Is there an EC2 query module that allows you to look up various resources and associated metadata that can be registered as variables? I consistently seem to run across a problem using Ansible (I assume this is a lack of understanding or misuse of Ansible on my part) where I am doing a sequence of events like this:
- Look up an AMI with some specific tags
- Use said AMI to create ec2 instance(s)
- Add created instance(s) to dynamic hostgroup
- Provision instance(s) in dynamic hostgroup
I know how to achieve this, but my problem occurs if there is some sort of error in step #4. How do I re-assemble the state of steps 2 and 3, without running something like aws cli?
This is how I am doing an approximation of what I want, but I feel like I am doing something wrong. What I really want is to use registered variables, because those seem to be global to playbooks, where facts seem host specific.