nucypher/deploy/ansible/provision/terminate.yml

33 lines
916 B
YAML

- hosts: localhost
connection: local
gather_facts: false
user: root
pre_tasks:
- include_vars: "{{ lookup('env', 'ANSIBLE_VARIABLES') }}"
vars:
nucypher_network_name: "{{ lookup('env', 'NUCYPHER_NETWORK_NAME') }}"
inventory_group: "{{ nucypher_network_name }}-{{ nucypher_role }}"
tasks:
- name: Get EC2 instance IDs for {{ nucypher_network_name }}
run_once: true
ec2_remote_facts:
filters:
"tag:Type": "{{ ec2_tag_Type }}"
"tag:Role": "{{ inventory_group }}"
region: "{{ ec2_region }}"
register: instances
- name: display instances
run_once: true
debug:
var: instances
- name: Remove registered instances
run_once: true
ec2:
state: absent
wait: true
instance_ids: "{{instances|json_query('instances[*].id')}}"
region: "{{ ec2_region }}"
when: instances