Thanks for your response.  I will test doing simple folder deletion in a 
test environment before I try it in production.  

An example of why we want to make sure that we are running a particular 
version is that there have been bug fixes in a newer version of the 
ansible.windows collection to fix issues with the win_updates module.  With 
the previous version of ansible.windows, we had a lot of issues with the 
win_updates module hanging with errors on a Windows server and never 
recovering.  So, we would then have to stop the playbook and rerun, hoping 
that it would run cleanly.  By making sure that there is no chance of 
Ansible using the older version, we are guarding against the having 
playbook runs fail due to those bugs.  Those failures were costly because 
some of those playbook runs are in tight maintenance windows. 

I know that we can set the collections path in ansible.cfg to avoid Ansible 
using the wrong version.  But we still want to remove the collections that 
are duplicated and don't need to be there in order to have a cleaner 
environment.  The cleaner it is, the easier it is for everyone to maintain.

On Tuesday, September 19, 2023 at 1:25:09 AM UTC-6 Romain Pelisse wrote:

> Generally, I simply do a "$ rm -rf 
> /home/user/.ansible/ansible_collections/" to force a collection refresh. 
> You can also just remove like that, the collection causing issues.
>
> Another strategy is to force the installation, using --force, which will 
> remove the old version and install the new latest one.
>
> That beings said, I don't think there is a risk of running the wrong 
> version. The presence of different version is probably because one 
> collection depends on version X and another one depends on version Y. So 
> the first one will use X and the second will use Y.
>
> On Tue, Sep 19, 2023 at 1:41 AM 'Eric Jolley' via Ansible Project <
> ansible...@googlegroups.com> wrote:
>
>> Hello All,
>>
>> I have an Ansible server with collections that are stored under a user 
>> context in "/home/user/.ansible/ansible_collections/" in addition to the 
>> collections for all users that are stored in 
>> "/usr/lib/python3/dist-packages/ansible_collections/".  I found that there 
>> are some duplicates of collections, such as "ansible.windows" that are 
>> different versions.  In order to mitigate the risk of running playbooks 
>> using the wrong version of a collection, I want to remove the collections 
>> that are installed under a user context.  
>>
>> Unfortunately, I found that there isn't a remove argument for 
>> "ansible-galaxy collection".  And I didn't find anything in the Ansible 
>> documentation or anything definitive in this Google group, nor doing Google 
>> searches or ChatGPT. It is possible that deleting the specific folders 
>> under /home/user/.ansible/ansible_collections/ would work.  But I don't 
>> know if that could have unintended consequences.  So, I would like to get 
>> some confirmation from anyone who has experience with this or knows where 
>> it is documented.  
>>
>> Does anyone know what the best practice is for removing installed 
>> collections?
>>
>> Also, I have submitted an issue for the correct method to be documented 
>> at:  
>> https://docs.ansible.com/ansible/latest/collections_guide/index.html#using-ansible-collections.
>>   
>> It will probably take a while for that issue to be taken on and resolved 
>> though.
>>
>> Best regards,
>> Eric
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible-proje...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/490f79e1-c2c2-48bf-99e4-fddea5bebe2an%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/490f79e1-c2c2-48bf-99e4-fddea5bebe2an%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2991ad55-9062-4ef7-a8b7-8a22a15e1ec4n%40googlegroups.com.

Reply via email to