How to use galaxy in awx

3,101 views
Skip to first unread message

Selvam Elangovan

unread,
Jul 13, 2020, 6:07:51 AM7/13/20
to AWX Project
Hi!

I plan to install collections in awx.  Could some one guide me?  I use Awx in kubernetes.

It is a netapp collections:

Finally, you need the NetApp collections and the collections directory to allow all users access

$ sudo ansible-galaxy collection install netapp.ontap netapp.elementsw -p /usr/share/ansible/collections
$ sudo chmod +rx /usr/share/ansible/collections

Thanks & Regards,
Selvam E.



Sergio

unread,
Jul 13, 2020, 8:14:43 AM7/13/20
to AWX Project
Hello,

If you have a collections/requirements.yml in your project, AWX will read it and install the collections from it.
Example of requirements.yml:

---
collections:
  - name: awx.awx

Selvam Elangovan

unread,
Jul 13, 2020, 10:28:41 PM7/13/20
to Sergio, AWX Project
Thanks.

--
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/8ae96882-7b36-423d-a205-bff8fd4f94a2n%40googlegroups.com.

Selvam Elangovan

unread,
Jul 15, 2020, 12:51:57 AM7/15/20
to Sergio, AWX Project
one more quick clarification.  can we use different source in requirements.yaml file for SCM project?

Sergio

unread,
Jul 15, 2020, 3:00:52 AM7/15/20
to AWX Project
Well,

According to the docs, yes. You can install collections from a private Git repository if needed.

daniel...@vistracorp.com

unread,
Sep 23, 2020, 6:40:13 PM9/23/20
to AWX Project
So if I read from the link that Sergio posted, I can untar the collection into a git repo and put the link in the playbook and it should work instead of having to go into the Docker container and do the ansible-galaxy install, correct?

"Installing a collection from a git repository

You can install a collection in a git repository by providing the URI to the repository instead of a collection name or path to a tar.gz file. The collection must contain a galaxy.yml file, which will be used to generate the would-be collection artifact data from the directory. The URI should be prefixed with git+ (or with git@ to use a private repository with ssh authentication) and optionally supports a comma-separated git commit-ish version (for example, a commit or tag)."

Sorry, I have very new to Ansible AWX and navigating Docker.  Currently I would much rather not have to tweak the AWX Docker Container.

Thank you

Daniel


Daniel@Vistra

unread,
Sep 23, 2020, 7:07:36 PM9/23/20
to AWX Project
I spent a few hours last night trying to run a playbook with some AWS collections, but I installed the collection at the Linux layer not inside the Docker container, that is what I came to, is I would have to run install inside of Docker container, but If I can reference a GitLab repo, that leaves that Docker repo pristine. 

Thank you
Daniel

Sergio

unread,
Sep 29, 2020, 7:54:06 AM9/29/20
to AWX Project
Hello,

Read my first answer again, you only need to add collections/requirements.yml to your project, then AWX will read it and install the collections from it
No need to manually install the collections inside the Docker containers.

Vibin K Madampath

unread,
Mar 16, 2021, 11:30:13 AM3/16/21
to Sergio, AWX Project
Hello,

Can I have an example requirements.yml file to install the collection from a git repository. 

To test,  I cloned the community.windows git repository nd uploaded to my private repository.

Now, I'd like to install it via requirements.yml file in my project directory.  I'm on AWX 14 and ansible version 2.9

I tried the following but with no luck.

collections:
- name: community.windows
  src: https://*.git
  type: git
  version: master

Any help would be much appreciated. 

phil.gr...@gmail.com

unread,
Mar 17, 2021, 5:42:17 AM3/17/21
to AWX Project
Have a look at my example here: https://github.com/ffirg/tower_collection_example

Vibin K Madampath

unread,
Mar 17, 2021, 2:11:10 PM3/17/21
to phil.gr...@gmail.com, AWX Project
Guess, my question was not clear enough.

I was actually looking for a requirements.yml file which references a private git repository. 

If I read the documentation correctly, its not possible with ansible version 2.9 and Redhat has not released 2.10.


Regards,
Vibin

Phil Griffiths

unread,
Mar 17, 2021, 2:24:24 PM3/17/21
to Vibin K Madampath, AWX Project
What do you mean by a private repo? Hidden behind a firewall on the corp lan, or a github hosted one which is marked as private?
What credentials, if any, do you need to gain access? 

Vibin K Madampath

unread,
Mar 18, 2021, 1:52:19 PM3/18/21
to Phil Griffiths, AWX Project
Hello, 

We use a stash repository behind firewall in the corp lan.

No access outside.

Regards,
Vibin

Phil Griffiths

unread,
Mar 18, 2021, 4:01:21 PM3/18/21
to Vibin K Madampath, AWX Project
stash = bitbucket = git does it not? Not sure why you can't use that, but you haven't provided much detail around what's going on, so its hard to help!

