New in version 2.1.
parameter | required | default | choices | comments | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ad_user | no | Active Directory username. Use when authenticating with an Active Directory user rather than service principal. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
append_tags | no | True | Use to control if tags field is canonical or just appends to existing tags. When canonical, any tags not found in the tags parameter will be removed from the object's metadata. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
client_id | no | Azure client ID. Use when authenticating with a Service Principal. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cloud_environment | no | AzureCloud | For cloud environments other than the US public cloud, the environment name (as defined by Azure Python SDK, eg, AzureChinaCloud , AzureUSGovernment ), or a metadata discovery endpoint URL (required for Azure Stack). Can also be set via credential file profile or the AZURE_CLOUD_ENVIRONMENT environment variable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
default_rules | no | The set of default rules automatically added to a security group at creation. In general default rules will not be modified. Modify rules to shape the flow of traffic to or from a subnet or NIC. See rules below for the makeup of a rule dict. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
location | no | resource_group location | Valid azure location. Defaults to location of the resource group. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name | no | Name of the security group to operate on. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
password | no | Active Directory user password. Use when authenticating with an Active Directory user rather than service principal. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
profile | no | Security profile found in ~/.azure/credentials file. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
purge_default_rules | no | Remove any existing rules not matching those defined in the default_rules parameter. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
purge_rules | no | Remove any existing rules not matching those defined in the rules parameters. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
resource_group | yes | Name of the resource group the security group belongs to. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rules | no | Set of rules shaping traffic flow to or from a subnet or NIC. Each rule is a dictionary. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
secret | no | Azure client secret. Use when authenticating with a Service Principal. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
state | no | present |
| Assert the state of the security group. Set to 'present' to create or update a security group. Set to 'absent' to remove a security group. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
subscription_id | no | Your Azure subscription Id. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tags | no | Dictionary of string:string pairs to assign as metadata to the object. Metadata tags on the object will be updated with any provided values. To remove tags set append_tags option to false. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tenant | no | Azure tenant ID. Use when authenticating with a Service Principal. |
# Create a security group - azure_rm_securitygroup: resource_group: mygroup name: mysecgroup purge_rules: yes rules: - name: DenySSH protocol: TCP destination_port_range: 22 access: Deny priority: 100 direction: Inbound - name: 'AllowSSH' protocol: TCP source_address_prefix: '174.109.158.0/24' destination_port_range: 22 access: Allow priority: 101 direction: Inbound # Update rules on existing security group - azure_rm_securitygroup: resource_group: mygroup name: mysecgroup rules: - name: DenySSH protocol: TCP destination_port_range: 22-23 access: Deny priority: 100 direction: Inbound - name: AllowSSHFromHome protocol: TCP source_address_prefix: '174.109.158.0/24' destination_port_range: 22-23 access: Allow priority: 102 direction: Inbound tags: testing: testing delete: on-exit # Delete security group - azure_rm_securitygroup: resource_group: mygroup name: mysecgroup state: absent
Common return values are documented here Return Values, the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
state | Current state of the security group. | always | dict | {'subnets': [], 'name': 'mysecgroup', 'tags': {'foo': 'bar', 'testing': 'testing', 'delete': 'on-exit'}, 'rules': [{'access': 'Deny', 'destination_address_prefix': '*', 'protocol': 'Tcp', 'description': None, 'direction': 'Inbound', 'provisioning_state': 'Succeeded', 'priority': 100, 'etag': 'W/"edf48d56-b315-40ca-a85d-dbcb47f2da7d"', 'source_port_range': '*', 'source_address_prefix': '*', 'id': '/subscriptions/3f7e29ba-24e0-42f6-8d9c-5149a14bda37/resourceGroups/Testing/providers/Microsoft.Network/networkSecurityGroups/mysecgroup/securityRules/DenySSH', 'destination_port_range': '22', 'name': 'DenySSH'}, {'access': 'Allow', 'destination_address_prefix': '*', 'protocol': 'Tcp', 'description': None, 'direction': 'Inbound', 'provisioning_state': 'Succeeded', 'priority': 101, 'etag': 'W/"edf48d56-b315-40ca-a85d-dbcb47f2da7d"', 'source_port_range': '*', 'source_address_prefix': '174.109.158.0/24', 'id': '/subscriptions/3f7e29ba-24e0-42f6-8d9c-5149a14bda37/resourceGroups/Testing/providers/Microsoft.Network/networkSecurityGroups/mysecgroup/securityRules/AllowSSH', 'destination_port_range': '22', 'name': 'AllowSSH'}], 'network_interfaces': [], 'default_rules': [{'access': 'Allow', 'destination_address_prefix': 'VirtualNetwork', 'protocol': '*', 'description': 'Allow inbound traffic from all VMs in VNET', 'direction': 'Inbound', 'provisioning_state': 'Succeeded', 'priority': 65000, 'etag': 'W/"edf48d56-b315-40ca-a85d-dbcb47f2da7d"', 'source_port_range': '*', 'source_address_prefix': 'VirtualNetwork', 'id': '/subscriptions/3f7e29ba-24e0-42f6-8d9c-5149a14bda37/resourceGroups/Testing/providers/Microsoft.Network/networkSecurityGroups/mysecgroup/defaultSecurityRules/AllowVnetInBound', 'destination_port_range': '*', 'name': 'AllowVnetInBound'}, {'access': 'Allow', 'destination_address_prefix': '*', 'protocol': '*', 'description': 'Allow inbound traffic from azure load balancer', 'direction': 'Inbound', 'provisioning_state': 'Succeeded', 'priority': 65001, 'etag': 'W/"edf48d56-b315-40ca-a85d-dbcb47f2da7d"', 'source_port_range': '*', 'source_address_prefix': 'AzureLoadBalancer', 'id': '/subscriptions/3f7e29ba-24e0-42f6-8d9c-5149a14bda37/resourceGroups/Testing/providers/Microsoft.Network/networkSecurityGroups/mysecgroup/defaultSecurityRules/AllowAzureLoadBalancerInBound', 'destination_port_range': '*', 'name': 'AllowAzureLoadBalancerInBound'}, {'access': 'Deny', 'destination_address_prefix': '*', 'protocol': '*', 'description': 'Deny all inbound traffic', 'direction': 'Inbound', 'provisioning_state': 'Succeeded', 'priority': 65500, 'etag': 'W/"edf48d56-b315-40ca-a85d-dbcb47f2da7d"', 'source_port_range': '*', 'source_address_prefix': '*', 'id': '/subscriptions/3f7e29ba-24e0-42f6-8d9c-5149a14bda37/resourceGroups/Testing/providers/Microsoft.Network/networkSecurityGroups/mysecgroup/defaultSecurityRules/DenyAllInBound', 'destination_port_range': '*', 'name': 'DenyAllInBound'}, {'access': 'Allow', 'destination_address_prefix': 'VirtualNetwork', 'protocol': '*', 'description': 'Allow outbound traffic from all VMs to all VMs in VNET', 'direction': 'Outbound', 'provisioning_state': 'Succeeded', 'priority': 65000, 'etag': 'W/"edf48d56-b315-40ca-a85d-dbcb47f2da7d"', 'source_port_range': '*', 'source_address_prefix': 'VirtualNetwork', 'id': '/subscriptions/3f7e29ba-24e0-42f6-8d9c-5149a14bda37/resourceGroups/Testing/providers/Microsoft.Network/networkSecurityGroups/mysecgroup/defaultSecurityRules/AllowVnetOutBound', 'destination_port_range': '*', 'name': 'AllowVnetOutBound'}, {'access': 'Allow', 'destination_address_prefix': 'Internet', 'protocol': '*', 'description': 'Allow outbound traffic from all VMs to Internet', 'direction': 'Outbound', 'provisioning_state': 'Succeeded', 'priority': 65001, 'etag': 'W/"edf48d56-b315-40ca-a85d-dbcb47f2da7d"', 'source_port_range': '*', 'source_address_prefix': '*', 'id': '/subscriptions/3f7e29ba-24e0-42f6-8d9c-5149a14bda37/resourceGroups/Testing/providers/Microsoft.Network/networkSecurityGroups/mysecgroup/defaultSecurityRules/AllowInternetOutBound', 'destination_port_range': '*', 'name': 'AllowInternetOutBound'}, {'access': 'Deny', 'destination_address_prefix': '*', 'protocol': '*', 'description': 'Deny all outbound traffic', 'direction': 'Outbound', 'provisioning_state': 'Succeeded', 'priority': 65500, 'etag': 'W/"edf48d56-b315-40ca-a85d-dbcb47f2da7d"', 'source_port_range': '*', 'source_address_prefix': '*', 'id': '/subscriptions/3f7e29ba-24e0-42f6-8d9c-5149a14bda37/resourceGroups/Testing/providers/Microsoft.Network/networkSecurityGroups/mysecgroup/defaultSecurityRules/DenyAllOutBound', 'destination_port_range': '*', 'name': 'DenyAllOutBound'}], 'location': 'westus', 'type': 'Microsoft.Network/networkSecurityGroups', 'id': '/subscriptions/3f7e29ba-24e0-42f6-8d9c-5149a14bda37/resourceGroups/Testing/providers/Microsoft.Network/networkSecurityGroups/mysecgroup'} |
Note
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/azure_rm_securitygroup_module.html