# Required Python packages:
#
# ansible
# openstackclient
# openstacksdk

- ansible.builtin.import_playbook: common.yaml

- hosts: all
  gather_facts: no

  tasks:
  - name: 'List security groups'
    ansible.builtin.command:
      cmd: "openstack security group list --tags {{ cluster_id_tag }} -f value -c ID"
    register: security_groups

  - name: 'Remove the cluster security groups'
    ansible.builtin.command:
      cmd: "openstack security group delete {{ item.1 }}"
    with_indexed_items: "{{ security_groups.stdout_lines }}"
