Guidance on deploying with Ansible

53 views
Skip to first unread message

Jeremy Gailor

unread,
Sep 9, 2014, 4:34:08 PM9/9/14
to ansible...@googlegroups.com
I think I have an idea about how to do this, but I wanted some guidance from the Ansible community:

What I would like to do is the following:

1) Run ansible-playbook
2) Ensure that there are X nodes in EC2 matching some criteria (an instance tag would be best), and create additional instances as necessary to bring the count up to X
3) Add each of the instance found/created to the set of hosts or the play
4) Add host variables based on instance tags on each of the instances
5) Run my play (and all associated roles) against that list of hosts built from the previous steps.

Thanks for the help.

Michael DeHaan

unread,
Sep 9, 2014, 4:37:42 PM9/9/14
to ansible...@googlegroups.com
Take a look at "exact_count" in the Ec2 module for #2, as combined with the add_host module.

This is a pretty common pattern.

With add_host you can throw the machine into a group, and the group_vars files will pick up and be applied.

Any specific questions?



--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/718b9ed2-ecb5-4855-bc10-695a1beabc5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeremy Gailor

unread,
Sep 9, 2014, 4:43:45 PM9/9/14
to ansible...@googlegroups.com
Awesome, this is a great start.

2 questions off the top of my head:

1) Because I am using ansible-playbook, where do I put these steps such that they run before the roles do so that all the machines are created, running, and in the hosts for the play?  Would I have them in the playbook file before the -roles section?

2) Can I take the tags from the ec2 instances and add them as variables on the hosts as I add each instance to the hosts for the play?  I have host-specific configuration that would be perfect to put in the instance tags

Thanks for you help.
Reply all
Reply to author
Forward
0 new messages