Score:2

How to use collections in Ansible Tower

fr flag

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

Score:2
th flag

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
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.