using modules in library folder from galaxy installed role

Hello,

I’m a beginner with AWX. I’m trying to use pcs-modules-2, a role which is meant to be included as a dependency. It contains a library folder with some custom Ansible modules (pcs_resource.py, pcs_property.py etc.). In a normal ansible-playbook run that references these modules, this works (obviously), but when I try it in AWX, the modules are not found (ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.). Is this supposed to work? Do I need to adjust a setting?

Thanks,

The requirements.yml file should be processed when the project is synced. Can you look at the sync job for the project to see if there were any errors in there?

-John

Hello,

Thanks for your answer. When I sync the project, the requirements file is not processed, the task is not executed:

TASK [fetch galaxy roles from requirements.yml] ********************************
skipping: [localhost,] => {“changed”: false, “skip_reason”: “Conditional result was False”}

I double-checked and ‘enable role download’ is on in settings → jobs. To test I commented the “when” clause in the task in project_update.yml, but it would hang on the ‘detect requirements.yml’ task. So I commented that task too and it complained about the roles_destination variable not being set. So I set a default value. The final task block that will sync the roles on a project update looks like this:

  • hosts: all
    gather_facts: false
    tasks:

  • block:
    #- name: detect requirements.yml

stat: path={{project_path|quote}}/roles/requirements.yml

register: doesRequirementsExist

  • name: fetch galaxy roles from requirements.yml
    command: ansible-galaxy install -r requirements.yml -p {{roles_destination|default(‘.’)|quote}}{{ ’ -’ + ‘v’ * ansible_verbosity if ansible_verbosity else ‘’ }}
    args:
    chdir: “{{project_path|quote}}/roles”
    register: galaxy_result
    #when: doesRequirementsExist.stat.exists
    changed_when: “‘was installed successfully’ in galaxy_result.stdout”
    environment:
    ANSIBLE_FORCE_COLOR: False

#when: roles_enabled|bool
delegate_to: localhost

All roles are now in the project directory, /var/lib/awx/projects/_9__endpoints/roles, I believe that’s correct.

Unfortunately it didn’t make a difference for the job:

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The playbook until the task triggering that error:

Does anyone have any ideas? Should I file one or more bugs for this?

Are you on the latest version of AWX? Does your project have a file at roles/requirements.yml, relative to the root of the project? Are you looking at the right project update? If you have requirements in your project, then any jobs ran from it should run a sync before the job starts, which links as a green circle next to the name of the project in the UI. The job type for that project update should be “run”.

Hello

Are you on the latest version of AWX?

I just upgraded from 9.0.1 to 9.1.0 and tested again. Same results.

Does your project have a file at roles/requirements.yml, relative to the root of the project?

Yes

Are you looking at the right project update? If you have requirements in your project, then any jobs ran from it should run a sync before the job starts, which links as a green circle next to the name of the project in the UI. The job type for that project update should be “run”.

OK, I see that the role is installed during a job run in /tmp/awx_44_zrvcyiut/requirements_roles/ondrejhome.pcs-modules-2

This is the tree structure of that role:

ondrejhome.pcs-modules-2
│ ├── library
│ │ ├── detect_pacemaker_cluster.py
│ │ ├── pcs_auth.py
│ │ ├── pcs_cluster.py
│ │ ├── pcs_constraint_colocation.py
│ │ ├── pcs_constraint_location.py
│ │ ├── pcs_constraint_order.py
│ │ ├── pcs_property.py
│ │ ├── pcs_resource_defaults.py
│ │ └── pcs_resource.py
│ ├── LICENSE
│ ├── LICENSE-APACHE2.txt
│ ├── LICENSE-GPLv3.txt
│ ├── meta
│ │ └── main.yml
│ ├── README.md
│ └── tests
│ ├── inventory
│ └── test.yml

I still get “ERROR! no action detected in task.” on the first task referencing one of those modules.

Then I don’t know quite what is going wrong. Since you reference a public github repository where the role is hosted, you should be able to reduce your content into a minimal reproducer so that you can share your playbook and requirements.yml file contents without exposing any confidential information. I would try to reproduce the error with that, because I’m interested in some better reference cases for SCM roles. Also, Ansible version could be relevant.

I’m sorry, this was user error. It works the same way as in ‘regular’ Ansible: I have to declare the role in the play (roles: - { role: ondrejhome.pcs-modules-2 } ) before I can actuaIly use it. I thought include_role of another role that had pcs-modules-2 as a dependency would allow me to use it in subsequent tasks in the same play. I don’t know how I missed that. Found out when trying to put together the reproducer.