Trying to figure out how to the get following solved. Coming from Puppet I
have a bit of an adjustment to make.
I'm trying to configure a few comware/arista switches which are only
accessible via a certain jump host.
*My inventory look like*:
*[comware]*
switch1
switch2
*[arista]*
switch3
*[switches:children]*
comware
arista
First my though was to create a role named "my-switches"
Create a playbook with the hosts set to "switches" which would loop through
the list [switch1, switch2, switch3]
Since they are only accessable via a certain jump-node I though using the
"delegate_to: jump_host" for each tasks.
But I also get some pre-tasks I would like to have executed installing
required pip packages on the jump_host.
Could really get this sorted out. Pre-tasks not running on the correct host
so then I switched to a different way of doing this.
Created a dict in the group_vars/all.yml
switches:
user: admin
pass: password
list:
switch1:
flavor: comware
switch2:
flavor: comare
switch3:
flavor: arista
And then setting the hosts in the playbook to "jump_host". Now the
pre-tasks installs correctly and I'm using with_items to loop switches.list
But delegate_to seems to be overrided by the fact that hosts in the
playbook is set to "jump_host".
The comware module runs ssh against my jump_host for every loop
(with_items) in roles/my-switches/tasks/main.yml.
Some how feels incorrect to build up a list of switches to iterate over
instead of using the inventory.
Not exactly sure what I'm failing to understand. Tried using the
ansible_host variable in the role but I'm guessing it gets overruled by the
hosts: jump_host defined in the playbook.
Maybe I'm jumping into ansible not doing the proper homework first of
passing the primer.
Did my question even make sense?
Also would be nice to be able to figure out which group a switch came from
in my first example to get the flavor of it not using extra variables when
using groups of groups.
Thanks!
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/596c5974-d72b-4ac9-b30d-c7272a36a38e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.