---
- name: Force remove s3 bucket
  s3_bucket:
    name: "{{ s3_bucket_name }}"
    state: absent
    force: yes

- name: Remove extra App nodes Cloudformation
  cloudformation:
    stack_name: "{{ item }}"
    state: absent
    template: roles/cloudformation-infra/files/add-node.json
    region: "{{ region }}"
  with_items:
  - "{{ extra_app_nodes }}"
  when: extra_app_nodes is defined

- name: Remove extra Infra nodes Cloudformation
  cloudformation:
    stack_name: "{{ item }}"
    state: absent
    template: roles/cloudformation-infra/files/add-infra-node.json
    region: "{{ region }}"
  with_items:
  - "{{ extra_infra_nodes }}"
  when: extra_infra_nodes is defined

- name: Remove Gluster Cloudformation
  cloudformation:
    stack_name: "{{ item }}"
    state: absent
    template: roles/cloudformation-infra/files/add-cns-storage.json
    region: "{{ region }}"
  with_items:
  - "{{ gluster_nodes }}"
  when: gluster_nodes is defined

- name: Remove Cloudformation
  cloudformation:
    stack_name: "{{ stack_name }}"
    state: absent
    template: "roles/cloudformation-infra/files/{{ stack_name }}-greenfield.json"
    region: "{{ region }}"
  ignore_errors: true

- name: lookup up vols
  ec2_vol_facts:
    region: "{{ region }}"
    filters:
      status: available
  register: vols

- name: cleanup
  ec2_vol:
    id: "{{ item.id }}"
    state: absent
    region: "{{ region }}"
  with_items:
  - "{{ vols.volumes }}"
  when: ci
