scottslowe-learning-tools/ansible-aws/delete.yml
Scott S. Lowe b0a8f6de59 Commit learning environment for using Ansible with AWS
Add Ansible configuration, Ansible inventory, dynamic inventory script, and Ansible playbooks for a learning environment that shows how to manage AWS infrastructure using Ansible.

Signed-off-by: Scott S. Lowe <scott.lowe@scottlowe.org>
2016-10-23 10:09:49 -06:00

37 lines
841 B
YAML

---
- hosts: "tag_tool_ansible"
connection: "local"
gather_facts: false
vars:
region: "<insert AWS region here>"
tasks:
- name: "Remove tagged EC2 instances from security group"
ec2:
state: "running"
region: "{{ region }}"
instance_ids: "{{ ec2_id }}"
group_id: ""
delegate_to: "localhost"
- name: "Terminate tagged EC2 instances"
ec2:
state: "absent"
region: "{{ region }}"
instance_ids: "{{ ec2_id }}"
wait: true
delegate_to: "localhost"
- hosts: "localhost"
connection: "local"
gather_facts: false
vars:
region: "<insert AWS region here>"
tasks:
- name: "Remove security group"
ec2_group:
name: "ansible-sec-group"
description: "New SG for Ansible-created instances"
region: "{{ region }}"
state: "absent"