EC2 provisionning and configuring with variables from inventory/ec2.py

83 views
Skip to first unread message

Olivier Vernin

unread,
Nov 4, 2014, 3:56:14 AM11/4/14
to ansible...@googlegroups.com
Hi,
I am facing a little problem and I don't find a clear solution
I need to provision a new EC2 (AWS) instance and configure it.
During the configuration I use some variables from the inventory script ec2.py

So I tried two approaches:
    1)  I executed two different playbooks under a shell script
    ¦   - ansible-playbook create_ec2.yml
    ¦   - ansible-playbook configure_ec2.yml

    ¦   This approach works but I use a shell script which execute two ansible scripts

    2)  I execute a meta playbook (which include create_ec2.yml then configure_ec2.yml)
    ¦   - ansible-playbook meta_ec2.yml

    ¦   This approach fail because it doesn't know variable like ec2_private_ip_address from ec2.py
    ¦   So I tried different thinks to get those variables, add
    ¦   ¦   ''' - name: Refresh AWS Cache
    ¦   ¦   ¦   - command: inventory.d/ec2.py --refresh-cache
    ¦   ¦   '''
    ¦   ¦   ¦   - name: gathering ec2 facts
    ¦   ¦   ¦   ¦ ec2_facts:
    ¦   ¦   '''
    ¦   But none of them work
Is anyone has an advice?

Michael DeHaan

unread,
Nov 5, 2014, 9:23:49 AM11/5/14
to ansible...@googlegroups.com
Typically the create playbook would include the configure playbook, using the "add_host" trick.

This is covered a bit in EC2 examples, others here can also offer some good pointers to EC2 workflow.

We're going to working on making the EC2 "best practices" type doc stuff a lot better in the coming months to show how to string these things together.



--
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/23426761-d144-4f72-ae3d-3ad120d6a8c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages