Location of collections

Hello, eveybody.

On all of my Ubuntu hosts the location of my collections is ~/.ansible/collections/ansible_collections/

On one of my hosts there is an additional location at /usr/lib/python3/dist-packages/ansible_collections/

How come this one host has collections in two places and what does Python have to do with it?

Thank you.

@ioan Hello!

~/.ansible/collections/ansible_collections/ is the default location where ansible-galaxy collection install command install to.

And /usr/lib/python3/dist-packages/ansible_collections/ is the location where installed collections by ansible community package (ansible-core and collections).

~/.ansible/collections/ansible_collections/ is the preferred search target for the collection.

2 Likes

Thank you.

The host with two locations for the collections is a laptop that currently shows the following:

user@laptop:~$ ansible --version
ansible [core 2.12.10]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Nov 22 2023, 10:22:35) [GCC 9.4.0]
  jinja version = 2.10.1
  libyaml = True

At some point I installed the ansible package with the apt install ansible command.

On another host I executed once apt install ansible and got an Ansible version 2.10.8. Since I wanted a newer one, I uninstalled the ansible package and installed the ansible-core package with apt install ansible-core command, which got me Ansible [core 2.16.4].

So I am assuming that I did the same on the laptop, as well and that the /usr/lib/python3/dist-packages/ansible_collections is a leftover from executing the apt install ansible command. What do you think? Does this make sense?

Any idea how to properly remove the /usr/lib/python3/dist-packages/ansible_collections directory?

@ioan Thank you for the information.

as well and that the /usr/lib/python3/dist-packages/ansible_collections is a leftover from executing the apt install ansible command.

I think yes.

If you don’t need ansible(-base) 2.10.8 installed by apt install ansible, you can remove /usr/lib/python3/dist-packages/ansible and /usr/lib/python3/dist-packages/ansible_collections diretory by apt remove ansible.

1 Like

Thank you, dear Akira.

Your advice worked.

Due to some experience with another host, I thought that the ansible and ansible-core packages could not be installed simulatenously. It turns out that, actually, these two were installed at the same time on my laptop, hence the two ansible_collections directories.

1 Like

ansible >= 3.0.0 and ansible-core can be installed at the same time. Actually if you install ansible >= 3.0.0, it will always install ansible-core as a dependency.

2 Likes

Thank you, Felix.

I appreciate it.