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

**URL:** <https://forum.ansible.com/t/directory-structure-git-roles-inventory-and-general-questions/28277>\
**Category:** AWX Project\
**Tags:** awx, galaxy-ng\
**Created:** [August 7, 2018, 8:06am UTC](https://forum.ansible.com/t/directory-structure-git-roles-inventory-and-general-questions/28277 "2018-08-07T08:06:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lee\_Drew](https://avatars.discourse-cdn.com/v4/letter/l/e0b2c6/32.png) [@Lee\_Drew](https://forum.ansible.com/u/Lee_Drew)\
**Post date:** [August 7, 2018, 8:06am UTC](https://forum.ansible.com/t/directory-structure-git-roles-inventory-and-general-questions/28277/1 "2018-08-07T08:06:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dpowell](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@dpowell](https://forum.ansible.com/u/dpowell)\
**Post date:** [September 26, 2019, 9:58pm UTC](https://forum.ansible.com/t/directory-structure-git-roles-inventory-and-general-questions/28277/2 "2019-09-26T21:58:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![iamroddo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iamroddo/32/321_2.png) [@iamroddo](https://forum.ansible.com/u/iamroddo)\
**Post date:** [September 28, 2019, 2:37pm UTC](https://forum.ansible.com/t/directory-structure-git-roles-inventory-and-general-questions/28277/3 "2019-09-28T14:37:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dpowell](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@dpowell](https://forum.ansible.com/u/dpowell)\
**Post date:** [September 28, 2019, 11:05pm UTC](https://forum.ansible.com/t/directory-structure-git-roles-inventory-and-general-questions/28277/4 "2019-09-28T23:05:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Wei-Yen\_Tan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/wei-yen_tan/32/4111_2.png) [@Wei-Yen\_Tan](https://forum.ansible.com/u/Wei-Yen_Tan)\
**Post date:** [September 29, 2019, 12:41am UTC](https://forum.ansible.com/t/directory-structure-git-roles-inventory-and-general-questions/28277/5 "2019-09-29T00:41:11Z")

</div>

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 .

---

<div class="post-metadata">

**Author:** ![dpowell](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@dpowell](https://forum.ansible.com/u/dpowell)\
**Post date:** [September 29, 2019, 2:57pm UTC](https://forum.ansible.com/t/directory-structure-git-roles-inventory-and-general-questions/28277/6 "2019-09-29T14:57:59Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![dpowell](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@dpowell](https://forum.ansible.com/u/dpowell)\
**Post date:** [September 29, 2019, 3:32pm UTC](https://forum.ansible.com/t/directory-structure-git-roles-inventory-and-general-questions/28277/7 "2019-09-29T15:32:14Z")

</div>

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)`
