diff --git a/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py b/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py index c89aca3f3c5..64a09776ce1 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py @@ -19,15 +19,16 @@ DOCUMENTATION = ''' --- module: azure_rm_networkinterface -version_added: "2.1" +version_added: '2.1' -short_description: Manage Azure network interfaces. +short_description: Manage Azure network interfaces description: - - Create, update or delete a network interface. When creating a network interface you must provide the name of an - existing virtual network, the name of an existing subnet within the virtual network. A default security group - and public IP address will be created automatically, or you can provide the name of an existing security group - and public IP address. See the examples below for more details. + - Create, update or delete a network interface. + - When creating a network interface you must provide the name of an existing virtual network, the name of an existing subnet within the virtual network. + - A default security group and public IP address will be created automatically. + - Or you can provide the name of an existing security group and public IP address. + - See the examples below for more details. options: resource_group: @@ -48,32 +49,30 @@ options: - present location: description: - - Valid azure location. Defaults to location of the resource group. + - Valid Azure location. Defaults to location of the resource group. virtual_network: description: - - An existing virtual network with which the network interface will be associated. Required - when creating a network interface. + - An existing virtual network with which the network interface will be associated. Required when creating a network interface. - It can be the virtual network's name. - Make sure your virtual network is in the same resource group as NIC when you give only the name. - It can be the virtual network's resource id. - - It can be a dict which contains C(name) and C(resource_group) of the virtual network. + - It can be a dict which contains I(name) and I(resource_group) of the virtual network. aliases: - virtual_network_name required: true subnet_name: description: - - Name of an existing subnet within the specified virtual network. Required when creating a network - interface + - Name of an existing subnet within the specified virtual network. Required when creating a network interface. - Use the C(virtual_network)'s resource group. aliases: - subnet required: true os_type: description: - - Determines any rules to be added to a default security group. When creating a network interface, if no - security group name is provided, a default security group will be created. If the os_type is 'Windows', - a rule will be added allowing RDP access. If the os_type is 'Linux', a rule allowing SSH access will be - added. + - Determines any rules to be added to a default security group. + - When creating a network interface, if no security group name is provided, a default security group will be created. + - If the I(os_type=Windows), a rule allowing RDP access will be added. + - If the I(os_type=Linux), a rule allowing SSH access will be added. choices: - Windows - Linux @@ -84,9 +83,9 @@ options: - This option will be deprecated in 2.9, use I(ip_configurations) instead. private_ip_allocation_method: description: - - "(Deprecate) Specify whether or not the assigned IP address is permanent. NOTE: when creating a network interface - specifying a value of 'Static' requires that a private_ip_address value be provided. You can update - the allocation method to 'Static' after a dynamic private ip address has been assigned." + - (Deprecate) Whether or not the assigned IP address is permanent. + - When creating a network interface, if you specify I(private_ip_address=Static), you must provide a value for I(private_ip_address). + - You can update the allocation method to C(Static) after a dynamic private IP address has been assigned. - This option will be deprecated in 2.9, use I(ip_configurations) instead. default: Dynamic choices: @@ -94,8 +93,8 @@ options: - Static public_ip: description: - - (Deprecate) When creating a network interface, if no public IP address name is provided a default public IP - address will be created. Set to false, if you do not want a public IP address automatically created. + - (Deprecate) When creating a network interface, if no public IP address name is provided a default public IP address will be created. + - Set to C(false) if you do not want a public IP address automatically created. - This option will be deprecated in 2.9, use I(ip_configurations) instead. type: bool default: 'yes' @@ -108,8 +107,8 @@ options: - public_ip_name public_ip_allocation_method: description: - - (Deprecate) If a public_ip_address_name is not provided, a default public IP address will be created. The allocation - method determines whether or not the public IP address assigned to the network interface is permanent. + - (Deprecate) If a I(public_ip_address_name) is not provided, a default public IP address will be created. + - The allocation method determines whether or not the public IP address assigned to the network interface is permanent. - This option will be deprecated in 2.9, use I(ip_configurations) instead. choices: - Dynamic @@ -117,103 +116,103 @@ options: default: Dynamic ip_configurations: description: - - List of ip configuration if contains mutilple configuration, should contain configuration object include - field private_ip_address, private_ip_allocation_method, public_ip_address_name, public_ip, public_ip_allocation_method, name + - List of IP configurations. Each configuration object should include + field I(private_ip_address), I(private_ip_allocation_method), I(public_ip_address_name), I(public_ip), I(public_ip_allocation_method), I(name). suboptions: name: description: - - Name of the ip configuration. + - Name of the IP configuration. required: true private_ip_address: description: - - Private ip address for the ip configuration. + - Private IP address for the IP configuration. private_ip_allocation_method: description: - - private ip allocation method. + - Private IP allocation method. choices: - Dynamic - Static default: Dynamic public_ip_address_name: description: - - Name of the public ip address. None for disable ip address. + - Name of the public IP address. None for disable IP address. aliases: - public_ip_address - public_ip_name public_ip_allocation_method: description: - - public ip allocation method. + - Public IP allocation method. choices: - Dynamic - Static default: Dynamic load_balancer_backend_address_pools: description: - - List of an existing load-balancer backend address pool id to associate with the network interface. - - It can be write as a resource id. + - List of existing load-balancer backend address pools to associate with the network interface. + - Can be written as a resource ID. - Also can be a dict of I(name) and I(load_balancer). - version_added: 2.6 + version_added: '2.6' primary: description: - - Whether the ip configuration is the primary one in the list. + - Whether the IP configuration is the primary one in the list. type: bool default: 'no' application_security_groups: description: - List of application security groups in which the IP configuration is included. - - Element of the list could be a resource id of application security group, or dict of C(resource_group) and C(name). - version_added: 2.8 - version_added: 2.5 + - Element of the list could be a resource id of application security group, or dict of I(resource_group) and I(name). + version_added: '2.8' + version_added: '2.5' enable_accelerated_networking: description: - - Specifies whether the network interface should be created with the accelerated networking feature or not + - Whether the network interface should be created with the accelerated networking feature or not. type: bool - version_added: 2.7 + version_added: '2.7' default: False create_with_security_group: description: - - Specifies whether a security group should be be created with the NIC. - - If this flag set to C(True) and no C(security_group) set, a default security group will be created. + - Whether a security group should be be created with the NIC. + - If this flag set to C(True) and no I(security_group) set, a default security group will be created. type: bool - version_added: 2.6 + version_added: '2.6' default: True security_group: description: - - An existing security group with which to associate the network interface. If not provided, a - default security group will be created when C(create_with_security_group) is true. + - An existing security group with which to associate the network interface. + - If not provided, a default security group will be created when I(create_with_security_group=true). - It can be the name of security group. - Make sure the security group is in the same resource group when you only give its name. - It can be the resource id. - - It can be a dict contains security_group's C(name) and C(resource_group). + - It can be a dict contains security_group's I(name) and I(resource_group). aliases: - security_group_name open_ports: description: - When a default security group is created for a Linux host a rule will be added allowing inbound TCP - connections to the default SSH port 22, and for a Windows host rules will be added allowing inbound - access to RDP ports 3389 and 5986. Override the default ports by providing a list of open ports. + connections to the default SSH port C(22), and for a Windows host rules will be added allowing inbound + access to RDP ports C(3389) and C(5986). Override the default ports by providing a list of open ports. enable_ip_forwarding: description: - - Whether to enable IP forwarding + - Whether to enable IP forwarding. aliases: - ip_forwarding type: bool default: False - version_added: 2.7 + version_added: '2.7' dns_servers: description: - - Which DNS servers should the NIC lookup - - List of IP's + - Which DNS servers should the NIC lookup. + - List of IP addresses. type: list - version_added: 2.7 + version_added: '2.7' extends_documentation_fragment: - azure - azure_tags author: - - "Chris Houseknecht (@chouseknecht)" - - "Matt Davis (@nitzmahone)" - - "Yuwei Zhou (@yuwzho)" + - Chris Houseknecht (@chouseknecht) + - Matt Davis (@nitzmahone) + - Yuwei Zhou (@yuwzho) ''' EXAMPLES = ''' @@ -266,7 +265,7 @@ EXAMPLES = ''' public_ip_address_name: publicip001 primary: True - - name: Create a network with mutilple ip configurations + - name: Create a network with multiple ip configurations azure_rm_networkinterface: name: nic004 resource_group: myResourceGroup @@ -323,43 +322,137 @@ EXAMPLES = ''' RETURN = ''' state: - description: The current state of the network interface. + description: + - The current state of the network interface. returned: always - type: dict - sample: { - "dns_settings": { - "applied_dns_servers": [], - "dns_servers": [], - "internal_dns_name_label": null, - "internal_fqdn": null - }, - "enable_ip_forwarding": false, - "etag": 'W/"be115a43-2148-4545-a324-f33ad444c926"', - "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroup/myResourceGroup/providers/Microsoft.Network/networkInterfaces/nic003", - "ip_configurations": [{ - "name": "default", - "private_ip_address": "10.1.0.10", - "private_ip_allocation_method": "Static", - "public_ip_address": { - "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroup/myResourceGroup/providers/Microsoft.Network/publicIPAddresse - s/publicip001", - "name": "publicip001" - }, - "subnet": {}, - "load_balancer_backend_address_pools": [] - }], - "location": "eastus2", - "mac_address": null, - "name": "nic003", - "network_security_group": { - "id": "/subscriptions//xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroup/myResourceGroup/providers/Microsoft.Network/networkSecurityGroups/nsg001", - "name": "nsg001" - }, - "primary": null, - "provisioning_state": "Succeeded", - "tags": null, - "type": "Microsoft.Network/networkInterfaces" - } + type: complex + contains: + dns_server: + description: + - Which DNS servers should the NIC lookup. + - List of IP addresses. + type: list + sample: ['8.9.10.11', '7.8.9.10'] + dns_setting: + description: + - The DNS settings in network interface. + type: dict + sample: { + "applied_dns_servers": [], + "dns_servers": [ + "8.9.10.11", + "7.8.9.10" + ], + "internal_dns_name_label": null, + "internal_fqdn": null + } + enable_ip_forwarding: + description: + Whether to enable IP forwarding. + type: bool + sample: true + etag: + description: + - A unique read-only string that changes whenever the resource is updated. + type: str + sample: 'W/"be115a43-2148-4545-a324-f33ad444c926"' + id: + description: + - Id of the network interface. + type: str + sample: "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroup/myResourceGroup/providers/Microsoft.Network/networkInterfaces/nic003" + enable_accelerated_networking: + description: + - Whether the network interface should be created with the accelerated networking feature or not. + type: bool + sample: true + ip_configurations: + description: + - List of IP configurations. + type: complex + contains: + name: + description: + - Name of the IP configuration. + type: str + sample: default + load_balancer_backend_address_pools: + description: + - List of existing load-balancer backend address pools to associate with the network interface. + type: list + private_ip_address: + description: + - Private IP address for the IP configuration. + type: str + sample: "10.1.0.10" + private_ip_allocation_method: + description: + - Private IP allocation method. + type: str + sample: "Static" + public_ip_address: + description: + - Name of the public IP address. None for disable IP address. + type: dict + sample: { + "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroup/myResourceGroup/providers/Microsoft.Network/publicIPAddresse + s/publicip001", + "name": "publicip001" + } + subnet: + description: + - The reference of the subnet resource. + type: dict + sample: { + "id": "/subscriptions/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/ + myresourcegroup/providers/Microsoft.Network/virtualNetworks/tnb57dc95318/subnets/tnb57dc95318", + "name": "tnb57dc95318", + "resource_group": "myresourcegroup", + "virtual_network_name": "tnb57dc95318" + } + location: + description: + - The network interface resource location. + type: str + sample: eastus + mac_address: + description: + - The MAC address of the network interface. + type: str + name: + description: + - Name of the network interface. + type: str + sample: nic003 + network_security_group: + description: + - The reference of the network security group resource. + type: dict + sample: { + "id": "/subscriptions//xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroup/ + myResourceGroup/providers/Microsoft.Network/networkSecurityGroups/nsg001", + "name": "nsg001" + } + primary: + description: + - Get whether this is a primary network interface on virtual machine. + type: bool + sample: true + provisioning_state: + description: + - The provisioning state of the public IP resource. + type: str + sample: Succeeded + tags: + description: + -Tags of the network interface. + type: dict + sample: { 'key': 'value' } + type: + description: + - Type of the resource. + type: str + sample: "Microsoft.Network/networkInterfaces" ''' try: diff --git a/lib/ansible/modules/cloud/azure/azure_rm_networkinterface_facts.py b/lib/ansible/modules/cloud/azure/azure_rm_networkinterface_facts.py index 566ee6c81f5..4003375a20e 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_networkinterface_facts.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_networkinterface_facts.py @@ -20,7 +20,7 @@ module: azure_rm_networkinterface_facts version_added: "2.1" -short_description: Get network interface facts. +short_description: Get network interface facts description: - Get facts for a specific network interface or all network interfaces within a resource group. @@ -40,8 +40,8 @@ extends_documentation_fragment: - azure author: - - "Chris Houseknecht (@chouseknecht)" - - "Matt Davis (@nitzmahone)" + - Chris Houseknecht (@chouseknecht) + - Matt Davis (@nitzmahone) ''' @@ -65,7 +65,8 @@ EXAMPLES = ''' RETURN = ''' azure_networkinterfaces: - description: List of network interface dicts. + description: + - List of network interface dicts. returned: always type: list example: [{ @@ -105,7 +106,8 @@ azure_networkinterfaces: "type": "Microsoft.Network/networkInterfaces" }] networkinterfaces: - description: List of network interface dict, the dict contains parameters can be passed to C(azure_rm_networkinterface) module. + description: + - List of network interface dicts. Each dict contains parameters can be passed to M(azure_rm_networkinterface) module. type: list returned: always contains: @@ -124,7 +126,7 @@ networkinterfaces: virtual_network: description: - An existing virtual network with which the network interface will be associated. - - It is a dict which contains C(name) and C(resource_group) of the virtual network. + - It is a dict which contains I(name) and I(resource_group) of the virtual network. subnet: description: - Name of an existing subnet within the specified virtual network. @@ -133,36 +135,36 @@ networkinterfaces: - Tags of the network interface. ip_configurations: description: - - List of ip configuration if contains mutilple configuration. + - List of IP configurations, if contains multiple configurations. contains: name: description: - - Name of the ip configuration. + - Name of the IP configuration. private_ip_address: description: - - Private ip address for the ip configuration. + - Private IP address for the IP configuration. private_ip_allocation_method: description: - - private ip allocation method. + - Private IP allocation method. public_ip_address: description: - - Name of the public ip address. None for disable ip address. + - Name of the public IP address. None for disable IP address. public_ip_allocation_method: description: - - public ip allocation method. + - Public IP allocation method. load_balancer_backend_address_pools: description: - - List of an existing load-balancer backend address pool id to associate with the network interface. + - List of existing load-balancer backend address pools to associate with the network interface. primary: description: - - Whether the ip configuration is the primary one in the list. + - Whether the IP configuration is the primary one in the list. application_security_groups: description: - List of Application security groups. sample: /subscriptions//resourceGroups//providers/Microsoft.Network/applicationSecurityGroups/myASG enable_accelerated_networking: description: - - Specifies whether the network interface should be created with the accelerated networking feature or not + - Specifies whether the network interface should be created with the accelerated networking feature or not. create_with_security_group: description: - Specifies whether a default security group should be be created with the NIC. Only applies when creating a new NIC. @@ -175,8 +177,8 @@ networkinterfaces: - Whether to enable IP forwarding dns_servers: description: - - Which DNS servers should the NIC lookup - - List of IP's + - Which DNS servers should the NIC lookup. + - List of IP addresses. mac_address: description: - The MAC address of the network interface. @@ -188,15 +190,18 @@ networkinterfaces: - The DNS settings in network interface. contains: dns_servers: - description: List of DNS servers IP addresses. + description: + - List of DNS servers IP addresses. applied_dns_servers: description: - If the VM that uses this NIC is part of an Availability Set, then this list will have the union of all DNS servers from all NICs that are part of the Availability Set. This property is what is configured on each of those VMs. internal_dns_name_label: - description: Relative DNS name for this NIC used for internal communications between VMs in the same virtual network. + description: + - Relative DNS name for this NIC used for internal communications between VMs in the same virtual network. internal_fqdn: - description: Fully qualified DNS name supporting internal communications between VMs in the same virtual network. + description: + - Fully qualified DNS name supporting internal communications between VMs in the same virtual network. ''' # NOQA try: from msrestazure.azure_exceptions import CloudError