Newbie Collections Issue

I am new to Ansible and looking to use some collections in my playbook (other than the built in ones). The issue I have is that if i run a playbook to show what collections are available, the list is a very small subset of all of the collections that appear to be available on my control plane.

If I ssh to my control plane as the user i am running ansible as ‘ansible’ and execute the command
ansible-galaxy collection list
then i get a full list of collections.

If I run the playbook below against the control plane as the user ‘ansible’ I only see about 12 collections


  • name: List All Installed Collections
    hosts: localhost
    remote_user: ansible
    gather_facts: false
    • name: Use ansible-galaxy to list collections
      command: ansible-galaxy collection list
      register: galaxy_output

    • name: Display installed collections
      var: galaxy_output.stdout_lines

If I check the ansible config on the host with
ansible-config list
I can see that the COLLECTIONS_PATHS default is as I’d expect and if i check those locations i see all collections.

I’m running ansible v2.10.8

Whatever i do i can’t get my playbook to see all collections. Am I fundamentally misunderstanding how this should work?

Are the collections only accessible to the ansible user? The implicit localhost uses the local connection which doesn’t use the remote_user.

You could use become plugins:

- hosts: localhost
  become: yes
  become_user: ansible  # default is root
  become_method: sudo  # default become plugin

Available become methods can be listed with ansible-doc --list -t become and options seen with ansible-doc -t become $PLUGIN.

1 Like