0

For my initial ansible-awx setup i took my roles, inventories and playbooks and put them into one GIT-repository secured by ssh key authentication. HTTPS seems to be broken in Ansible-AWX 7.0

I imported the GIT-repository as a project into ansible-awx

I already managed to reference playbooks and inventories. How do i manage to use the roles i have inside the GIT repository?

I tried to use the following requirements.yml:

- src: ansible-awx@<some azure devops repo>
  name: hosting
  scm: git

The hosting role can not be resolved when trying to run the playbook that applies the hosting role onto my inventory.

I already tried the following:

  • Outsourcing the role into a different repo
  • Using git personal tokens inside the src

Without any success.

Help is very much appreciated.

Update: The actual setup. 1. Role is placed inside a seperate GIT Repo

/
- defaults
- files
- handlers
- meta
- tasks
- templates
- vars
  1. Role repository is added as a project with the correct credentials (SSH Key)

Resulting Error Message:

Identity added: /tmp/awx_5_kjl4ecco/artifacts/5/ssh_key_data (/tmp/awx_5_kjl4ecco/artifacts/5/ssh_key_data)
ERROR! the role 'celum-hosting' was not found in /var/lib/awx/projects/_8__cps_tc_git/playbooks/hosting/roles:/var/lib/awx/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/var/lib/awx/projects/_8__cps_tc_git/playbooks/hosting
The error appears to be in '/var/lib/awx/projects/_8__cps_tc_git/playbooks/hosting/playbook_applyhostingrole.yml': line 4, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
  roles:
    - { role: celum-hosting }
      ^ here
lt_katana
  • 11
  • 1
  • 5

1 Answers1

1

If you have a playbook in the path / of your git, the roles that that playbook needs must be located in the path /roles in the same base dir. You cannot "share" roles. That is a "problem" of Ansible. Earlier it was possible, that the working dir was the base of the search path of roles but that was a security risk and was removed. Ansible always looks for the roles folder inside the folder, where the playbook is running.

So - you cannot have a Git repository only for roles and another for playbooks in AWX, because it puts both in different locations.

Maybe - what you can do, is to put the roles repository a a Git sub-module in your playbook and in that case checkout the playbook repo will also checkout the roles repository. But in that case you can never have roles inside your playbook repo.

TRW
  • 488
  • 3
  • 16