From the course: Ansible: From Basics to Guru by Pearson

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Lesson 18 lab solution: Managing AWS with Ansible

Lesson 18 lab solution: Managing AWS with Ansible - Ansible Tutorial

From the course: Ansible: From Basics to Guru by Pearson

Lesson 18 lab solution: Managing AWS with Ansible

All right, I'm going to base this work on things that we've already done. We have this list instances, and we might as well use list instances. By the way, the difference between list instances and list instances new is the 2.9 or the 2.10 collection-based syntax. 2.9 syntax is doing just right here. So what do we have in listinstances.yml? We have all of this code and you know what? I am going to need all of this. So let me copy listinstances.yml to removeinstances.yml. and let me edit remove instances.yaml. So we are going to use the default parameters to get the information, and then we are getting the instance ID. Just a debug first. The only thing that I need is the instance ID. So I don't need the state. I don't need the public DNS. I only need the instance ID. So let's just use debug to print the instance ID. And next, let's use the appropriate module, which would be the EC2 module. So let's call it remove them. EC2 is what we are going to use. And in EC2, we are going to use…

Contents