140 lines
3.1 KiB
YAML
140 lines
3.1 KiB
YAML
|
- name: Create resource group
|
||
|
azure_rm_resourcegroup:
|
||
|
name: "{{ resource_group }}"
|
||
|
location: "{{ location }}"
|
||
|
|
||
|
- name: Remove public ip
|
||
|
azure_rm_publicipaddress:
|
||
|
resource_group: "{{ resource_group }}"
|
||
|
name: testing01
|
||
|
state: absent
|
||
|
register: output
|
||
|
|
||
|
- debug: var=output
|
||
|
when: playbook_debug
|
||
|
|
||
|
- name: Create public ip
|
||
|
azure_rm_publicipaddress:
|
||
|
resource_group: "{{ resource_group }}"
|
||
|
name: testing01
|
||
|
allocation_method: Static
|
||
|
domain_name: autotest01
|
||
|
tags:
|
||
|
testing: testing
|
||
|
delete: on-exit
|
||
|
register: output
|
||
|
|
||
|
- debug: var=output
|
||
|
when: playbook_debug
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- output.state.public_ip_allocation_method == 'Static'
|
||
|
- output.state.dns_settings.domain_name_label == 'autotest01'
|
||
|
- output.state.tags | length == 2
|
||
|
- output.state.tags.testing == 'testing'
|
||
|
|
||
|
- name: Should be idempotent
|
||
|
azure_rm_publicipaddress:
|
||
|
resource_group: "{{ resource_group }}"
|
||
|
name: testing01
|
||
|
allocation_method: Static
|
||
|
domain_name: autotest01
|
||
|
tags:
|
||
|
testing: testing
|
||
|
delete: on-exit
|
||
|
register: output
|
||
|
|
||
|
- debug: var=output
|
||
|
when: playbook_debug
|
||
|
|
||
|
- assert:
|
||
|
that: not output.changed
|
||
|
|
||
|
- name: Update tags
|
||
|
azure_rm_publicipaddress:
|
||
|
resource_group: "{{ resource_group }}"
|
||
|
name: testing01
|
||
|
tags:
|
||
|
testing: testing
|
||
|
delete: never
|
||
|
foo: bar
|
||
|
register: output
|
||
|
|
||
|
- debug: var=output
|
||
|
when: playbook_debug
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- output.state.tags | length == 3
|
||
|
- output.state.tags.delete == 'never'
|
||
|
|
||
|
- name: Gather facts, filtering by tag
|
||
|
azure_rm_publicipaddress_facts:
|
||
|
resource_group: "{{ resource_group }}"
|
||
|
tags:
|
||
|
- testing
|
||
|
- foo:bar
|
||
|
register: output
|
||
|
|
||
|
- debug: var=output
|
||
|
when: playbook_debug
|
||
|
|
||
|
- assert:
|
||
|
that: azure_publicipaddresses | length == 1
|
||
|
|
||
|
- name: Purge all tags
|
||
|
azure_rm_publicipaddress:
|
||
|
resource_group: "{{ resource_group }}"
|
||
|
name: testing01
|
||
|
tags: {}
|
||
|
register: output
|
||
|
|
||
|
- debug: var=output
|
||
|
when: playbook_debug
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- output.state.tags | length == 0
|
||
|
|
||
|
- name: Gather facts for a public ip
|
||
|
azure_rm_publicipaddress_facts:
|
||
|
resource_group: "{{ resource_group }}"
|
||
|
name: testing01
|
||
|
register: output
|
||
|
|
||
|
- debug: var=output
|
||
|
when: playbook_debug
|
||
|
|
||
|
- assert:
|
||
|
that: azure_publicipaddresses | length == 1
|
||
|
|
||
|
- name: Gather facts for all public ips
|
||
|
azure_rm_publicipaddress_facts:
|
||
|
resource_group: "{{ resource_group }}"
|
||
|
register: output
|
||
|
|
||
|
- debug: var=output
|
||
|
when: playbook_debug
|
||
|
|
||
|
- assert:
|
||
|
that: azure_publicipaddresses | length > 0
|
||
|
|
||
|
- name: Remove all public ips
|
||
|
azure_rm_publicipaddress:
|
||
|
resource_group: "{{ resource_group }}"
|
||
|
name: "{{ item.name }}"
|
||
|
state: absent
|
||
|
with_items: "{{ azure_publicipaddresses }}"
|
||
|
|
||
|
- name: Gather facts for all public ips
|
||
|
azure_rm_publicipaddress_facts:
|
||
|
resource_group: "{{ resource_group }}"
|
||
|
register: output
|
||
|
|
||
|
- debug: var=output
|
||
|
when: playbook_debug
|
||
|
|
||
|
- assert:
|
||
|
that: azure_publicipaddresses | length == 0
|