mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
more integration test improvements (#41184)
This commit is contained in:
parent
5d7afe9d95
commit
e9214725fb
5 changed files with 210 additions and 147 deletions
|
@ -1,58 +1,63 @@
|
||||||
- name: Create storage account name
|
- name: Create storage account name
|
||||||
set_fact:
|
set_fact:
|
||||||
storage_account: "{{ resource_group | hash('md5') | truncate(24, True, '') }}"
|
vm_name: "vm{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}x"
|
||||||
|
storage_name: "st{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
|
storage_container_name: "sc{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
|
public_ip_name: "pip{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
|
security_group_name: "sg{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
|
blob_name: "blob{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
|
|
||||||
- name: Create storage account
|
- name: Create storage account
|
||||||
azure_rm_storageaccount:
|
azure_rm_storageaccount:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ storage_account }}"
|
name: "{{ storage_name }}"
|
||||||
account_type: Standard_LRS
|
account_type: Standard_LRS
|
||||||
|
|
||||||
- name: Create virtual network
|
- name: Create virtual network
|
||||||
azure_rm_virtualnetwork:
|
azure_rm_virtualnetwork:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm001
|
name: "{{ vm_name }}"
|
||||||
address_prefixes: "10.10.0.0/16"
|
address_prefixes: "10.10.0.0/16"
|
||||||
|
|
||||||
- name: Add subnet
|
- name: Add subnet
|
||||||
azure_rm_subnet:
|
azure_rm_subnet:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm001
|
name: "{{ vm_name }}"
|
||||||
address_prefix: "10.10.0.0/24"
|
address_prefix: "10.10.0.0/24"
|
||||||
virtual_network: testvm001
|
virtual_network: "{{ vm_name }}"
|
||||||
|
|
||||||
- name: Create public ip
|
- name: Create public ip
|
||||||
azure_rm_publicipaddress:
|
azure_rm_publicipaddress:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
allocation_method: Static
|
allocation_method: Static
|
||||||
name: testvm001
|
name: "{{ public_ip_name }}"
|
||||||
|
|
||||||
- name: Create security group
|
- name: Create security group
|
||||||
azure_rm_securitygroup:
|
azure_rm_securitygroup:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm001
|
name: "{{ security_group_name }}"
|
||||||
|
|
||||||
- name: Create NIC
|
- name: Create NIC
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm001
|
name: "{{ vm_name }}"
|
||||||
virtual_network: testvm001
|
virtual_network: "{{ vm_name }}"
|
||||||
subnet: testvm001
|
subnet: "{{ vm_name }}"
|
||||||
public_ip_name: testvm001
|
public_ip_name: "{{ public_ip_name }}"
|
||||||
security_group: testvm001
|
security_group: "{{ security_group_name }}"
|
||||||
|
|
||||||
- name: Create virtual machine
|
- name: Create virtual machine
|
||||||
azure_rm_virtualmachine:
|
azure_rm_virtualmachine:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm002
|
name: "{{ vm_name }}"
|
||||||
vm_size: Standard_A0
|
vm_size: Standard_A0
|
||||||
storage_account: "{{ storage_account }}"
|
storage_account: "{{ storage_name }}"
|
||||||
storage_container: testvm001
|
storage_container: "{{ storage_container_name }}"
|
||||||
storage_blob: testvm001.vhd
|
storage_blob: "{{ blob_name }}.vhd"
|
||||||
admin_username: adminuser
|
admin_username: adminuser
|
||||||
admin_password: Password123!
|
admin_password: Password123!
|
||||||
os_type: Linux
|
os_type: Linux
|
||||||
network_interfaces: testvm001
|
network_interfaces: "{{ vm_name }}"
|
||||||
image:
|
image:
|
||||||
offer: UbuntuServer
|
offer: UbuntuServer
|
||||||
publisher: Canonical
|
publisher: Canonical
|
||||||
|
@ -62,7 +67,7 @@
|
||||||
- name: Deallocate the virtual machine
|
- name: Deallocate the virtual machine
|
||||||
azure_rm_virtualmachine:
|
azure_rm_virtualmachine:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm002
|
name: "{{ vm_name }}"
|
||||||
allocated: no
|
allocated: no
|
||||||
vm_size: Standard_A0
|
vm_size: Standard_A0
|
||||||
register: output
|
register: output
|
||||||
|
@ -70,13 +75,13 @@
|
||||||
- name: Start the virtual machine
|
- name: Start the virtual machine
|
||||||
azure_rm_virtualmachine:
|
azure_rm_virtualmachine:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm002
|
name: "{{ vm_name }}"
|
||||||
vm_size: Standard_A0
|
vm_size: Standard_A0
|
||||||
|
|
||||||
- name: Create an image from VM (check mode)
|
- name: Create an image from VM (check mode)
|
||||||
azure_rm_image:
|
azure_rm_image:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
source: "https://{{ storage_account }}.blob.core.windows.net/testvm001/testvm001.vhd"
|
source: "https://{{ storage_name }}.blob.core.windows.net/{{ storage_container_name }}/{{ blob_name }}.vhd"
|
||||||
name: testimage001
|
name: testimage001
|
||||||
os_type: Linux
|
os_type: Linux
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
|
@ -88,7 +93,7 @@
|
||||||
- name: Create an image from VM
|
- name: Create an image from VM
|
||||||
azure_rm_image:
|
azure_rm_image:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
source: "https://{{ storage_account }}.blob.core.windows.net/testvm001/testvm001.vhd"
|
source: "https://{{ storage_name }}.blob.core.windows.net/{{ storage_container_name }}/{{ blob_name }}.vhd"
|
||||||
name: testimage001
|
name: testimage001
|
||||||
os_type: Linux
|
os_type: Linux
|
||||||
register: output
|
register: output
|
||||||
|
@ -101,7 +106,7 @@
|
||||||
- name: Create an image from VM (idempotent)
|
- name: Create an image from VM (idempotent)
|
||||||
azure_rm_image:
|
azure_rm_image:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
source: "https://{{ storage_account }}.blob.core.windows.net/testvm001/testvm001.vhd"
|
source: "https://{{ storage_name }}.blob.core.windows.net/{{ storage_container_name }}/{{ blob_name }}.vhd"
|
||||||
name: testimage001
|
name: testimage001
|
||||||
os_type: Linux
|
os_type: Linux
|
||||||
register: output
|
register: output
|
||||||
|
@ -148,7 +153,14 @@
|
||||||
- name: Delete VM
|
- name: Delete VM
|
||||||
azure_rm_virtualmachine:
|
azure_rm_virtualmachine:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm002
|
name: "{{ vm_name }}"
|
||||||
state: absent
|
state: absent
|
||||||
vm_size: Standard_A0
|
vm_size: Standard_A0
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
|
- name: Delete public ip
|
||||||
|
azure_rm_publicipaddress:
|
||||||
|
resource_group: "{{ resource_group }}"
|
||||||
|
allocation_method: Static
|
||||||
|
name: "{{ public_ip_name }}"
|
||||||
|
state: absent
|
||||||
|
|
|
@ -2,8 +2,11 @@
|
||||||
set_fact:
|
set_fact:
|
||||||
pipaname: "pipa{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
pipaname: "pipa{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
pipbname: "pipb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
pipbname: "pipb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
lbname: "lb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
|
||||||
lbvnname: "lbvn{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
lbvnname: "lbvn{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
|
lbname_a: "lba{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
|
lbname_b: "lbb{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
|
lbname_c: "lbc{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
|
lbname_d: "lbd{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
run_once: yes
|
run_once: yes
|
||||||
|
|
||||||
- name: create public ip
|
- name: create public ip
|
||||||
|
@ -21,13 +24,13 @@
|
||||||
- name: clear load balancer
|
- name: clear load balancer
|
||||||
azure_rm_loadbalancer:
|
azure_rm_loadbalancer:
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
name: "{{ lbname }}"
|
name: "{{ lbname_a }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: create load balancer
|
- name: create load balancer
|
||||||
azure_rm_loadbalancer:
|
azure_rm_loadbalancer:
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
name: "{{ lbname }}"
|
name: "{{ lbname_a }}"
|
||||||
public_ip: "{{ pipaname }}"
|
public_ip: "{{ pipaname }}"
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
|
@ -38,7 +41,7 @@
|
||||||
- name: delete load balancer
|
- name: delete load balancer
|
||||||
azure_rm_loadbalancer:
|
azure_rm_loadbalancer:
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
name: "{{ lbname }}"
|
name: "{{ lbname_a }}"
|
||||||
state: absent
|
state: absent
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
|
@ -49,7 +52,7 @@
|
||||||
- name: delete load balancer (idempotent)
|
- name: delete load balancer (idempotent)
|
||||||
azure_rm_loadbalancer:
|
azure_rm_loadbalancer:
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
name: "{{ lbname }}"
|
name: "{{ lbname_a }}"
|
||||||
state: absent
|
state: absent
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
|
@ -60,7 +63,7 @@
|
||||||
- name: create another load balancer with more options
|
- name: create another load balancer with more options
|
||||||
azure_rm_loadbalancer:
|
azure_rm_loadbalancer:
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
name: "{{ lbname }}"
|
name: "{{ lbname_b }}"
|
||||||
sku: Standard
|
sku: Standard
|
||||||
public_ip_address: "{{ pipbname }}"
|
public_ip_address: "{{ pipbname }}"
|
||||||
probe_protocol: Tcp
|
probe_protocol: Tcp
|
||||||
|
@ -87,13 +90,13 @@
|
||||||
- name: delete load balancer
|
- name: delete load balancer
|
||||||
azure_rm_loadbalancer:
|
azure_rm_loadbalancer:
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
name: "{{ lbname }}"
|
name: "{{ lbname_b }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: create load balancer with multiple parameters
|
- name: create load balancer with multiple parameters
|
||||||
azure_rm_loadbalancer:
|
azure_rm_loadbalancer:
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
name: "{{ lbname }}"
|
name: "{{ lbname_c }}"
|
||||||
frontend_ip_configurations:
|
frontend_ip_configurations:
|
||||||
- name: frontendipconf0
|
- name: frontendipconf0
|
||||||
public_ip_address: "{{ pipaname }}"
|
public_ip_address: "{{ pipaname }}"
|
||||||
|
@ -125,7 +128,7 @@
|
||||||
- name: delete load balancer
|
- name: delete load balancer
|
||||||
azure_rm_loadbalancer:
|
azure_rm_loadbalancer:
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
name: "{{ lbname }}"
|
name: "{{ lbname_c }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Create virtual network
|
- name: Create virtual network
|
||||||
|
@ -145,7 +148,7 @@
|
||||||
- name: create internal loadbalancer
|
- name: create internal loadbalancer
|
||||||
azure_rm_loadbalancer:
|
azure_rm_loadbalancer:
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
name: "{{ lbname }}"
|
name: "{{ lbname_d }}"
|
||||||
frontend_ip_configurations:
|
frontend_ip_configurations:
|
||||||
- name: frontendipconf0
|
- name: frontendipconf0
|
||||||
private_ip_address: 10.10.0.10
|
private_ip_address: 10.10.0.10
|
||||||
|
@ -179,7 +182,7 @@
|
||||||
- name: delete load balancer
|
- name: delete load balancer
|
||||||
azure_rm_loadbalancer:
|
azure_rm_loadbalancer:
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
name: "{{ lbname }}"
|
name: "{{ lbname_d }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: cleanup public ip
|
- name: cleanup public ip
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
- name: Setup variables...
|
- name: Prepare random number
|
||||||
set_fact:
|
set_fact:
|
||||||
managed_disk1: "{{ resource_group | hash('md5') | truncate(24, True, '') }}"
|
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
managed_disk2: "{{ resource_group | hash('md5') | truncate(18, True, '') }}"
|
run_once: yes
|
||||||
|
|
||||||
- name: Clearing (if) previous disks were created
|
- name: Clearing (if) previous disks were created
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
|
@ -9,13 +9,13 @@
|
||||||
name: "{{item }}"
|
name: "{{item }}"
|
||||||
state: absent
|
state: absent
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ managed_disk2 }}"
|
- "md{{ rpfx }}2"
|
||||||
- "{{ managed_disk1 }}"
|
- "md{{ rpfx }}1"
|
||||||
|
|
||||||
- name: Create managed disk (Check Mode)
|
- name: Create managed disk (Check Mode)
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 1
|
disk_size_gb: 1
|
||||||
tags:
|
tags:
|
||||||
testing: testing
|
testing: testing
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
- name: Create new managed disk succesfully
|
- name: Create new managed disk succesfully
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
storage_account_type: "Standard_LRS"
|
storage_account_type: "Standard_LRS"
|
||||||
disk_size_gb: 1
|
disk_size_gb: 1
|
||||||
tags:
|
tags:
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
- name: Copy disk to a new managed disk
|
- name: Copy disk to a new managed disk
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk2 }}"
|
name: "md{{ rpfx }}2"
|
||||||
create_option: "copy"
|
create_option: "copy"
|
||||||
source_resource_uri: "{{ output.state.id }}"
|
source_resource_uri: "{{ output.state.id }}"
|
||||||
disk_size_gb: 1
|
disk_size_gb: 1
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
- name: Update a new disk without changes
|
- name: Update a new disk without changes
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
storage_account_type: "Standard_LRS"
|
storage_account_type: "Standard_LRS"
|
||||||
disk_size_gb: 1
|
disk_size_gb: 1
|
||||||
register: output
|
register: output
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
- name: Change storage account type to an invalid type
|
- name: Change storage account type to an invalid type
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
storage_account_type: "PremiumL"
|
storage_account_type: "PremiumL"
|
||||||
disk_size_gb: 1
|
disk_size_gb: 1
|
||||||
register: output
|
register: output
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
- name: Change disk size to incompatible size
|
- name: Change disk size to incompatible size
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 30000
|
disk_size_gb: 30000
|
||||||
register: output
|
register: output
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
@ -114,7 +114,7 @@
|
||||||
- name: Change disk to bigger size
|
- name: Change disk to bigger size
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 2
|
disk_size_gb: 2
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
- name: Change disk to Premium
|
- name: Change disk to Premium
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
storage_account_type: "Premium_LRS"
|
storage_account_type: "Premium_LRS"
|
||||||
disk_size_gb: 2
|
disk_size_gb: 2
|
||||||
register: output
|
register: output
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
- name: Update disk tags
|
- name: Update disk tags
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 2
|
disk_size_gb: 2
|
||||||
tags:
|
tags:
|
||||||
testing: testing
|
testing: testing
|
||||||
|
@ -156,7 +156,7 @@
|
||||||
- name: Update disk tags
|
- name: Update disk tags
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 2
|
disk_size_gb: 2
|
||||||
tags:
|
tags:
|
||||||
testing: testing
|
testing: testing
|
||||||
|
@ -173,7 +173,7 @@
|
||||||
- name: Gather facts to one specific disk
|
- name: Gather facts to one specific disk
|
||||||
azure_rm_managed_disk_facts:
|
azure_rm_managed_disk_facts:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
@ -190,46 +190,46 @@
|
||||||
- name: Create virtual network
|
- name: Create virtual network
|
||||||
azure_rm_virtualnetwork:
|
azure_rm_virtualnetwork:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm001
|
name: "tr{{ rpfx }}"
|
||||||
address_prefixes: "10.10.0.0/16"
|
address_prefixes: "10.10.0.0/16"
|
||||||
|
|
||||||
- name: Add subnet
|
- name: Add subnet
|
||||||
azure_rm_subnet:
|
azure_rm_subnet:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm001
|
name: "tr{{ rpfx }}"
|
||||||
address_prefix: "10.10.0.0/24"
|
address_prefix: "10.10.0.0/24"
|
||||||
virtual_network: testvm001
|
virtual_network: "tr{{ rpfx }}"
|
||||||
|
|
||||||
- name: Create public ip
|
- name: Create public ip
|
||||||
azure_rm_publicipaddress:
|
azure_rm_publicipaddress:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
allocation_method: Static
|
allocation_method: Static
|
||||||
name: testvm001
|
name: "tr{{ rpfx }}"
|
||||||
|
|
||||||
- name: Create security group
|
- name: Create security group
|
||||||
azure_rm_securitygroup:
|
azure_rm_securitygroup:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm001
|
name: "tr{{ rpfx }}"
|
||||||
|
|
||||||
- name: Create NIC
|
- name: Create NIC
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm001
|
name: "tr{{ rpfx }}"
|
||||||
virtual_network: testvm001
|
virtual_network: "tr{{ rpfx }}"
|
||||||
subnet: testvm001
|
subnet: "tr{{ rpfx }}"
|
||||||
public_ip_name: testvm001
|
public_ip_name: "tr{{ rpfx }}"
|
||||||
security_group: testvm001
|
security_group: "tr{{ rpfx }}"
|
||||||
|
|
||||||
- name: Create virtual machine
|
- name: Create virtual machine
|
||||||
azure_rm_virtualmachine:
|
azure_rm_virtualmachine:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm001
|
name: "tr{{ rpfx }}"
|
||||||
admin_username: adminuser
|
admin_username: adminuser
|
||||||
admin_password: Password123!
|
admin_password: Password123!
|
||||||
os_type: Linux
|
os_type: Linux
|
||||||
managed_disk_type: Premium_LRS
|
managed_disk_type: Premium_LRS
|
||||||
vm_size: Standard_DS1_v2
|
vm_size: Standard_DS1_v2
|
||||||
network_interfaces: testvm001
|
network_interfaces: "tr{{ rpfx }}"
|
||||||
image:
|
image:
|
||||||
offer: UbuntuServer
|
offer: UbuntuServer
|
||||||
publisher: Canonical
|
publisher: Canonical
|
||||||
|
@ -239,9 +239,9 @@
|
||||||
- name: Mount the disk to virtual machine (check mode)
|
- name: Mount the disk to virtual machine (check mode)
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 2
|
disk_size_gb: 2
|
||||||
managed_by: testvm001
|
managed_by: "tr{{ rpfx }}"
|
||||||
tags:
|
tags:
|
||||||
testing: testing
|
testing: testing
|
||||||
delete: never
|
delete: never
|
||||||
|
@ -255,9 +255,9 @@
|
||||||
- name: Mount the disk to virtual machine
|
- name: Mount the disk to virtual machine
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 2
|
disk_size_gb: 2
|
||||||
managed_by: testvm001
|
managed_by: "tr{{ rpfx }}"
|
||||||
tags:
|
tags:
|
||||||
testing: testing
|
testing: testing
|
||||||
delete: never
|
delete: never
|
||||||
|
@ -265,14 +265,14 @@
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "'testvm001' in mounted.state.managed_by"
|
- "'tr{{ rpfx }}' in mounted.state.managed_by"
|
||||||
|
|
||||||
- name: Mount the disk to virtual machine (idempotent)
|
- name: Mount the disk to virtual machine (idempotent)
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 2
|
disk_size_gb: 2
|
||||||
managed_by: testvm001
|
managed_by: "tr{{ rpfx }}"
|
||||||
tags:
|
tags:
|
||||||
testing: testing
|
testing: testing
|
||||||
delete: never
|
delete: never
|
||||||
|
@ -281,12 +281,12 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- not mounted.changed
|
- not mounted.changed
|
||||||
- "'testvm001' in mounted.state.managed_by"
|
- "'tr{{ rpfx }}' in mounted.state.managed_by"
|
||||||
|
|
||||||
- name: Unmount the disk to virtual machine (check mode)
|
- name: Unmount the disk to virtual machine (check mode)
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 2
|
disk_size_gb: 2
|
||||||
tags:
|
tags:
|
||||||
testing: testing
|
testing: testing
|
||||||
|
@ -301,7 +301,7 @@
|
||||||
- name: Unmount the disk to virtual machine
|
- name: Unmount the disk to virtual machine
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 2
|
disk_size_gb: 2
|
||||||
tags:
|
tags:
|
||||||
testing: testing
|
testing: testing
|
||||||
|
@ -316,7 +316,7 @@
|
||||||
- name: Unmount the disk to virtual machine (idempotent)
|
- name: Unmount the disk to virtual machine (idempotent)
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 2
|
disk_size_gb: 2
|
||||||
tags:
|
tags:
|
||||||
testing: testing
|
testing: testing
|
||||||
|
@ -331,7 +331,7 @@
|
||||||
- name: Update disk size
|
- name: Update disk size
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 4
|
disk_size_gb: 4
|
||||||
tags:
|
tags:
|
||||||
testing: testing
|
testing: testing
|
||||||
|
@ -345,9 +345,9 @@
|
||||||
- name: Attach the disk to virtual machine again
|
- name: Attach the disk to virtual machine again
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 4
|
disk_size_gb: 4
|
||||||
managed_by: testvm001
|
managed_by: "tr{{ rpfx }}"
|
||||||
tags:
|
tags:
|
||||||
testing: testing
|
testing: testing
|
||||||
delete: never
|
delete: never
|
||||||
|
@ -356,14 +356,14 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- mounted.changed
|
- mounted.changed
|
||||||
- "'testvm001' in mounted.state.managed_by"
|
- "'tr{{ rpfx }}' in mounted.state.managed_by"
|
||||||
|
|
||||||
- name: Change disk size to incompatible size
|
- name: Change disk size to incompatible size
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
state: absent
|
state: absent
|
||||||
managed_by: testvm001
|
managed_by: "tr{{ rpfx }}"
|
||||||
register: output
|
register: output
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@
|
||||||
- name: Delete managed disk (Check Mode)
|
- name: Delete managed disk (Check Mode)
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
state: absent
|
state: absent
|
||||||
register: output
|
register: output
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
|
@ -387,14 +387,14 @@
|
||||||
- name: Delete managed disk
|
- name: Delete managed disk
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk2 }}"
|
name: "md{{ rpfx }}2"
|
||||||
state: absent
|
state: absent
|
||||||
check_mode: no
|
check_mode: no
|
||||||
|
|
||||||
- name: Delete copied managed disk
|
- name: Delete copied managed disk
|
||||||
azure_rm_managed_disk:
|
azure_rm_managed_disk:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: "{{ managed_disk1 }}"
|
name: "md{{ rpfx }}1"
|
||||||
disk_size_gb: 2
|
disk_size_gb: 2
|
||||||
state: absent
|
state: absent
|
||||||
check_mode: no
|
check_mode: no
|
||||||
|
@ -402,6 +402,13 @@
|
||||||
- name: Delete virtual machine
|
- name: Delete virtual machine
|
||||||
azure_rm_virtualmachine:
|
azure_rm_virtualmachine:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testvm001
|
name: "tr{{ rpfx }}"
|
||||||
state: absent
|
state: absent
|
||||||
vm_size: Standard_DS1_v2
|
vm_size: Standard_DS1_v2
|
||||||
|
|
||||||
|
- name: Delete public ip
|
||||||
|
azure_rm_publicipaddress:
|
||||||
|
resource_group: "{{ resource_group }}"
|
||||||
|
allocation_method: Static
|
||||||
|
name: "tr{{ rpfx }}"
|
||||||
|
state: absent
|
||||||
|
|
|
@ -1,29 +1,34 @@
|
||||||
|
- name: Prepare random number
|
||||||
|
set_fact:
|
||||||
|
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
|
run_once: yes
|
||||||
|
|
||||||
- name: Create virtual network
|
- name: Create virtual network
|
||||||
azure_rm_virtualnetwork:
|
azure_rm_virtualnetwork:
|
||||||
resource_group: "{{ resource_group_secondary }}"
|
resource_group: "{{ resource_group_secondary }}"
|
||||||
name: testnic001
|
name: "tn{{ rpfx }}"
|
||||||
address_prefixes: "10.10.0.0/16"
|
address_prefixes: "10.10.0.0/16"
|
||||||
register: vn
|
register: vn
|
||||||
|
|
||||||
- name: Add subnet
|
- name: Add subnet
|
||||||
azure_rm_subnet:
|
azure_rm_subnet:
|
||||||
resource_group: "{{ resource_group_secondary }}"
|
resource_group: "{{ resource_group_secondary }}"
|
||||||
name: testnic001
|
name: "tn{{ rpfx }}"
|
||||||
address_prefix: "10.10.0.0/24"
|
address_prefix: "10.10.0.0/24"
|
||||||
virtual_network: testnic001
|
virtual_network: "tn{{ rpfx }}"
|
||||||
|
|
||||||
- name: create public ip
|
- name: create public ip
|
||||||
azure_rm_publicipaddress:
|
azure_rm_publicipaddress:
|
||||||
name: ansiblepip3
|
name: "pip{{ rpfx }}"
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
|
|
||||||
- name: create load balancer with multiple parameters
|
- name: create load balancer with multiple parameters
|
||||||
azure_rm_loadbalancer:
|
azure_rm_loadbalancer:
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
name: lbtestfromansible
|
name: "lb{{ rpfx }}"
|
||||||
frontend_ip_configurations:
|
frontend_ip_configurations:
|
||||||
- name: frontendipconf0
|
- name: frontendipconf0
|
||||||
public_ip_address: ansiblepip3
|
public_ip_address: "pip{{ rpfx }}"
|
||||||
backend_address_pools:
|
backend_address_pools:
|
||||||
- name: backendaddrpool0
|
- name: backendaddrpool0
|
||||||
- name: backendaddrpool1
|
- name: backendaddrpool1
|
||||||
|
@ -48,18 +53,18 @@
|
||||||
|
|
||||||
- name: create public ip
|
- name: create public ip
|
||||||
azure_rm_publicipaddress:
|
azure_rm_publicipaddress:
|
||||||
name: ansiblepip3
|
name: "pip{{ rpfx }}"
|
||||||
resource_group: '{{ resource_group }}'
|
resource_group: '{{ resource_group }}'
|
||||||
|
|
||||||
- name: Create NIC (check mode)
|
- name: Create NIC (check mode)
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testnic001
|
name: "tn{{ rpfx }}"
|
||||||
virtual_network: "{{ vn.state.id }}"
|
virtual_network: "{{ vn.state.id }}"
|
||||||
subnet: testnic001
|
subnet: "tn{{ rpfx }}"
|
||||||
public_ip_name: testnic001
|
public_ip_name: "tn{{ rpfx }}"
|
||||||
public_ip_allocation_method: Static
|
public_ip_allocation_method: Static
|
||||||
security_group: testnic001
|
security_group: "tn{{ rpfx }}"
|
||||||
register: output
|
register: output
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
|
|
||||||
|
@ -70,27 +75,27 @@
|
||||||
- name: Create NIC using virtual_network resource_group parameter
|
- name: Create NIC using virtual_network resource_group parameter
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testnic001rg
|
name: "tn{{ rpfx }}rg"
|
||||||
virtual_network:
|
virtual_network:
|
||||||
name: testnic001
|
name: "tn{{ rpfx }}"
|
||||||
resource_group: "{{ resource_group_secondary }}"
|
resource_group: "{{ resource_group_secondary }}"
|
||||||
subnet: testnic001
|
subnet: "tn{{ rpfx }}"
|
||||||
public_ip_name: testnic001rg
|
public_ip_name: "tn{{ rpfx }}rg"
|
||||||
public_ip_allocation_method: Static
|
public_ip_allocation_method: Static
|
||||||
security_group: testnic001
|
security_group: "tn{{ rpfx }}"
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: Create NIC using virtual_network resource_group parameter (idempotent)
|
- name: Create NIC using virtual_network resource_group parameter (idempotent)
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testnic001rg
|
name: "tn{{ rpfx }}rg"
|
||||||
virtual_network:
|
virtual_network:
|
||||||
name: testnic001
|
name: "tn{{ rpfx }}"
|
||||||
resource_group: "{{ resource_group_secondary }}"
|
resource_group: "{{ resource_group_secondary }}"
|
||||||
subnet: testnic001
|
subnet: "tn{{ rpfx }}"
|
||||||
public_ip_name: testnic001rg
|
public_ip_name: "tn{{ rpfx }}rg"
|
||||||
public_ip_allocation_method: Static
|
public_ip_allocation_method: Static
|
||||||
security_group: testnic001
|
security_group: "tn{{ rpfx }}"
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -100,41 +105,41 @@
|
||||||
- name: Delete NIC
|
- name: Delete NIC
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testnic001rg
|
name: "tn{{ rpfx }}rg"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Create NIC
|
- name: Create NIC
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testnic001
|
name: "tn{{ rpfx }}"
|
||||||
virtual_network: "{{ vn.state.id }}"
|
virtual_network: "{{ vn.state.id }}"
|
||||||
subnet: testnic001
|
subnet: "tn{{ rpfx }}"
|
||||||
public_ip_name: testnic001
|
public_ip_name: "tn{{ rpfx }}"
|
||||||
public_ip_allocation_method: Static
|
public_ip_allocation_method: Static
|
||||||
security_group:
|
security_group:
|
||||||
name: testnic002
|
name: "tn{{ rpfx }}2"
|
||||||
resource_group: "{{ resource_group_secondary }}"
|
resource_group: "{{ resource_group_secondary }}"
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- output.changed
|
- output.changed
|
||||||
- output.state.ip_configuration.subnet.name == 'testnic001'
|
- output.state.ip_configuration.subnet.name == 'tn{{ rpfx }}'
|
||||||
|
|
||||||
- name: Update the NIC with mutilple ip configurations (check mode)
|
- name: Update the NIC with mutilple ip configurations (check mode)
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testnic001
|
name: "tn{{ rpfx }}"
|
||||||
security_group:
|
security_group:
|
||||||
name: testnic002
|
name: "tn{{ rpfx }}2"
|
||||||
resource_group: "{{ resource_group_secondary }}"
|
resource_group: "{{ resource_group_secondary }}"
|
||||||
virtual_network: "{{ vn.state.id }}"
|
virtual_network: "{{ vn.state.id }}"
|
||||||
subnet: testnic001
|
subnet: "tn{{ rpfx }}"
|
||||||
ip_configurations:
|
ip_configurations:
|
||||||
- name: ipconfig-add
|
- name: ipconfig-add
|
||||||
public_ip_name: testnic002
|
public_ip_name: "tn{{ rpfx }}2"
|
||||||
- name: default
|
- name: default
|
||||||
public_ip_name: testnic001
|
public_ip_name: "tn{{ rpfx }}"
|
||||||
primary: True
|
primary: True
|
||||||
public_ip_allocation_method: Static
|
public_ip_allocation_method: Static
|
||||||
- name: ipconfig1
|
- name: ipconfig1
|
||||||
|
@ -149,17 +154,17 @@
|
||||||
- name: Update the NIC with mutilple ip configurations
|
- name: Update the NIC with mutilple ip configurations
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testnic001
|
name: "tn{{ rpfx }}"
|
||||||
security_group:
|
security_group:
|
||||||
name: testnic002
|
name: "tn{{ rpfx }}2"
|
||||||
resource_group: "{{ resource_group_secondary }}"
|
resource_group: "{{ resource_group_secondary }}"
|
||||||
virtual_network: "{{ vn.state.id }}"
|
virtual_network: "{{ vn.state.id }}"
|
||||||
subnet: testnic001
|
subnet: "tn{{ rpfx }}"
|
||||||
ip_configurations:
|
ip_configurations:
|
||||||
- name: ipconfig-add
|
- name: ipconfig-add
|
||||||
public_ip_name: testnic002
|
public_ip_name: "tn{{ rpfx }}2"
|
||||||
- name: default
|
- name: default
|
||||||
public_ip_name: testnic001
|
public_ip_name: "tn{{ rpfx }}"
|
||||||
primary: True
|
primary: True
|
||||||
public_ip_allocation_method: Static
|
public_ip_allocation_method: Static
|
||||||
- name: ipconfig1
|
- name: ipconfig1
|
||||||
|
@ -167,7 +172,7 @@
|
||||||
load_balancer_backend_address_pools:
|
load_balancer_backend_address_pools:
|
||||||
- "{{ lb.state.backend_address_pools[0].id }}"
|
- "{{ lb.state.backend_address_pools[0].id }}"
|
||||||
- name: backendaddrpool1
|
- name: backendaddrpool1
|
||||||
load_balancer: lbtestfromansible
|
load_balancer: "lb{{ rpfx }}"
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -175,20 +180,20 @@
|
||||||
- output.changed
|
- output.changed
|
||||||
- not output.state.ip_configuration
|
- not output.state.ip_configuration
|
||||||
- output.state.ip_configurations | length == 3
|
- output.state.ip_configurations | length == 3
|
||||||
- output.state.network_security_group.name == 'testnic002'
|
- output.state.network_security_group.name == 'tn{{ rpfx }}2'
|
||||||
|
|
||||||
- name: Update the NIC with mutilple ip configurations (idempotent)
|
- name: Update the NIC with mutilple ip configurations (idempotent)
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testnic001
|
name: "tn{{ rpfx }}"
|
||||||
security_group: "{{ output.state.network_security_group.id }}"
|
security_group: "{{ output.state.network_security_group.id }}"
|
||||||
virtual_network: "{{ vn.state.id }}"
|
virtual_network: "{{ vn.state.id }}"
|
||||||
subnet: testnic001
|
subnet: "tn{{ rpfx }}"
|
||||||
ip_configurations:
|
ip_configurations:
|
||||||
- name: ipconfig-add
|
- name: ipconfig-add
|
||||||
public_ip_name: testnic002
|
public_ip_name: "tn{{ rpfx }}2"
|
||||||
- name: default
|
- name: default
|
||||||
public_ip_name: testnic001
|
public_ip_name: "tn{{ rpfx }}"
|
||||||
primary: True
|
primary: True
|
||||||
public_ip_allocation_method: Static
|
public_ip_allocation_method: Static
|
||||||
- name: ipconfig1
|
- name: ipconfig1
|
||||||
|
@ -196,7 +201,7 @@
|
||||||
load_balancer_backend_address_pools:
|
load_balancer_backend_address_pools:
|
||||||
- "{{ lb.state.backend_address_pools[0].id }}"
|
- "{{ lb.state.backend_address_pools[0].id }}"
|
||||||
- name: backendaddrpool1
|
- name: backendaddrpool1
|
||||||
load_balancer: lbtestfromansible
|
load_balancer: "lb{{ rpfx }}"
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -206,21 +211,21 @@
|
||||||
- name: Remove one ip configuration
|
- name: Remove one ip configuration
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testnic001
|
name: "tn{{ rpfx }}"
|
||||||
security_group:
|
security_group:
|
||||||
name: testnic002
|
name: "tn{{ rpfx }}2"
|
||||||
resource_group: "{{ resource_group_secondary }}"
|
resource_group: "{{ resource_group_secondary }}"
|
||||||
virtual_network: "{{ vn.state.id }}"
|
virtual_network: "{{ vn.state.id }}"
|
||||||
subnet: testnic001
|
subnet: "tn{{ rpfx }}"
|
||||||
ip_configurations:
|
ip_configurations:
|
||||||
- name: ipconfig1
|
- name: ipconfig1
|
||||||
public_ip_name: testnic003
|
public_ip_name: testnic003
|
||||||
load_balancer_backend_address_pools:
|
load_balancer_backend_address_pools:
|
||||||
- "{{ lb.state.backend_address_pools[0].id }}"
|
- "{{ lb.state.backend_address_pools[0].id }}"
|
||||||
- name: backendaddrpool1
|
- name: backendaddrpool1
|
||||||
load_balancer: lbtestfromansible
|
load_balancer: "lb{{ rpfx }}"
|
||||||
- name: default
|
- name: default
|
||||||
public_ip_name: testnic001
|
public_ip_name: "tn{{ rpfx }}"
|
||||||
public_ip_allocation_method: Static
|
public_ip_allocation_method: Static
|
||||||
primary: True
|
primary: True
|
||||||
register: output
|
register: output
|
||||||
|
@ -233,10 +238,10 @@
|
||||||
- name: IP configuration without public IP and NSG
|
- name: IP configuration without public IP and NSG
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testnic001noip
|
name: "tn{{ rpfx }}noip"
|
||||||
create_with_security_group: False
|
create_with_security_group: False
|
||||||
virtual_network: "{{ vn.state.id }}"
|
virtual_network: "{{ vn.state.id }}"
|
||||||
subnet: testnic001
|
subnet: "tn{{ rpfx }}"
|
||||||
ip_configurations:
|
ip_configurations:
|
||||||
- name: ipconfig1
|
- name: ipconfig1
|
||||||
primary: True
|
primary: True
|
||||||
|
@ -250,7 +255,7 @@
|
||||||
- name: Delete the NIC (check mode)
|
- name: Delete the NIC (check mode)
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testnic001
|
name: "tn{{ rpfx }}"
|
||||||
state: absent
|
state: absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: output
|
register: output
|
||||||
|
@ -265,8 +270,8 @@
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: absent
|
state: absent
|
||||||
with_items:
|
with_items:
|
||||||
- testnic001
|
- "tn{{ rpfx }}"
|
||||||
- testnic001noip
|
- "tn{{ rpfx }}noip"
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -276,10 +281,45 @@
|
||||||
- name: Delete the NIC (idempotent)
|
- name: Delete the NIC (idempotent)
|
||||||
azure_rm_networkinterface:
|
azure_rm_networkinterface:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testnic001
|
name: "tn{{ rpfx }}"
|
||||||
state: absent
|
state: absent
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- not output.changed
|
- not output.changed
|
||||||
|
|
||||||
|
- name: delete load balancer
|
||||||
|
azure_rm_loadbalancer:
|
||||||
|
resource_group: '{{ resource_group }}'
|
||||||
|
name: "lb{{ rpfx }}"
|
||||||
|
frontend_ip_configurations:
|
||||||
|
- name: frontendipconf0
|
||||||
|
public_ip_address: "pip{{ rpfx }}"
|
||||||
|
backend_address_pools:
|
||||||
|
- name: backendaddrpool0
|
||||||
|
- name: backendaddrpool1
|
||||||
|
probes:
|
||||||
|
- name: prob0
|
||||||
|
port: 80
|
||||||
|
inbound_nat_pools:
|
||||||
|
- name: inboundnatpool0
|
||||||
|
frontend_ip_configuration_name: frontendipconf0
|
||||||
|
protocol: Tcp
|
||||||
|
frontend_port_range_start: 80
|
||||||
|
frontend_port_range_end: 81
|
||||||
|
backend_port: 8080
|
||||||
|
load_balancing_rules:
|
||||||
|
- name: lbrbalancingrule0
|
||||||
|
frontend_ip_configuration: frontendipconf0
|
||||||
|
backend_address_pool: backendaddrpool0
|
||||||
|
frontend_port: 80
|
||||||
|
backend_port: 80
|
||||||
|
probe: prob0
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: delete public ip
|
||||||
|
azure_rm_publicipaddress:
|
||||||
|
name: "pip{{ rpfx }}"
|
||||||
|
resource_group: '{{ resource_group }}'
|
||||||
|
state: absent
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
- name: Create domain name
|
- name: Create domain name
|
||||||
set_fact:
|
set_fact:
|
||||||
domain_name: "ansible-{{ resource_group | hash('md5') | truncate(24, True, '') }}"
|
domain_name: "ansible-{{ resource_group | hash('md5') | truncate(24, True, '') }}"
|
||||||
|
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"
|
||||||
|
|
||||||
- name: Remove public ip
|
- name: Remove public ip
|
||||||
azure_rm_publicipaddress:
|
azure_rm_publicipaddress:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testing01
|
name: "pip{{ rpfx }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Create public ip
|
- name: Create public ip
|
||||||
azure_rm_publicipaddress:
|
azure_rm_publicipaddress:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testing01
|
name: "pip{{ rpfx }}"
|
||||||
allocation_method: Static
|
allocation_method: Static
|
||||||
domain_name: "{{ domain_name }}"
|
domain_name: "{{ domain_name }}"
|
||||||
tags:
|
tags:
|
||||||
|
@ -29,7 +30,7 @@
|
||||||
- name: Should be idempotent
|
- name: Should be idempotent
|
||||||
azure_rm_publicipaddress:
|
azure_rm_publicipaddress:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testing01
|
name: "pip{{ rpfx }}"
|
||||||
allocation_method: Static
|
allocation_method: Static
|
||||||
domain_name: "{{ domain_name }}"
|
domain_name: "{{ domain_name }}"
|
||||||
tags:
|
tags:
|
||||||
|
@ -43,7 +44,7 @@
|
||||||
- name: Update tags
|
- name: Update tags
|
||||||
azure_rm_publicipaddress:
|
azure_rm_publicipaddress:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testing01
|
name: "pip{{ rpfx }}"
|
||||||
tags:
|
tags:
|
||||||
testing: testing
|
testing: testing
|
||||||
delete: never
|
delete: never
|
||||||
|
@ -68,7 +69,7 @@
|
||||||
- name: Purge all tags
|
- name: Purge all tags
|
||||||
azure_rm_publicipaddress:
|
azure_rm_publicipaddress:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testing01
|
name: "pip{{ rpfx }}"
|
||||||
tags: {}
|
tags: {}
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@
|
||||||
- name: Gather facts for a public ip
|
- name: Gather facts for a public ip
|
||||||
azure_rm_publicipaddress_facts:
|
azure_rm_publicipaddress_facts:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testing01
|
name: "pip{{ rpfx }}"
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that: azure_publicipaddresses | length == 1
|
that: azure_publicipaddresses | length == 1
|
||||||
|
@ -94,13 +95,13 @@
|
||||||
- name: Remove public ip
|
- name: Remove public ip
|
||||||
azure_rm_publicipaddress:
|
azure_rm_publicipaddress:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testing01
|
name: "pip{{ rpfx }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Gather facts for a public ip
|
- name: Gather facts for a public ip
|
||||||
azure_rm_publicipaddress_facts:
|
azure_rm_publicipaddress_facts:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
name: testing01
|
name: "pip{{ rpfx }}"
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that: azure_publicipaddresses | length == 0
|
that: azure_publicipaddresses | length == 0
|
||||||
|
|
Loading…
Reference in a new issue