Directory structure / git / roles / inventory and general questions...

I’m aware of the recommended directory structure published on the Ansible website. My questions however are:

  1. Do you have a git repo containing ALL of your playbooks? E.G all server related plays? Another repo for all network related plays?
  2. Do you have a git repo for each project you work on? E.G a project might be a Citrix farm refresh where numerous plays are required (Citrix, SQL, Apps etc)?
  3. Do you keep a copy of your roles and playbooks locally on the AWX box for development and testing and then only run them via AWX pulling from src control?
  4. Do you store your roles in a separate git repo?
  5. How do you keep your inventory in sync between Ansible core and AWX when using groups etc?
    Based upon my very limited use of AWX the custom roles will need to be stored locally on the AWX box however if I want to use galaxy roles I can reference these via a requirements.yml

Sorry about all the questions but I’m struggling to find these answers and want to ensure we adopt a recommended practice (this is a greenfield deployment where we have only just adopted using Ansible within the last couple of months - AWX is not in use yet).

Any other tips or lessons learnt you are willing to share would be greatly appreciated.

Did you ever figure this out or get a reply off line. Struggling with similar questions.

We put task logic into roles. Each role is on GitHub Enterprise in its own repo. We try to manage the number of roles/repo by putting related functions into the same role. Likewise we have playbook repos which contain one or more related playbooks, which are pretty simple with no tasks other than declaring some variables and tasks with the module ‘import_role’ to invoke the role function. In roles/responsibilitiesquirements.yml of the playbook repo, the roles used in the playbooks are listed along with a GitHub release. We define the GitHub release in the project in AWX. In that way updates on Git either for roles or playbooks don’t get used until we pull the trigger and change the release number in AWX.

We tend to develop roles/playbooks initially on the command line and when they seem functional push them to GitHub, up to release number and then point to that release in AWX.

Using release numbers can get complex, especially when you have a lot of different roles. However it gives a nice degree of control over what is run on AWX.

Thanks for the reply. Have you used any custom lib’s in your roles? I’m having the issue where the tasks/file.yml isn’t finding the methods from the custom library. I have the following structure for my role which seems to be what the doc’s suggest but within AWX it doesn’t pick them up.

roles/
role-name/
library/
customlib.py
tasks/
mail.yml (has calls to customlib.py but they aren’t being found)

Is there anything special that needs to be done to consum a custom lib?

Thanks again for your time.

How do you reference customlib.py?
By right It should be something like

Name: test module
Customlib:
parameter1: 1 St parameter
parameter2: 2 nd parameter

– You received this message because you are subscribed to the Google Groups “AWX Project” group. To unsubscribe from this group and stop receiving emails from it, send an email to . To view this discussion on the web visit .

I’m actually trying to follow the Redhat infra process creating org’s/projects,rbac through source. https://github.com/redhat-cop/infra-ansible/tree/master/roles/ansible/tower/manage-projects. I’m trying to create multiple projects for teams outside of my org. Trying to use the same rest_get custom module. It complains it doesn’t know what rest_get is. I’ve tried to put it in multiple diff locations. I can use the module ‘uri’ instead but was trying to figure out the library issue as I’m sure we’ll have need for our own at some point.

I have the

role/task/main.yml

  • name: “Get the existing projects”
    rest_get:
    host_url: “{{ ansible_tower.url | default(default_ansible_tower_url) }}”
    library/rest_get.py

With the above example the task isn’t able to use rest_get.

Seems to be working after moving the custom module library to the playbooks folder /library not in the roles /library.

Before which didn’t work

playbooks/ test.yml (calls the role) roles/ my_role/ tasks/....main.yml (uses rest_get module) library/ rest_get.py

This works, not how I would expected it from what I’ve read but is working.

playbooks/ test.yml (calls the role) library/ rest_get.py roles/ my_role/ tasks/....main.yml (uses rest_get module)