How to use galaxy in awx

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.

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:

Thanks.

one more quick clarification. can we use different source in requirements.yaml file for SCM project?

Well,

According to the docs, yes. You can install collections from a private Git repository if needed.
https://docs.ansible.com/ansible/devel/user_guide/collections_using.html#installing-a-collection-from-a-git-repository

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

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

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.

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.

Have a look at my example here: https://github.com/ffirg/tower_collection_example

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

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?

Hello,

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

No access outside.

Regards,
Vibin

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](https://bitbucket.org/willthames/git-ansible-galaxy)
  version: v1.4

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

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

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

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?

Guess, its because the format what we are giving in requirements.yml is not being recognized in ansible version 2.9

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:

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.

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.