How to set current directory in ansible.cfg?

142 views
Skip to first unread message

ZillaYT

unread,
Oct 2, 2017, 2:57:43 PM10/2/17
to Ansible Project
I want to set a roles_path = ${curr_dir}/roles, but how do I set curr_dir to my current directory where I run ansible-playbook command in my ansible.cfg file?

Brian Coca

unread,
Oct 2, 2017, 3:01:32 PM10/2/17
to Ansible Project
In 2.4 and above you can use {{CWD}}, i still don't recommend it as
it is a security risk (cd /tmp; ansible-playbook ~/security/play.yml)



--
----------
Brian Coca

ZillaYT

unread,
Oct 2, 2017, 3:06:04 PM10/2/17
to Ansible Project
Thanks. So what is the recommended way for setting roles_path to be <curr_dir>/roles for example?

Brian Coca

unread,
Oct 2, 2017, 3:08:03 PM10/2/17
to Ansible Project
That is my point, i don't recommend ever using 'cur dir', if invoking
a play, it already uses a roles/ dir adjacent to the play, I would use
that or a directory set by configuration.




--
----------
Brian Coca

ZillaYT

unread,
Oct 2, 2017, 3:17:01 PM10/2/17
to Ansible Project
Ah. I want to set it b/c I want to run the following to clone the roles defined in my current playbook's requirements.yml file in a roles sub-directory relative to my playbook.

$ ansible-galaxy install -r requirements.yml

So if my playbook is in....

/home/myuser/ansible-plays/myplaybook.yml

...and I run above command in that dir, I want the roles to be in

/home/myuser/ansible-plays/roles

Thanks again

ZillaYT

unread,
Oct 2, 2017, 3:21:20 PM10/2/17
to Ansible Project
I know I can...

$ ansible-galaxy install -r requirements.yml -p ./roles
Reply all
Reply to author
Forward
0 new messages