John_Wong
(John Wong)
January 21, 2013, 11:18pm
1
This is how I structure my playbooks
/root/
bootstrap.yml
master.yml
slave.yml
/apt/
tasks/
common.yml
master.yml
slave.yml
bootstrap is entry point
In bootstrap.yml I include master and slave playbooks
include master.yml
include slave.yml
In master and slave I need to include common,yml and {name}.yml
Common.yml contains common apt packages. I make user and hosts attribute as variables.
I want to supply a global var $user and $hosts in bootstrap.yml
John_Wong
(John Wong)
January 21, 2013, 11:39pm
2
The alternative is to place “include comm.yml” under apt/tasks/slave.yml and apt/tasks/master.yml, either as a standalone include, or a task-level include. The task-level include can pass in the parameters. That’s okay.
But looking for a global var solution.
Thanks
Is there a way to specify global level vars? Currently, I have to specify it
by hand.
In the same directory as your inventory file, make a 'group_vars/all'
file and put it there, in YAML, without the "vars:" indent.
John_Wong
(John Wong)
January 24, 2013, 5:02am
4
Thanks. I double check with the docs. Not sure if I miss anything.
I issue
ansible-playbook playbooks/bootstrap.yml -i /home/glasslab/workstation/vagrant-workstation/tests4/graphyte_playbooks/hosts -u vagrant -k -vvv
inside graphyte_playbooks
graphyte_playbooks/
hosts
/group_vars
master
/playbooks
bootstrap.yml
common.yml
/apt
setup.yml
In my bootstrap.yml I have
include: common.yml hosts=master
and in common.yml I have - include: apt/setup.yml
The only place I define $hosts and $user are in apt/setup.yml
But instead, the debug shows user is not substituted.
u’User=$user’, ‘192.168.1.151’
I just put the following in group_vars/master