1

I use a plugin such as nginx in ansible playbook.

https://galaxy.ansible.com/nginxinc/nginx_core

On server I can use cli to install the roles and collections as

ansible-galaxy collection install nginxinc.nginx_core

But how can I install it on AWX(Tower)?

I tried to run the command in one of AWX container - awx-ee (others are awx-web, awx-task, redis). When run a template in AWX, it still caused a role not found error.

Zeitounator
  • 38,476
  • 7
  • 53
  • 66
freetimetime
  • 13
  • 1
  • 4
  • 1
    https://docs.ansible.com/ansible-tower/latest/html/userguide/projects.html#collections-support. In short: create a `collections/requirements.yml` file in your project. Awx will detect it and run the needed `ansible-galaxy` command for you. Make sure that collection download has not been disabled in your awx/tower settings. – Zeitounator Mar 02 '22 at 11:14
  • @Zeitounator I use a role from ansible galaxy. I created a roles/requirements.yml and set this into it: `- src: dev-sec.mysql`. Then sync project in AWX to get new source from github. But run template got error: `ERROR! could't resolve module/action 'zypper_repository'. This often indicates a misspelling, missing collection, or incorrect module path.`. I'm using AWX 19.5.1. How to check which ansible version in the AWX containers? – freetimetime Mar 03 '22 at 09:49

1 Answers1

1

In addition to @Zeitounator comment, you could also manually install your collection into a dedicated path (i.e into collections folder from awx directory)

If you use a requirements.yml file :

sudo -u awx_user ansible-galaxy collection install -r /var/lib/awx/projects/my_project/collections/requirements.yml -p /var/lib/awx/projects/my_project/collections

or manually

ansible-galaxy collection install ansible.my_collection -f
'/home/.ansible/collections/ansible_collections/ansible/my_collection'
motorbass
  • 168
  • 6
  • Messing manually with ansible-galaxy inside the awx/tower containers is not a good advice to give to anyone IMO. Moreover, I strongly doubt those containers will have sudo installed. – Zeitounator Mar 02 '22 at 14:15
  • Thanks. I think @Zeitounator 's method is better. If install role but not collection, is it right to create a `roles/requirements.yml` file and put galaxy roles there? – freetimetime Mar 03 '22 at 00:10
  • i didn't saw it was about container. my mistake... i had these 2 commands in my notebook cause i had issues with awx/ansible/ansible core while installing collection (when your server have only a limited access to internet) ;) – motorbass Mar 03 '22 at 06:34
  • @freetimetime: this is explained a few paragraphs above in the documentation link I already shared. – Zeitounator Mar 03 '22 at 08:54