I would like to be able to refer to the roles in “foundation_roles” without having to use relative references everywhere. In particular, the roles in “foundation_roles” need to reference each other.
I believe one elegant solution would be to use the role_paths configuration setting - IF you could specify a path that was relative to the playbook_dir. However, as far as I can tell, these paths need to be absolute, or they are relative to the directory from which ansible was invoked.
The issue is that the relative path is relative to where the playbook was invoked, not relative to the playbook. That means that every invocation must be from the same relative depth - which is not necessarily the case when the roles are being shared by lots of people and automation. For example, we have build automation that tends to nest the ansible playbooks quite deeply.
For example the relative path in the roles_path directory would cause at least one of the following cases to fail:
1. Ansible-playbook /a/b/c/pb.yml
2. Ansible-playbook /x/pb.yml
where the actual directory names are irrelevant, only the depth matters.
I think the real question is in what cases would current ansible code break if the relative role_paths were defined to be relative to the playbook_dir?
“The path should be relative to the config file (it has not always been, but fixed in 2.4 to ensure this).”
Which path? And do you mean “ansible.cfg”. I’m currently running ansible 2.3.1, so that may be the source of my problems.
If, as of 2.4, the path from which relative paths in ROLES_PATH are calculated is the directory containing ansible.cfg, that will resolve my issue nicely.