Search Path for Playbooks?

I’m a newbie planning to use Ansible in a multi-project / multi-developer environment.

I envision creating a set of ‘system-wide’ playbooks, augmented by project-specific playbooks that extend and perhaps overlay the ‘system-wide’ setup.

It seems I can do this if I use absolute paths. But absolute paths are awful, since different developers will install playbook directories in different locations.

Can developers set up a search path for playbooks? I found how to set up a search path for modules, but couldn’t figure out how to establish a search path for playbooks.

I’m not sure why you think you need to use absolute paths.

Yes, when you run ansible-playbook, you do need to specify what playbook you want to run, but they need not be absolute.

Help me understand further?

Yeah - you can use relative paths to reference playbooks.

But still - for my projects those relative paths are long and unwieldy - it would be much easier if I could reference all of my playbook directories with search paths. My playbooks are in different directories.

I’m using search paths for ansible modules. Is there a way to reference playbooks with search paths?

There’s not a search path for /usr/bin/ansible-playbook to find what files you specify to it.

To me, they are inexoriably (is that the right word to use? Looking it up) files.

Symlinks may help? Or you could have playbooks in one dir that include playbooks in another (they are just includes and nothing else) to save typing?

Ultimately Ansible seeks (strongly) to be a minimal system, so I feel like adding search paths for something that is a shell argument (the path to the playbook) to me, feels as strange as if “ls” had a search path for it’s first argument.

OK - seems like you don’t want search paths for playbooks. Fair enough. I’m new to ansible, so maybe in time I will understand why that is a good design choice.

Sure I can find workarounds - simple enough to write some sort of ansible proxy that will behave like I want. But its a shame that I have to write a proxy or implement a novel symlink scheme when a simple colon separated string in ~/.ansible.cfg would get the job done.

Re: desire to be minimalist - I understand that. But is it really that hard to implement a search path? In Ruby, its a one liner. (I don’t know python but I’d be surprised if its much more complicated)

Last question - I’m curious: why agree to have search path for Modules, but not for Playbooks? The usage models should be consistent.

Finally - thanks for Ansible. Except for playbook search paths, everything I see here looks great and I’m looking forward to using Ansible for my projects.

Andy,

I use ${base}/playbooks/do_something.yml and ${base}/environments/vars/some_vars.yml etc. And then on the command line do -e “base=$(pwd)” and make sure to always stay in the base directory when running playbooks.

I agree, it’s a silly thing to have to implement ourselves.

Having a base variable is fine.

Not really sure why you didn’t just do

environments/vars/some_vars.yml though

relative to the playbook.

Ya, I suppose I can just use relative paths. ${base} was more clear for us and easier to debug, and hopefully it will prevent having to update file references if/when we move things around in the future.