Terminating resources

As already mentioned at the start of this chapter, we are launching resources that are going to incur costs when they are up and running. As we are still writing our playbook, we don't want the resource to sit idle and rack up costs while we work, so let's create a supporting playbook that undoes everything we have just ran.

To do this, let's create a single role called remove:

$ ansible-galaxy init roles/remove

This role will use Ansible to, well, remove everything we have just launched, thus keeping costs down while we are developing our playbook. First of all, we need to add some default variables to roles/remove/defaults/main.yml; these are:

wait:  wait: "yes"  wait_time: "1200"vpc_cidr_block: "10.0.0.0/16"

The vpc_cidr_block ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.