How to use collections in Ansible Tower

We're using Ansible Tower 3.7.4 which has Ansible 2.9.13, we also have 'theforeman' ansible collection installed.

My test playbook is

---
- name: Test foreman roles
  hosts: localhost
  become: false
  gather_facts: false

  tasks:

  - add_host:
      name: victim.local
      group: my_inv

- name: Test foreman roles
  hosts: my_inv
  become: false
  gather_facts: false

  tasks:

  - theforeman.foreman.host:
      server_url: "https://foreman-server.local"
      username: "admin"
      password: "password"
      parameters:
        name: "param_name"
        value: "param_value"
        parameter_type: "string"
    delegate_to: localhost

It doesn't matter if I use 'theforeman.foreman.host' or just 'host', both report "ERROR! couldn't resolve module/action"

The locate command shows me the installed path:

locate theforeman | grep host
/var/lib/awx/vendor/inventory_collections/ansible_collections/theforeman/foreman/plugins/modules/foreman_host.py
/var/lib/awx/vendor/inventory_collections/ansible_collections/theforeman/foreman/plugins/modules/foreman_host_power.py
/var/lib/awx/vendor/inventory_collections/ansible_collections/theforeman/foreman/plugins/modules/foreman_hostgroup.py
/var/lib/awx/vendor/inventory_collections/ansible_collections/theforeman/foreman/plugins/modules/katello_host_collection.py

And I've put this in the ansible.cfg file:

grep collections /etc/ansible/ansible.cfg
collections_paths = /var/lib/awx/vendor/inventory_collections/ansible_collections

How do I use an already installed collection?

Thanks


Solution 1:

ansible_collections is part of the directory structure underneath collection paths, and should not be included in the search path.

collections_paths = /var/lib/awx/vendor/inventory_collections