Advertisement
Guest User

Untitled

a guest
May 21st, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. - name: Get Instance facts
  2. ec2_instance_facts:
  3. aws_access_key: "{{ access_key }}"
  4. aws_secret_key: "{{ secret_key }}"
  5. region: "{{ aws.region }}"
  6. filters:
  7. availability-zone: "{{ aws.az1 }}"
  8. register: ec2_facts
  9.  
  10. # ec2_instance_facts gets me a list of each instance it's facts ec2_facts.0.XXX for example
  11.  
  12. How can I loop through and delete something like
  13.  
  14. - name: Destroy ec2 instances
  15. ec2:
  16. aws_access_key: "{{ presops_access_key }}"
  17. aws_secret_key: "{{ presops_secret_key }}"
  18. region: "{{ aws.region }}"
  19. state: absent
  20. instance_ids: {{ item }}
  21. with_items: ec2_facts.item.instance_id
  22.  
  23.  
  24. # I know this is incorrect, but am trying to wrap my head around looping thru the list and getting the instance_id value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement