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

654 views
Skip to first unread message

java_cat33

unread,
Aug 7, 2018, 4:06:59 AM8/7/18
to AWX Project
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.

Damon Powell

unread,
Sep 26, 2019, 5:58:12 PM9/26/19
to AWX Project
Did you ever figure this out or get a reply off line. Struggling with similar questions. 

Rod Oliver

unread,
Sep 28, 2019, 10:37:17 AM9/28/19
to Damon Powell, AWX Project
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. 

--
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 awx-project...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/de4b1d02-80e3-42a2-9950-c4618f0f98a7%40googlegroups.com.
Message has been deleted

Damon Powell

unread,
Sep 28, 2019, 7:05:01 PM9/28/19
to AWX Project
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.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-p...@googlegroups.com.

Wei-Yen Tan

unread,
Sep 28, 2019, 8:38:41 PM9/28/19
to Rod Oliver, Damon Powell, AWX Project
Wouldn’t the actual task logic be pushed into an ansible  module/library. The actual play in the role is so declarative...

That's how I handle a lot of my custom modules for my windows nodes. For any custom  activity I write an ansible library and attach to my library f older which I then reference in my tasks. 

 

From: awx-p...@googlegroups.com on behalf of Rod Oliver <rodo...@gmail.com>
Sent: Saturday, September 28, 2019 10:37 PM
To: Damon Powell
Cc: AWX Project
Subject: Re: [awx-project] Re: Directory structure / git / roles / inventory and general 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. 

On Thu, 26 Sep 2019 at 23:58, Damon Powell <dscott...@gmail.com> wrote:
Did you ever figure this out or get a reply off line. Struggling with similar questions. 

On Tuesday, August 7, 2018 at 3:06:59 AM UTC-5, java_cat33 wrote:
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.

--
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 awx-project...@googlegroups.com.

--
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 awx-project...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/CAGaNFzMuGUgn6cjbpjugx7Pc2z3rvRWtbRZx36yJNuswM6KVnA%40mail.gmail.com.

Wei-Yen Tan

unread,
Sep 28, 2019, 8:41:15 PM9/28/19
to Damon Powell, AWX Project
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



 

From: awx-p...@googlegroups.com on behalf of Damon Powell <dscott...@gmail.com>
Sent: Sunday, September 29, 2019 7:05 AM
To: AWX Project

Subject: Re: [awx-project] Re: Directory structure / git / roles / inventory and general questions...
 
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/08a3fa95-e2d3-46aa-a092-0d9c7c9f582f%40googlegroups.com.

Damon Powell

unread,
Sep 29, 2019, 10:58:12 AM9/29/19
to AWX Project
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.

Damon Powell

unread,
Sep 29, 2019, 11:32:14 AM9/29/19
to AWX Project
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)





On Tuesday, August 7, 2018 at 3:06:59 AM UTC-5, java_cat33 wrote:
Reply all
Reply to author
Forward
0 new messages