How to set a variable using dynamic inventory using Ansible

47 views
Skip to first unread message

Rahul Mehrotra

unread,
Jun 17, 2015, 3:44:45 PM6/17/15
to ansible...@googlegroups.com
I am looking for method to set a variable in ansible playbook using inventory information received from dynamic inventory. 

For example if we have a sample playbook like


    ---
    - hosts: localhost
      connection: local
      
      tasks:
       - set_fact: rds_hostname="{{ rds_mysql }}" #set rds endpoint from ec2.py
       
       - debug: var=rds_hostname 
      

I am able to get the endpoint when I run the plain ec2.py script as


> "rds_mysql":{
> }

However I wish to set rds_hostname as the endpoint recieved from dynamic_inventory. 

Can any one point out my mistake. Thank you

Brian Coca

unread,
Jun 18, 2015, 12:11:56 AM6/18/15
to ansible...@googlegroups.com
what is rds_mysql in this context? it is not clear that it is returned
as a hostvar/groupvar or something else



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages