Manually install collection on airgapped system

I would like to use the ansible.posix collection in my projects. I have been reading ansible docs, searching these forums and searching the internet, but I cannot seem to figure out what is going wrong. I am using this as my ansible.cfg:

[defaults]
inventory      = ./inventory.ini
library        = ./modules
roles_path     = ./roles
collections_path = ./collections
interpreter_python = auto_silent
gathering = smart
host_key_checking = False
stdout_callback = debug
callback_whitelist = timer, profile_roles
# SSH timeout
timeout = 10
log_path = ../../ansible.log
deprecation_warnings = True
retry_files_enabled = False

I have done the following to install the collection:

  • Downloaded the tarball
  • extracted to a temp dir
  • created ./collections/ansible-collections/community dir in my project dir (next to my playbook)
  • moved ansible.posix dir below the community dir. This dir holds the docs, meta, plugins dir (amongst the other content of course)

I create a playbook and call the collection as follows:

    - name: Set authorized key taken from file
      ansible.posix.authorized_key:

The error appears:

ERROR! couldn't resolve module/action 'ansible.posix.authorized_key'. This often indicates a misspelling, missing collection, or incorrect module path.

I moved the ansible.posix to:

  • ./collections
  • ./collections/ansible-collections/

But I keep getting this error. I tried different modules like ansible.posix.mount, it’s another one I’d like to use but it throws the same error.

I’m sure it must be something silly, but I don’t see what I’m doing wrong here?

Any help please?

Thanks in advance!

1 Like

Hey, do you have tryed the FQCN in your playbook?

Thanks.

That wasn’t the complete playbook, just the play that calls the module.

The playbook looks like this:

---
- hosts: name_as_specified_in_inventory
  gather_facts: true
  become: false
  tasks:
    - name: etc

With other plays and built-in modules the playbook runs correctly. Hosts are reachable.

I’ll test it myself and report back

Hey, so i tried it and for me it works.

Your collections_paths is set correct but your directory structure seems wrong.
It should be collections/ansible_collections/<namespace>/<module>.
in your case it should be collections/ansible_collections/ansible/posix

when you now try your playbook and give it a go with -vvv you see the collection path it uses: Using module file <my_dir>/collections/ansible_collections/ansible/posix/plugins/modules/authorized_key.py

also please dont extract the tar.gz your self thats seems laborious. Instead use ansible: ansible-galaxy collection install ansible-posix-1.5.4.tar.gz -p ./collections that way you get a correct directory structure.

please let me know if this works for you :slight_smile:

Best Regards

4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.