AAP 2.5 role not found

Please replace this text with a description of your issue. You should:

  • My company is running AAP 2.5. We are in the process of standing it up. Getting closer day by day. However I am trying to test some roles now.
  • I am using the fedora.linux-system-roles in the requirments.yml and common collections as well
    Here is the error i’m getting. I have a ticket with support open. They suggested I make some changes to the role itself.
ERROR! the role 'config_adjoin' was not found in /runner/project/tests/roles:/runner/requirements_roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/runner/project/tests

The error appears to be in '/runner/project/tests/test.yml': line 6, column 7, but may

be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  roles:
    - config_adjoin
      ^ here

The changes the support rep suggested was to create a folder called roles and move everything under there and then create a playbook.yml to call the role. I’ve also read to put a ansible.cfg in each role.

Any thoughts?

I don’t have AAP myself but it seems like people come here with questions about it frequently.

Looks like this collection here Ansible Galaxy is your collection, right? Not sure why your support rep is telling you to rearrange your roles folder. As far as I know, you need your requirements.yml in a folder named collections at the base of your code repository. This is aside from things that might be affecting it like internet access, referencing an internal proxy mirror, etc.

So I have a requirements.yml file. I had it in there. It still flipped out and gave me the same error. I feel like the roles path should be an easy fix, right?

Hi @Fracture7144

You have two options:

  • Have the role installed in your execution environment that the Job Template is using.
  • As you already have the requirements.yml at the root of your project, can you confirm that the role is being installed at runtime when the Job starts?

Assuming you have your Automation Hub credentials configured and this role is staged in your Automation Hub?

So thi is AAP on-prem. I believe the role is installed in the correct execution environment. I am using the default. I’m not sure I configured automation hub credentials.

Is config_adjoin a role in a collection, or is it a standalone role? Is the role defined in the project itself, or was a custom EE built which contains the role?

You can debug the available roles by running a playbook like this in the execution environment:

- hosts: localhost
  gather_facts: no
  tasks:
    - name: List available roles
      shell: "{{ ansible_playbook_python }} $(command -v ansible-doc) --playbook-dir . -t role --list --json"
      args:
        chdir: "{{ playbook_dir }}"
      environment:
        ANSIBLE_CONFIG: "{{ lookup('config', 'CONFIG_FILE') }}"
      register: ansible_doc_roles

    - name: Display role count
      debug:
        msg: "Found {{ ansible_doc_roles.stdout | from_json | length }} roles"

    - name: Display role names
      debug:
        msg: "{{ item }}"
      loop: "{{ (ansible_doc_roles.stdout | from_json).keys() | list }}"

I’ve also read to put a ansible.cfg in each role.

Ansible can’t be configured mid play, and only supports 1 ansible.cfg file. Not sure where you saw this, but don’t do that.

I’m not sure why you’d need an ansible.cfg at all. You’d only need to configure the roles path if the role isn’t installed in the EE and is defined in a non-standard project path.

Here’s an example layout of roles defined in the project (instead of installed in the EE) that will be located without special configuration:

project_root/
└── playbooks
    ├── collections
    │   └── ansible_collections
    │       └── ns
    │           └── col
    │               └── roles
    │                   └── collection_role
    │                       ├── meta
    │                       │   └── main.yml
    │                       └── tasks
    │                           └── main.yml
    ├── roles
    │   └── standalone_role
    │       ├── meta
    │       │   └── main.yml
    │       └── tasks
    │           └── main.yml
    └── test.yml

Hi thanks for your response. config_adjoin is a standalone role. It is defined in a project. I did use the template that red hat provided and improved upon that.

This is what a rh support engineer had me structure the role like:
**


**

I’m confused at what I’m looking at. Is that the project root? I don’t see the tests/test.yml playbook. The roles/ directory containing a requirements.yml seems odd. If you’re working with RH support, then it would be better to follow up there and as support for clarification.

Correct. This is the project root. I just didn’t show all the files and whatnot for security reasons. They suggested that I do this. I’m asking here, because honestly it seemed a bit strange that with the default file layout I couldn’t make AAP 2.5 on-prem get the job done. We were also having issues with isolated job paths.

Try adding an ansible.cfg in the project root that contains

[defaults]
roles_path=./

ok, but I shouldn’t have to do that with each role, right?

Not unless the role isn’t in any of the already configured (or default) role directories. The ansible.cfg is optional. If the playbook was in the project root (i.e. test.yml instead of tests/test.yml), then roles in the project’s root directory (and any in roles/) would be picked up automatically.

If config_adjoin is the role, move that directory to the roles directory under CONFIGE_ADJOIN.

That’s not in the search path in the error message either.

ERROR! the role ‘config_adjoin’ was not found in /runner/project/tests/roles:/runner/requirements_roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/runner/project/tests

Since the playbook is in tests/, the playbook-relative roles paths are /runner/project/tests/roles and /runner/project/tests.

This is what I have configured in my “Paths to expose isolated jobs”

Not sure if this is going to help resolve my issue.