Have you tried any of these:
# from Bitbucket
- src: git+https://bitbucket.org/willthames/git-ansible-galaxy
  version: v1.4

# from Bitbucket, alternative syntax and caveats
- src: https://bitbucket.org/willthames/hg-ansible-galaxy
  scm: hg

# from GitLab or other git-based scm, using git+ssh
- src: g...@gitlab.company.com:mygroup/ansible-base.git
  scm: git
  version: "0.1"  # quoted, so YAML doesn't parse this as a floating-point value


Vibin K Madampath

unread,
Mar 19, 2021, 6:23:17 AM3/19/21
to Phil Griffiths, AWX Project
Sorry for the lack of information. 

Let me update you on background. 

My Awx environment runs on K8s and the ansible version is 2.9

Now my customers want to make use of ansible collections and I'd like that to be managed from their end rather than me installing it everytime. 

Thats when the collections/requirements.yml came in to picture. So that they can download the required collections and store them in git repository and point to that repo in requirements.yml in their project. 

But the problem seems to be this 'git+https' is only supported from ansible version 2.10

https://github.com/ansible collections/community.sops/issues/5

So now I created a custom virtual environment with ansible-base version 2.10 and enabled the venv in the project GUI but it doesn't seem to take it and runs using the default ansible environment. 

To double check anything wrong with the custom venv, I ran a job template using the venv and it worked as expected.

So the only problem is now with project updates not picking up the custom venv during sync from git.

Is this a bug or am I doing something wrong? Appreciate your time and support.

Regards,
Vibin

phil.gr...@gmail.com

unread,
Mar 22, 2021, 7:06:43 PM3/22/21
to AWX Project
I think the project syncs only run from the internal awx venv which shouldn't be modified. JT's are different. 
Soon this shouldn't be a problem as we're moving away from venvs to something called execution environments, but that's not quite here yet.

So why doesn't setting an SCM credential against the internal repos you're trying to use work?

Vibin K Madampath

unread,
Mar 24, 2021, 9:12:26 AM3/24/21
to phil.gr...@gmail.com, AWX Project
Guess, its because the format what we are giving in requirements.yml is not being recognized in ansible version 2.9

---
collections:
  - name: git+https://stash.net/scm/ansible/ansible.windows.git

The same format works fine in ansible version 2.10 and above.

Regards,
Vibin

Andre Semek

unread,
Mar 31, 2021, 5:16:27 AM3/31/21
to AWX Project
Hello.

I've been trying to get collections running for two days without success. To be honest, I don't quite understand it yet and unfortunately find the documentation unhelpful. Can anyone help me or explain how it works with an example !?

I'm using the latest AWX version 18.0.0 and I ALWAYS get this message no matter what I try:

config file = None
configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
ansible collection location = /runner/requirements_collections:/home/runner/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible-playbook
python version = 3.8.3 (default, Aug 31 2020, 16:03:14) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
jinja version = 2.10.3
libyaml = True
No config file found; using defaults
setting up inventory plugins
host_list declined parsing /runner/inventory/hosts as it did not pass its verify_file() method
Parsed /runner/inventory/hosts inventory source with script plugin
redirecting (type: modules) ansible.builtin.win_chocolatey to chocolatey.chocolatey.win_chocolatey

ERROR! couldn't resolve module/action 'win_chocolatey'. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in '/runner/project/windows/roles/install_software/tasks/main.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- name: Install latest Notepad++, 7zip, WinMerge, BareTail, Edge, WinDirStat, ProcessExplorer
^ here


The whole thing runs in docker-compose and I
've tried a requirements.yml in "Roles" folder and in "Collections" folder. In all other folders...
Ansible Galaxy credentials are in AWX and in my Default organization.

Playbook:

root/install_software.yml
---
hostsall
  gather_factsfalse

  collections:
    - chocolatey.chocolatey

  roles:
    - install_software

root/roles/install_software/tasks/main.yml
---
nameInstall latest Notepad++, 7zip, WinMerge, BareTail, Edge, WinDirStat, ProcessExplorer
  win_chocolatey:
    name:
    - notepadplusplus
    - 7zip
    - winmerge
    - baretail
    - microsoft-edge
    - windirstat
    - procexp
    statelatest

root/roles/requirements.yml
---
collections:
  - chocolatey.chocolatey


And I don't understand why doesn't read the ansible.cfg, maybe someone can explain that to me.

Sorry for so much text, but I'm a little desperate no.

regards Andre

Chris Paggen

unread,
Apr 27, 2021, 4:51:55 AM4/27/21
to AWX Project
Same issue as you. Did you ever get this resolved? I tried many different requirements.yml (under directory collections; in the main directory; pointing to Git, pointing to a local gz archive, pointing to the name of the collection as used with ansible-galaxy collection install) and it's as if AWX simply ignores this. It keeps producing the same error as you no matter what I use. If I enter random options in requirements.yml, same thing. Not even an error message telling me the option is invalid. Everything leads to AWX not trying to install the collection at all. Odd, and difficult to troubleshoot.

