For starters, you have a typo in your add_host task: publid_dns_name should be public_dns_name.
When you run your playbook the first time, there *is* no inventory. If you want to be able to access your new instances from the same playbook that creates them, you'll need to reference them by either the registered variable (ec2) or the group you're adding them to (my_cool_instance_group). Dynamic inventory isn't dynamically modified as you create instances. It simply populates your inventory when the playbook starts. That's the inventory you have to work with until the playbook is complete and you refresh the cache. On Tuesday, April 28, 2015 at 1:53:14 PM UTC-4, Mateus Dubiela Oliveira wrote: > > > *TL;DR: *When I create a instance the *ec2_* *variables are undefined. > > > Hello, > > I'm using ansible to create instances and using the *ec2_tag_Name* to set > up the machine's hostname. The problem is, on the first run the playbook > crashes saying that the '*ec2_tag_Name*' variable is undefinded, which is > odd, since it should be automagicly defined by the *ec2.py* script. I've > tried to run [$ ./ec2.py --refresh-cache]after the machine's creation > but with no luck. > > My current workaround is to simply run the playbook twice, the variable is > defined on the second run. > > Here <https://gist.github.com/mateusduboli/ca9ebaf6637ded97b46c> is a > example playbook with this behaviour. > > Thank you! > > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1ce12ba4-c9af-47d1-ad5b-119812482ad4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.