---
{% raw -%}
- name: Destroy
  hosts: localhost
  connection: local
  gather_facts: false
  no_log: "{{ molecule_no_log }}"
  vars:
    resource_group_name: molecule
    virtual_network_name: molecule_vnet
    subnet_name: molecule_subnet
  tasks:
    - name: Destroy resource group and all associated resources
      azure.azcollection.azure_rm_resourcegroup:
        name: "{{ resource_group_name }}"
        state: absent
        force_delete_nonempty: true
      register: rg
      notify:
        - Dump instance config

    - name: Populate instance config
      ansible.builtin.set_fact:
        instance_conf: {}

  handlers:
    - name: Dump instance config
      ansible.builtin.copy:
        content: "{{ instance_conf | to_json | from_json | to_yaml }}"
        dest: "{{ molecule_instance_config }}"
        mode: "0644"
{%- endraw %}
