Terminating all the resources
Before we complete this chapter, we need to look at terminating the resources; to do this, you can run the following:
$ ansible-playbook -i hosts destroy.yml
This removes everything in the reverse order that we launched it, starting with the Auto Scaling Group:
PLAY [Destroy the AWS Environment created by the site.yml playbook] ************ TASK [Gathering Facts] ************************************ ok: [localhost] TASK [Delete the Auto Scaling Group] ********************** changed: [localhost] TASK [Delete the Launch Template] ************************* changed: [localhost]
As there can be more than one AMI, we gather some facts and then loop through removing everything that is returned:
TASK [Get information about the AMIs] ********************* ok: [localhost] TASK [Delete the AMI(s)] ********************************** changed: [localhost] => (item={'architecture': 'x86_64', 'creation_date': '2024-01...