1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/azure_rm_virtualnetworkpeering/tasks/main.yml

110 lines
3.1 KiB
YAML
Raw Normal View History

- name: Prepare random number
set_fact:
vnetname1: "vnet1{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
vnetname2: "vnet2{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
peering_name: "peering1{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 100 | random }}"
- name: Create first virtual network
azure_rm_virtualnetwork:
name: "{{ vnetname1 }}"
address_prefixes_cidr:
- 10.1.0.0/16
tags:
testing: testing
delete: on-exit
resource_group: "{{ resource_group }}"
register: vnet1
- name: Create second virtual network
azure_rm_virtualnetwork:
name: "{{ vnetname2 }}"
address_prefixes_cidr:
- 10.2.0.0/24
resource_group: "{{ resource_group_secondary }}"
register: vnet2
- assert:
that:
- vnet1.changed
- vnet2.changed
- name: Create virtual network peering (check mode)
azure_rm_virtualnetworkpeering:
resource_group: "{{ resource_group }}"
name: "{{ peering_name }}"
virtual_network: "{{ vnetname1 }}"
remote_virtual_network:
resource_group: "{{ resource_group_secondary }}"
name: "{{ vnetname2 }}"
allow_virtual_network_access: false
allow_forwarded_traffic: true
check_mode: yes
register: output
- assert:
that: output.changed
- name: Create virtual network peering
azure_rm_virtualnetworkpeering:
resource_group: "{{ resource_group }}"
name: "{{ peering_name }}"
virtual_network: "{{ vnetname1 }}"
remote_virtual_network:
resource_group: "{{ resource_group_secondary }}"
name: "{{ vnetname2 }}"
allow_virtual_network_access: false
allow_forwarded_traffic: true
register: output
- assert:
that: output.changed
- name: Update virtual network peering (idempotent)
azure_rm_virtualnetworkpeering:
resource_group: "{{ resource_group }}"
name: "{{ peering_name }}"
virtual_network: "{{ vnetname1 }}"
remote_virtual_network:
resource_group: "{{ resource_group_secondary }}"
name: "{{ vnetname2 }}"
allow_virtual_network_access: false
allow_forwarded_traffic: true
register: output
- assert:
that: not output.changed
- name: Update virtual network peering
azure_rm_virtualnetworkpeering:
resource_group: "{{ resource_group }}"
name: "{{ peering_name }}"
virtual_network: "{{ vnetname1 }}"
remote_virtual_network:
resource_group: "{{ resource_group_secondary }}"
name: "{{ vnetname2 }}"
allow_virtual_network_access: true
allow_forwarded_traffic: false
register: output
- assert:
that: output.changed
- name: Delete virtual network peering
azure_rm_virtualnetworkpeering:
resource_group: "{{ resource_group }}"
name: "{{ peering_name }}"
virtual_network: "{{ vnetname1 }}"
state: absent
register: output
- name: Delete first virtual network
azure_rm_virtualnetwork:
name: "{{ vnetname1 }}"
resource_group: "{{ resource_group }}"
state: absent
- name: Delete virtual network
azure_rm_virtualnetwork:
name: "{{ vnetname2 }}"
resource_group: "{{ resource_group_secondary }}"
state: absent