|
21 | 21 | VPN: "{{ subnet_item.VPN }}" |
22 | 22 | Subnet: "{{ subnet_item.name }}" |
23 | 23 | type: "{{ subnet_item.type }}" |
| 24 | + sku: standard |
24 | 25 | loop: |
25 | 26 | - "{{ mgmt_subnet }}" |
26 | 27 | - "{{ transport_subnet }}" |
27 | 28 | loop_control: |
28 | 29 | loop_var: subnet_item |
29 | 30 | register: public_ip_addresses |
30 | 31 |
|
| 32 | +- name: "Create public IPv6 addresses for machine: {{ hostname }}" |
| 33 | + azure.azcollection.azure_rm_publicipaddress: |
| 34 | + resource_group: "{{ az_resource_group }}" |
| 35 | + allocation_method: static |
| 36 | + name: "public-ipv6-{{ hostname }}-vpn-{{ subnet_item.VPN }}" |
| 37 | + tags: |
| 38 | + Name: "public-ipv6-{{ hostname }}" |
| 39 | + Creator: "{{ az_tag_creator }}" |
| 40 | + Machine: "{{ hostname }}" |
| 41 | + VPN: "{{ subnet_item.VPN }}" |
| 42 | + Subnet: "{{ subnet_item.name }}" |
| 43 | + type: "{{ subnet_item.type }}" |
| 44 | + version: ipv6 |
| 45 | + sku: standard |
| 46 | + loop: |
| 47 | + - "{{ mgmt_subnet }}" |
| 48 | + - "{{ transport_subnet }}" |
| 49 | + loop_control: |
| 50 | + loop_var: subnet_item |
| 51 | + register: public_ipv6_addresses |
| 52 | + |
31 | 53 | - name: "Get info about NSG: {{ az_network_security_group }}" |
32 | 54 | azure.azcollection.azure_rm_securitygroup_info: |
33 | 55 | resource_group: "{{ az_resource_group }}" |
|
51 | 73 | Name: "{{ az_network_security_group }}" |
52 | 74 | Creator: "{{ az_tag_creator }}" |
53 | 75 | Organization: "{{ organization_name }}" |
54 | | - loop: "{{ public_ip_addresses.results }}" |
| 76 | + loop: "{{ public_ip_addresses.results + public_ipv6_addresses.results }}" |
55 | 77 | loop_control: |
56 | 78 | loop_var: public_ip_state |
57 | 79 | index_var: my_idx |
|
71 | 93 | - name: "ipconfig-vpn-{{ public_ip_state.state.tags.VPN }}" |
72 | 94 | public_ip_address_name: "{{ public_ip_state.state.name }}" |
73 | 95 | private_ip_allocation_method: "Dynamic" |
| 96 | + - name: "ipconfig-vpn-{{ public_ip_state.state.tags.VPN }}-ipv6" |
| 97 | + public_ip_address_name: "{{ public_ipv6_addresses.results | json_query(_public_ip_query) | first }}" |
| 98 | + private_ip_allocation_method: "Dynamic" |
| 99 | + private_ip_address_version: IPv6 |
74 | 100 | tags: |
75 | 101 | Name: "nic-{{ hostname }}-{{ public_ip_state.state.tags.type }}-vpn-{{ public_ip_state.state.tags.VPN }}" |
76 | 102 | Creator: "{{ az_tag_creator }}" |
|
85 | 111 | register: vmanage_nics |
86 | 112 | when: |
87 | 113 | - public_ip_state.state is defined |
| 114 | + vars: |
| 115 | + _public_ip_query: "[?to_number(state.tags.VPN)==`{{ public_ip_state.state.tags.VPN }}`].state.name" |
88 | 116 |
|
89 | 117 | - name: "Create virtual network interface card if cluster deployment" |
90 | 118 | azure.azcollection.azure_rm_networkinterface: |
|
140 | 168 | - name: Set az_network_interfaces_vmanage fact with a list of interfaces for vmanage |
141 | 169 | ansible.builtin.set_fact: |
142 | 170 | az_network_interfaces_vmanage: "{{ (vmanage_nics.results + [cluster_vmanage_nic]) | selectattr('state', 'defined') | map(attribute='state') | list }}" |
143 | | - az_public_ip_addresses_vmanage: "{{ public_ip_addresses.results | selectattr('state', 'defined') | map(attribute='state') | list }}" |
| 171 | + az_public_ip_addresses_vmanage: "{{ (public_ip_addresses.results + public_ipv6_addresses.results) | selectattr('state', 'defined') | map(attribute='state') | list }}" |
144 | 172 |
|
145 | 173 | - name: Filter az_network_interfaces_vmanage for instance creation. Set az_mgmt_nic and az_transport_nic facts |
146 | 174 | ansible.builtin.set_fact: |
147 | 175 | az_mgmt_nic: "{{ az_network_interfaces_vmanage | selectattr('tags.type', 'equalto', 'mgmt') | list | first }}" |
148 | 176 | az_transport_nic: "{{ az_network_interfaces_vmanage | selectattr('tags.type', 'equalto', 'transport') | list | first }}" |
149 | 177 | az_cluster_nic: "{{ az_network_interfaces_vmanage | selectattr('tags.type', 'equalto', 'cluster') | list | first | default(omit) }}" |
150 | | - az_mgmt_public_ip: "{{ az_public_ip_addresses_vmanage | selectattr('tags.type', 'equalto', 'mgmt') | list | first }}" |
151 | | - az_transport_public_ip: "{{ az_public_ip_addresses_vmanage | selectattr('tags.type', 'equalto', 'transport') | list | first }}" |
| 178 | + az_mgmt_public_ip: "{{ _mgmt_public_ips | selectattr('public_ip_address_version', 'equalto', 'ipv4') | list | first }}" |
| 179 | + az_transport_public_ip: "{{ _transport_public_ips | selectattr('public_ip_address_version', 'equalto', 'ipv4') | list | first }}" |
| 180 | + az_mgmt_public_ipv6: "{{ _mgmt_public_ips | selectattr('public_ip_address_version', 'equalto', 'ipv6') | list | first }}" |
| 181 | + az_transport_public_ipv6: "{{ _transport_public_ips | selectattr('public_ip_address_version', 'equalto', 'ipv6') | list | first }}" |
| 182 | + vars: |
| 183 | + _mgmt_public_ips: "{{ az_public_ip_addresses_vbond | selectattr('tags.VPN', 'equalto', '512') }}" |
| 184 | + _transport_public_ips: "{{ az_public_ip_addresses_vbond | selectattr('tags.VPN', 'equalto', '0') }}" |
152 | 185 |
|
153 | 186 | - name: Prepare nics_ids_list variable for VM creation |
154 | 187 | ansible.builtin.set_fact: |
|
169 | 202 |
|
170 | 203 | - name: "Set vmanage facts" |
171 | 204 | ansible.builtin.set_fact: |
172 | | - vmanage_mgmt_private_ip: "{{ az_mgmt_nic.ip_configuration.private_ip_address }}" |
173 | | - vmanage_transport_private_ip: "{{ az_transport_nic.ip_configuration.private_ip_address }}" |
| 205 | + vmanage_mgmt_private_ip: "{{ (az_mgmt_nic.ip_configurations | json_query('[?private_ip_address_version==`IPv4`]') | first).private_ip_address }}" |
| 206 | + vmanage_mgmt_private_ipv6: "{{ (az_mgmt_nic.ip_configurations | json_query('[?private_ip_address_version==`IPv6`]') | first).private_ip_address }}" |
| 207 | + vmanage_transport_private_ip: "{{ (az_transport_nic.ip_configurations | json_query('[?private_ip_address_version==`IPv4`]') | first).private_ip_address }}" |
| 208 | + vmanage_transport_private_ipv6: "{{ (az_transport_nic.ip_configurations | json_query('[?private_ip_address_version==`IPv6`]') | first).private_ip_address }}" |
174 | 209 | vmanage_mgmt_public_ip: "{{ az_mgmt_public_ip.ip_address }}" |
175 | 210 | vmanage_transport_public_ip: "{{ az_transport_public_ip.ip_address }}" |
| 211 | + vmanage_mgmt_public_ipv6: "{{ az_mgmt_public_ipv6.ip_address }}" |
| 212 | + vmanage_transport_public_ipv6: "{{ az_transport_public_ipv6.ip_address }}" |
176 | 213 | vmanage_persona: "{{ persona | default(vmanage_default_persona) }}" |
177 | 214 |
|
178 | 215 | - name: "Set vmanage cluster related facts" |
|
185 | 222 |
|
186 | 223 | - name: "Set vpn0_default_gateway fact from VPN 0 subnet value" |
187 | 224 | ansible.builtin.set_fact: |
188 | | - vpn0_default_gateway: "{{ subnet.cidr | ansible.utils.ipaddr('1') | ansible.utils.ipaddr('address') }}" |
| 225 | + vpn0_default_gateway: "{{ subnet.cidr[0] | ansible.utils.ipaddr('1') | ansible.utils.ipaddr('address') }}" |
189 | 226 | loop: "{{ az_subnets }}" |
190 | 227 | loop_control: |
191 | 228 | loop_var: subnet |
|
254 | 291 | admin_password: "{{ admin_password }}" |
255 | 292 | mgmt_public_ip: "{{ vmanage_mgmt_public_ip }}" |
256 | 293 | transport_public_ip: "{{ vmanage_transport_public_ip }}" |
| 294 | + mgmt_public_ipv6: "{{ vmanage_mgmt_public_ipv6 }}" |
| 295 | + transport_public_ipv6: "{{ vmanage_transport_public_ipv6 }}" |
257 | 296 | cluster_private_ip: "{{ vmanage_cluster_private_ip | default(omit) }}" |
258 | 297 | persona: "{{ vmanage_persona }}" |
259 | 298 | changed_when: true |
|
0 commit comments