azure / azure.azcollection / 2.3.0 / module / azure_rm_subnet Manage Azure subnets | "added in version" 0.1.0 of azure.azcollection" Authors: Chris Houseknecht (@chouseknecht), Matt Davis (@nitzmahone)azure.azcollection.azure_rm_subnet (2.3.0) — module
Install with ansible-galaxy collection install azure.azcollection:==2.3.0
collections: - name: azure.azcollection version: 2.3.0
Create, update or delete a subnet within a given virtual network.
Allows setting and updating the address prefix CIDR, which must be valid within the context of the virtual network.
Use the M(azure.azcollection.azure_rm_networkinterface) module to associate interfaces with the subnet and assign specific IP addresses.
- name: Create a subnet azure_rm_subnet: resource_group: myResourceGroup virtual_network_name: myVirtualNetwork name: mySubnet address_prefix_cidr: "10.1.0.0/24"
- name: Create a subnet refer nsg from other resource group azure_rm_subnet: resource_group: myResourceGroup virtual_network_name: myVirtualNetwork name: mySubnet address_prefix_cidr: "10.1.0.0/16" security_group: name: secgroupfoo resource_group: mySecondResourceGroup route_table: route
- name: Create a subnet with service endpoint azure_rm_subnet: resource_group: myResourceGroup virtual_network_name: myVirtualNetwork name: mySubnet address_prefix_cidr: "10.1.0.0/16" service_endpoints: - service: "Microsoft.Sql" locations: - "eastus"
- name: Create a subnet with delegations azure_rm_subnet: resource_group: myResourceGroup virtual_network_name: myVirtualNetwork name: mySubnet address_prefix_cidr: "10.1.0.0/16" delegations: - name: 'mydeleg' serviceName: 'Microsoft.ContainerInstance/containerGroups'
- name: Create a subnet with an associated NAT Gateway azure_rm_subnet: resource_group: myResourceGroup virtual_network_name: myVirtualNetwork name: mySubnet address_prefix_cidr: "10.1.0.0/16" nat_gateway: myNatGateway
- name: Delete a subnet azure_rm_subnet: resource_group: myResourceGroup virtual_network_name: myVirtualNetwork name: mySubnet state: absent
name: description: - Name of the subnet. required: true type: str state: choices: - absent - present default: present description: - Assert the state of the subnet. Use C(present) to create or update a subnet and use C(absent) to delete a subnet. type: str secret: description: - Azure client secret. Use when authenticating with a Service Principal. type: str tenant: description: - Azure tenant ID. Use when authenticating with a Service Principal. type: str ad_user: description: - Active Directory username. Use when authenticating with an Active Directory user rather than service principal. type: str profile: description: - Security profile found in ~/.azure/credentials file. type: str log_mode: description: - Parent argument. type: str log_path: description: - Parent argument. type: str password: description: - Active Directory user password. Use when authenticating with an Active Directory user rather than service principal. type: str client_id: description: - Azure client ID. Use when authenticating with a Service Principal or Managed Identity (msi). - Can also be set via the C(AZURE_CLIENT_ID) environment variable. type: str thumbprint: description: - The thumbprint of the private key specified in I(x509_certificate_path). - Use when authenticating with a Service Principal. - Required if I(x509_certificate_path) is defined. type: str version_added: 1.14.0 version_added_collection: azure.azcollection api_profile: default: latest description: - Selects an API profile to use when communicating with Azure services. Default value of C(latest) is appropriate for public clouds; future values will allow use with Azure Stack. type: str version_added: 0.0.1 version_added_collection: azure.azcollection auth_source: choices: - auto - cli - credential_file - env - msi default: auto description: - Controls the source of the credentials to use for authentication. - Can also be set via the C(ANSIBLE_AZURE_AUTH_SOURCE) environment variable. - When set to C(auto) (the default) the precedence is module parameters -> C(env) -> C(credential_file) -> C(cli). - When set to C(env), the credentials will be read from the environment variables - When set to C(credential_file), it will read the profile from C(~/.azure/credentials). - When set to C(cli), the credentials will be sources from the Azure CLI profile. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if more than one is present otherwise the default az cli subscription is used. - When set to C(msi), the host machine must be an azure resource with an enabled MSI extension. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if the resource is granted access to more than one subscription, otherwise the first subscription is chosen. - The C(msi) was added in Ansible 2.6. type: str version_added: 0.0.1 version_added_collection: azure.azcollection delegations: description: - An array of delegations. elements: dict suboptions: actions: default: [] description: - A list of actions. elements: str type: list name: description: - The name of delegation. required: true type: str serviceName: choices: - Microsoft.ContainerService/managedClusters - Microsoft.Web/serverFarms - Microsoft.ContainerInstance/containerGroups - Microsoft.Netapp/volumes - Microsoft.HardwareSecurityModules/dedicatedHSMs - Microsoft.ServiceFabricMesh/networks - Microsoft.Logic/integrationServiceEnvironments - Microsoft.Batch/batchAccounts - Microsoft.Sql/managedInstances - Microsoft.Web/hostingEnvironments - Microsoft.BareMetal/CrayServers - Microsoft.BareMetal/MonitoringServers - Microsoft.Databricks/workspaces - Microsoft.BareMetal/AzureHostedService - Microsoft.BareMetal/AzureVMware - Microsoft.BareMetal/AzureHPC - Microsoft.BareMetal/AzurePaymentHSM - Microsoft.StreamAnalytics/streamingJobs - Microsoft.DBforPostgreSQL/serversv2 - Microsoft.AzureCosmosDB/clusters - Microsoft.MachineLearningServices/workspaces - Microsoft.DBforPostgreSQL/singleServers - Microsoft.DBforPostgreSQL/flexibleServers - Microsoft.DBforMySQL/serversv2 - Microsoft.DBforMySQL/flexibleServers - Microsoft.ApiManagement/service - Microsoft.Synapse/workspaces - Microsoft.PowerPlatform/vnetaccesslinks - Microsoft.Network/managedResolvers - Microsoft.Kusto/clusters description: - The type of the endpoint service. required: true type: str type: list nat_gateway: description: - Existing NAT Gateway with which to associate the subnet. - It can be the NAT Gateway name which is in the same resource group. - Can be the resource ID of the NAT Gateway. - Can be a dict containing the I(name) and I(resource_group) of the NAT Gateway. type: str route_table: description: - The reference of the RouteTable resource. - Can be the name or resource ID of the route table. - Can be a dict containing the I(name) and I(resource_group) of the route table. - Without this configuration, the associated route table will be dissociate. If there is no associated route table, it has no impact. type: raw resource_group: description: - Name of resource group. required: true type: str security_group: aliases: - security_group_name description: - Existing security group with which to associate the subnet. - It can be the security group name which is in the same resource group. - Can be the resource ID of the security group. - Can be a dict containing the I(name) and I(resource_group) of the security group. type: raw subscription_id: description: - Your Azure subscription Id. type: str cloud_environment: default: AzureCloud description: - For cloud environments other than the US public cloud, the environment name (as defined by Azure Python SDK, eg, C(AzureChinaCloud), C(AzureUSGovernment)), or a metadata discovery endpoint URL (required for Azure Stack). Can also be set via credential file profile or the C(AZURE_CLOUD_ENVIRONMENT) environment variable. type: str version_added: 0.0.1 version_added_collection: azure.azcollection service_endpoints: description: - An array of service endpoints. elements: dict suboptions: locations: description: - A list of locations. elements: str type: list service: description: - The type of the endpoint service. required: true type: str type: list adfs_authority_url: description: - Azure AD authority url. Use when authenticating with Username/password, and has your own ADFS authority. type: str version_added: 0.0.1 version_added_collection: azure.azcollection address_prefix_cidr: aliases: - address_prefix description: - CIDR defining the IPv4 address space of the subnet. Must be valid within the context of the virtual network. type: str cert_validation_mode: choices: - ignore - validate description: - Controls the certificate validation behavior for Azure endpoints. By default, all modules will validate the server certificate, but when an HTTPS proxy is in use, or against Azure Stack, it may be necessary to disable this behavior by passing C(ignore). Can also be set via credential file profile or the C(AZURE_CERT_VALIDATION) environment variable. type: str version_added: 0.0.1 version_added_collection: azure.azcollection virtual_network_name: aliases: - virtual_network description: - Name of an existing virtual network with which the subnet is or will be associated. required: true type: str address_prefixes_cidr: aliases: - address_prefixes description: - CIDR defining the IPv4 and IPv6 address space of the subnet. Must be valid within the context of the virtual network. - If set I(address_prefix), It will not set. elements: str type: list version_added: 1.0.0 version_added_collection: azure.azcollection x509_certificate_path: description: - Path to the X509 certificate used to create the service principal in PEM format. - The certificate must be appended to the private key. - Use when authenticating with a Service Principal. type: path version_added: 1.14.0 version_added_collection: azure.azcollection disable_instance_discovery: default: false description: - Determines whether or not instance discovery is performed when attempting to authenticate. Setting this to true will completely disable both instance discovery and authority validation. This functionality is intended for use in scenarios where the metadata endpoint cannot be reached such as in private clouds or Azure Stack. The process of instance discovery entails retrieving authority metadata from https://login.microsoft.com/ to validate the authority. By setting this to **True**, the validation of the authority is disabled. As a result, it is crucial to ensure that the configured authority host is valid and trustworthy. - Set via credential file profile or the C(AZURE_DISABLE_INSTANCE_DISCOVERY) environment variable. type: bool version_added: 2.3.0 version_added_collection: azure.azcollection private_endpoint_network_policies: choices: - Enabled - Disabled default: Enabled description: - C(Enabled) or C(Disabled) apply network policies on private endpoints in the subnet. type: str private_link_service_network_policies: choices: - Enabled - Disabled default: Enabled description: - C(Enabled) or C(Disabled) apply network policies on private link service in the subnet. type: str
state: contains: address_prefix: description: - IP address CIDR. returned: always sample: 10.1.0.0/16 type: str address_prefixes: description: - IP address for IPv4 and IPv6 CIDR. returned: always sample: - 10.2.0.0/24 - fdda:e69b:1587:495e::/64 type: list delegations: contains: actions: description: - list of actions associated with service of delegation returned: when delegation is present sample: - Microsoft.Network/virtualNetworks/subnets/action type: list name: description: - name of delegation returned: when delegation is present sample: delegationname type: str serviceName: description: - service associated to delegation returned: when delegation is present sample: Microsoft.ContainerInstance/containerGroups type: str description: - Associated delegation of subnets returned: always type: list id: description: - Subnet resource path. returned: always sample: /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroup/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVirtualNetwork/subnets/mySubnet type: str name: description: - Subnet name. returned: always sample: foobar type: str network_security_group: contains: id: description: - Security group resource identifier. returned: always sample: /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroup/myResourceGroup/providers/Microsoft.Network/networkSecurityGroups/secgroupfoo type: str name: description: - Name of the security group. returned: always sample: secgroupfoo type: str description: - Associated network security group of subnets. returned: always type: complex private_endpoint_network_policies: description: - C(Enabled) or C(Disabled) apply network policies on private endpoints in the subnet. returned: always sample: Enabled type: str private_link_service_network_policies: description: - C(Enabled) or C(Disabled) apply network policies on private link service in the subnet. returned: always sample: Disabled type: str provisioning_state: description: - Success or failure of the provisioning event. returned: always sample: Succeeded type: str description: - Current state of the subnet. returned: success type: complex