Ansible.windows vs community.windows and how to remove a collection?

I am confused by both of them. I have been installing both as I am not sure if they are the same thing or different. I assume different now because ansible.windows is version 2.2.0 and community.windows is 2.1.0. I installed both of them using ansible.galaxy but recently tried to remove community.windows because it was older but even after rm -rf ~/.ansible/collections/ansible_collections/community , I still see it with ansible-galaxy collection list.

So which should we be using and how do you remove a collection properly? Or are both ansible.windows and collection.windows somehow tied together?

This is on Rocky Linux 9.3 fully updated.

ansible-galaxy collection list

ansible.posix 1.5.4
ansible.windows 2.2.0
community.general 7.2.1
community.windows 2.1.0

[ansible@ode-ansible02 ]$ ansible --version
ansible [core 2.14.9]
config file = /etc/ansible/ansible.cfg
configured module search path = [‘/home/ansible/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.9.18 (main, Sep 7 2023, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True

I only have ansible-core installed from the OS/Stream packages.
[ansible@ode-ansible02 ]$ rpm -qa|grep ansible
ansible-core-2.14.9-1.el9.x86_64

I also used pip to install pywinrm

Hi,

I am not sure if they are the same thing or different

Not the same thing, but some modules / plugins could potentially overlap, or so it seems. I’d say they are complementary.
In a more general sense, community collections are supported by community; a fair amount of them are shipped with Ansible package (ansible-core + bells and whistle).

Now ansible.windows doesn’t seem to be builtin (maintained by core devs), but it sure looks like it; difference is you can’t list or properly remove Ansible builtin collections.
At least that’s my comprehension of it; someone please correct me if I’m wrong.

how do you remove a collection properly?

I don’t know if there’s a proper way to do it, but ansible-galaxy doesn’t seem to have a corresponding parameter. Removing the folder corresponding to collection namespace is a good option IMO (and does work on my end).

Now for your issue, I think there might be a mismatch somewhere on your collections paths. Could you run those commands:

  • ansible-config dump | grep COLLECTIONS_PATHS
  • ansible-galaxy collection list | grep -E '^#'

(and yes, I know ansible --version indicates collections paths on “ansible collection location” line, but there might be some setups when it doesn’t show the correct paths)

I only have ansible-core installed from the OS/Stream packages.
[ansible@ode-ansible02 ]$ rpm -qa|grep ansible
ansible-core-2.14.9-1.el9.x86_64

Seems weird. You should have ansible package installed, not only ansible-core, as you are listing community collections with ansible-galaxy, which would not be available with ansible-core alone AFAIK.

Perhaps you installed it with pip instead, so assuming you don’t use a venv, you could check by running: pip list installed | grep -i ansible (even though ansible --version shows binary to be located in /usr/bin, so I highly doubt it). which ansible and update-alternatives --list ansible might also hint us.

Also note collections paths could be defined in an ansible.cfg config file, which could point to other locations depending on where you ran your commands from.

[ansible@ode-ansible02 ~]$ ansible-config dump | grep COLLECTIONS_PATHS
COLLECTIONS_PATHS(default) = [‘/home/ansible/.ansible/collections’, ‘/usr/share/ansible/collections’]

[ansible@ode-ansible02 ~]$ ls /home/ansible/.ansible/collections/ansible_collections/
ansible ansible.windows-2.1.0.info
ansible.posix-1.5.4.info ansible.windows-2.2.0.info
ansible.windows-1.12.0.info community
ansible.windows-1.14.0.info community.general-7.2.1.info
ansible.windows-2.0.0.info

[ansible@ode-ansible02 ~]$ pip list installed
Package Version


ansible-core 2.14.9
Babel 2.9.1
certifi 2022.6.15
cffi 1.14.5
charset-normalizer 2.1.1
cryptography 36.0.1
dbus-python 1.2.18
gpg 1.15.1
idna 3.3
Jinja2 2.11.3
libcomps 0.1.18
MarkupSafe 1.1.1
nftables 0.1
ntlm-auth 1.5.0
packaging 20.9
pip 21.2.3
ply 3.11
pycparser 2.20
PyGObject 3.40.1
pyparsing 2.4.7
python-dateutil 2.8.1
pytz 2021.1
pywinrm 0.4.3
PyYAML 5.4.1
requests 2.28.1
requests-ntlm 1.1.0
resolvelib 0.5.4
rpm 4.16.1.3
selinux 3.5
setuptools 53.0.0
six 1.15.0
systemd-python 234
urllib3 1.26.12
xmltodict 0.13.0

I was able to remove the community stuff using rm -Rf ~/.ansible/collections/ansible_collections/community* . I now only see ansible.posix and ansible.windows.

Still not clear to me community.windows vs ansible.windows. They both seem to have the same plugins just looking at them manually (before I removed community stuff). Anyone else know for sure how that works? Does ansible pull in community.windows into ansible.windows occasionally or vice versa?

Take a look at the documentation:

As you can see they have quite a different set of modules and plugins. Also community.windows has ansible.windows listed as a dependency (https://github.com/ansible-collections/community.windows/blob/main/galaxy.yml#L14), so if you install community.windows, ansible-galaxy collection install will also make sure that ansible.windows is present (but not the other way around).

1 Like

Thanks. I must have been looking at the wrong list of plugins in community. They are different. I at first thought win_updates was in both community.windows and ansible.windows.

Thanks for clearing that up for me.