Questions about roles_path

28 views
Skip to first unread message

candlerb

unread,
Oct 17, 2016, 4:27:05 AM10/17/16
to Ansible Project
A couple of questions:

(1) Is it possible to set roles_path within a playbook?

(I tried "vars: {roles_path: ...}" and "vars: {ansible_roles_path: ...}" but they didn't work)

(2) Is it possible to set roles_path to search for directories relative to playbook_dir ?

Here's the use case. I want to organise a bundle  playbooks into a set of sibling directories, plus a "shared" directory for roles common to them all.

foo/
bar/
baz/
shared/

I would like to avoid writing

roles:
  - ../shared/roles/xxx
  - ../shared/roles/yyy

when referring to the shared roles. But I would also like users to be able to checkout the whole bundle at any location in the filesystem.

Thanks,

Brian.

candlerb

unread,
Oct 18, 2016, 3:39:51 AM10/18/16
to Ansible Project
I think I found a workaround.

ansible looks for ansible.cfg in the current working directory, before looking in ~/.ansible.cfg or /etc/ansible.cfg

So I can include within the playbook directory:

[defaults]
inventory = ./hosts
roles_path = ../shared/roles

This works as long as the user does:

cd path/to/playbook
ansible-playbook playbook.yml

rather than:

ansible-playbook path/to/playbook/playbook.yml

(However I'd still like to be able to set roles_path within a playbook, this would be a cleaner solution)

Regards,

Brian.
Reply all
Reply to author
Forward
0 new messages