|
10 | 10 | virtual_network_name: molecule_vnet |
11 | 11 | subnet_name: molecule_subnet |
12 | 12 | tasks: |
13 | | - - name: Destroy molecule instance(s) |
14 | | - azure_rm_virtualmachine: |
15 | | - resource_group: "{{ resource_group_name }}" |
16 | | - name: "{{ item.name }}" |
17 | | - state: absent |
18 | | - remove_on_absent: |
19 | | - - all_autocreated |
20 | | - register: server |
21 | | - with_items: "{{ molecule_yml.platforms }}" |
22 | | - async: 7200 |
23 | | - poll: 0 |
24 | | - |
25 | | - - name: Wait for instance(s) deletion to complete |
26 | | - async_status: |
27 | | - jid: "{{ item.ansible_job_id }}" |
28 | | - register: azure_jobs |
29 | | - until: azure_jobs.finished |
30 | | - retries: 300 |
31 | | - with_items: "{{ server.results }}" |
32 | | - # avoid failure when resource_group is already missing, as we remove it later anyway |
33 | | - failed_when: false |
34 | | - |
35 | | - - name: Destroy subnet |
36 | | - azure_rm_subnet: |
37 | | - resource_group: "{{ resource_group_name }}" |
38 | | - name: "{{ subnet_name }}" |
39 | | - virtual_network_name: "{{ virtual_network_name }}" |
40 | | - state: absent |
41 | | - # avoid failure when resource_group is already missing, as we remove it later anyway |
42 | | - failed_when: false |
43 | | - |
44 | | - - name: Destroy virtual network |
45 | | - azure_rm_virtualnetwork: |
46 | | - resource_group: "{{ resource_group_name }}" |
47 | | - name: "{{ virtual_network_name }}" |
48 | | - state: absent |
49 | | - # avoid failure when resource_group is already missing, as we remove it later anyway |
50 | | - failed_when: false |
51 | | - |
52 | | - - name: Destroy resource group |
| 13 | + - name: Destroy resource group and all associated resources |
53 | 14 | azure_rm_resourcegroup: |
54 | 15 | name: "{{ resource_group_name }}" |
55 | 16 | state: absent |
56 | 17 | force_delete_nonempty: true |
| 18 | + register: rg |
57 | 19 |
|
58 | 20 | # Mandatory configuration for Molecule to function. |
59 | 21 |
|
|
65 | 27 | copy: |
66 | 28 | content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" |
67 | 29 | dest: "{{ molecule_instance_config }}" |
68 | | - when: server.changed | bool |
| 30 | + when: rg.changed | bool |
69 | 31 | {%- endraw %} |
0 commit comments