Chris Paggen

unread,
Apr 27, 2021, 8:33:27 AM4/27/21
to AWX Project
Solved with a custom EE. See https://www.linkedin.com/pulse/creating-custom-ee-awx-phil-griffiths/ for steps, it worked like a charm for me.

Wei-Yen Tan

unread,
Apr 27, 2021, 8:52:45 AM4/27/21
to Chris Paggen, AWX Project
Hi Chris,

I followed the instructions too. I am on. awx 19. I am experiencing a different kind of error  as outlined here:



What image are yoy using? Latest one?  I get the same error as I described in the issue above. very curious if you empty the local image and start again, and see if it works for you. I will give it a go again aS things may have changed since the last time I tried. Many thanks 


From: awx-p...@googlegroups.com <awx-p...@googlegroups.com> on behalf of Chris Paggen <cpa...@gmail.com>
Sent: Wednesday, April 28, 2021 12:33:27 AM
To: AWX Project <awx-p...@googlegroups.com>
Subject: Re: [awx-project] Re: How to use galaxy in awx
 

Chris Paggen

unread,
Apr 27, 2021, 9:43:24 AM4/27/21
to Wei-Yen Tan, AWX Project
You are using a different image. I followed the steps at https://www.linkedin.com/pulse/creating-custom-ee-awx-phil-griffiths/ exactly, using Phil's image. I then tagged the image with my username in order to push it to Dockerhub.

Wei-Yen Tan

unread,
Apr 27, 2021, 2:12:10 PM4/27/21
to Chris Paggen, AWX Project
Are you referring to this one?

 
ansible-builder build --tag quay.io/philgriffiths/awx-custom-ee:latest --context ./context --container-runtime
That's the only command. That I can see is using the image being built. That's not an image when he is using a tag. That's not using his image. The tag is referring to is tagging the image that we  are building. The image is still using awx-ee:0.2.0.  Unless you are saying that there is something else....


From: Chris Paggen <cpa...@gmail.com>
Sent: Wednesday, April 28, 2021 1:43:10 AM
To: Wei-Yen Tan <weiye...@gmail.com>
Cc: AWX Project <awx-p...@googlegroups.com>

Wei-Yen Tan

unread,
Apr 27, 2021, 2:55:16 PM4/27/21
to Chris Paggen, AWX Project
What do you mean different image? 

 
ansible-builder build --tag quay.io/philgriffiths/awx-custom-ee:latest --context ./context --container-runti
The tag here is  --tag quay.io/philgriffiths/awx-custom-ee:latest is just renaming the local image that is compiled on the local machine. 

In the background it is pulling the latest version of the runner and such.

I tried using that exact line to build image 
ansible-builder build --tag quay.io/philgriffiths/awx-custom-ee:latest --context ./context --container-runtime docker
I still get this error message:

Traceback (most recent call last): File "/var/lib/awx/venv/awx/lib64/python3.8/site-packages/awx/main/tasks.py", line 1397, in run res = receptor_job.run() File "/var/lib/awx/venv/awx/lib64/python3.8/site-packages/awx/main/tasks.py", line 2957, in run return self._run_internal(receptor_ctl) File "/var/lib/awx/venv/awx/lib64/python3.8/site-packages/awx/main/tasks.py", line 3008, in _run_internal raise RuntimeError(detail) RuntimeError: Pod Running



From: Chris Paggen <cpa...@gmail.com>
Sent: Wednesday, April 28, 2021 1:43:10 AM
To: Wei-Yen Tan <weiye...@gmail.com>
Cc: AWX Project <awx-p...@googlegroups.com>

Chris Paggen

unread,
Apr 27, 2021, 3:39:46 PM4/27/21
to Wei-Yen Tan, AWX Project
Yes I used awx-custom-ee, it worked right off the bat for me. I modified requirements.yml to include my collections, that's it.

Wei-Yen Tan

unread,
Apr 27, 2021, 5:42:20 PM4/27/21
to Chris Paggen, AWX Project
Ok that's not actually using that image. That -t is a tag that you will name the image that  is built from this project:
awx-ee/Containerfile at devel · ansible/awx-ee (github.com)

if you use verbose you can see its pulling down those images from here. And its the latest ones. if we use a different image then we can use the buildargs parameter and replace 
these with our own.
ARG ANSIBLE_RUNNER_IMAGE.

I am using AWX19 ....what about you? Just trying to track the differences. Thanks!



From: Chris Paggen <cpa...@gmail.com>
Sent: Wednesday, April 28, 2021 7:39:30 AM
Reply all
Reply to author
Forward
0 new messages