Access to variables defined in roles from python script

Skip to first unread message

wnel...@gmail.com

unread,
Mar 7, 2019, 4:09:33 AM3/7/19
to Ansible Project
I am an ansible newbie. My first non-trivial ansible project is to update / optimize the configuration of Juniper switches. The ansible modules are not run on the Juniper switch but locally on the ansible controller. The default modules do not seem to match our requirements, thus a (python) user module is needed. In a role ( ~/roles/x/vars/main.yaml ) a multi-level dict (in python-parlance) is defined, which includes a few lists. Is this information accessible from within a python script running on the ansible controller, and if so, how?

Pshem Kowalczyk

unread,
Mar 7, 2019, 4:57:15 AM3/7/19
to Ansible Project
Hi,

You'll need to build your own module that you can invoke from your task list or role.

kind regards
Pshem


On Thu, 7 Mar 2019 at 22:09, <wnel...@gmail.com> wrote:
I am an ansible newbie. My first non-trivial ansible project is to update / optimize the configuration of Juniper switches. The ansible modules are not run on the Juniper switch but locally on the ansible controller. The default modules do not seem to match our requirements, thus a (python) user module is needed. In a role ( ~/roles/x/vars/main.yaml ) a multi-level dict (in python-parlance) is defined, which includes a few lists. Is this information accessible from within a python script running on the ansible controller, and if so, how?

--
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/bcfc0ff2-ad8b-4030-b9a2-de7871177516%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

wnel...@gmail.com

unread,
Mar 11, 2019, 7:43:42 AM3/11/19
to Ansible Project
I've read it, as well as other documents w.r.t. development of user modules. However, it does not answer my original question, nor does it supply a pointer to an answer.
In the mean time an related question has come up. On remote machines one can save some 'facts' in /etc/ansible/facts.d/*fact. Is a similar functionality also available on the ansible controller?
Reply all
Reply to author
Forward
0 new messages