Managing an Azure network security group
In Azure, a network security group is an access control list (ACL), which allows and denies network traffic to subnets or an individual NIC. In this recipe, we will create a network security group with some basic rules for allowing web (HTTP and HTTPS) and SSH (port22) traffic and denying the rest of the traffic. Since a network security group is the property of the network and not the virtual machine, we can use subnets to group our virtual machines and keep them in the same network security group for the same ACL.
How to do it...
- Create a network security group:
- name: Create network security group azure_rm_securitygroup: resource_group: example name: mysg01 purge_rules: yes rules: - name: 'AllowSSH' protocol: TCP source_address_prefix: * destination_port_range: 22 access: Allow priority: 100 direction: Inbound - name: 'AllowHTTP' protocol: TCP...