Accessing "Ansible Variables" in custom modules ?

237 views
Skip to first unread message

Kumar

unread,
May 23, 2012, 7:18:52 PM5/23/12
to Ansible Project
Hi :

Is there anyway to access the setup module variables in a custom
built modules ?
Are there variables passed to the modules.

Thanks,

Michael DeHaan

unread,
May 23, 2012, 8:23:21 PM5/23/12
to ansible...@googlegroups.com
On Wed, May 23, 2012 at 7:18 PM, Kumar <kumaravel...@gmail.com> wrote:
> Hi :
>
>  Is there anyway to access the setup module variables in a custom
> built modules ?

Easiest thing is to pass them back to the modules using the dollar
sign syntax. In other words, they already bubble up back to the
playbook, so you just pass the things in that you need.

Trivial example:

command echo $ansible_hostname

Modules don't require the setup module to be used (think
/usr/bin/ansible vs /usr/bin/ansible-playbook), so they don't read
from there.
Reply all
Reply to author
Forward
0 new messages