Virtual machines should reference explicit network interfaces so network security controls (for example, Network Security Groups) can be applied and network exposure is predictable. Without explicit NIC configuration, instances may be created without NSGs or with default networking that exposes them to unintended access.
For Ansible VM tasks using azure.azcollection.azure_rm_virtualmachine or azure_rm_virtualmachine, either the network_interface_names property (a list of existing NIC names) or the network_interfaces property (a list of interface definitions) must be defined. Tasks missing both network_interface_names and network_interfaces are flagged. This rule verifies the presence of NIC references only and does not validate whether the referenced NICs themselves have NSGs attached.
Secure configuration examples:
- name:Create VM with NIC nameazure.azcollection.azure_rm_virtualmachine:name:myVMresource_group:myRGnetwork_interface_names:- myNic- name:Create VM with inline NIC definitionazure.azcollection.azure_rm_virtualmachine:name:myVM2resource_group:myRGnetwork_interfaces:- name:myNic2primary:true
Compliant Code Examples
- name:Create a VM with a custom imageazure_rm_virtualmachine:resource_group:myResourceGroupname:testvm001vm_size:Standard_DS1_v2admin_username:adminUseradmin_password:password01image:customimage001network_interfaces:testvm001
Non-Compliant Code Examples
---- name:Create a VM with a custom imageazure_rm_virtualmachine:resource_group:myResourceGroupname:testvm001vm_size:Standard_DS1_v2admin_username:adminUseradmin_password:password01image:customimage001
1
2
rulesets:- Ansible / Azure # Rules to enforce / Azure.
パーソナライズされたデモをリクエスト
Datadog を始める
Ask AI
AI-generated responses may be inaccurate. Verify important info.