AWX shared playbook between projects/templates?

Is it possible to share a playbook between projects? I’m able to share roles by creating a symlink but it doesn’t appear to work with playbooks. I have a playbook that basically includes a role which works between projects but I have to create basically a duplicate playbook in each scm repo so I can create a template using the playbook for each repo when its the exact same playbook.

The symlink works allowing me to create the template but when I actually run the template it fails saying it can’t find playbooks/shared_playbook.yml

Hi dpowell,

I’m not sure if that’s possible but, if it is, it sounds like a “it works but unsupported” solution. I could see running into maintainability issues managing links between projects/repos, depending on how much you’re planning to scale.

One option is to keep the single repo/project but wrap the template in question in a workflow. This would allow you to present the playbook to multiple orgs (if you’re using those for RBAC) and/or with different names while only having to maintain a single repo. The workflow can belong to a different org from the template as long as the user building the workflow has access to both orgs. The user running the workflow just needs access to the workflow, not necessarily the template(s).

We use a similar approach to allow for template reuse between multiple use cases where we only need to change a variable, survey question or inventory but the main playbook code is the same. This also allows us to abstract the playbook logic from contractors who just need to execute the tool but shouldn’t have access to the underlying templates.

Happy to help brainstorm ideas

1 Like

Thanks for the info. I’m testing one more thing right now so will see if it helps. Then will explore the workflow template ideal. I’ve only played with them for a few mins. We’re currently switching from a home grown ansible UI to AWX. We’re just trying to make sure we have as much of a seamless transition for our consumers on our tool to AWX.

When AWX runs a playbook, it creates a new container and copies the project to the container. Then that container runs the playbook, and will have all of the resources available within that project.

By creating a symlink in your project to another project, the job container ends up with a symlink that points to nothing because the other project doesn’t get copied over.

So no, sharing a playbook between projects isn’t “supported” like this. However, you can place a playbook inside of a collection, and have AWX dynamically install the collection via a requirements file in each project. However, to run that playbook, you would need to have a playbook in each project that uses the import_playbook keyword to call the playbook in the collection.

Thanks, that is what I was testing. I tried setting Follow symlinks in the Job-Settings but that didn’t work. It allows me to choose the playbooks/playbook.yml since its found but as you stated it wasn’t copied into the container as it was a link.

I think the simple playbook to include the collections playbook may be the simplest thing to try at this point.