# ansible-galaxy fails to install roles the second time

**URL:** <https://forum.ansible.com/t/ansible-galaxy-fails-to-install-roles-the-second-time/34430>\
**Category:** Ansible Project\
**Tags:** galaxy-ng\
**Created:** [January 13, 2021, 11:40am UTC](https://forum.ansible.com/t/ansible-galaxy-fails-to-install-roles-the-second-time/34430 "2021-01-13T11:40:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Riain\_Condon](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@Riain\_Condon](https://forum.ansible.com/u/Riain_Condon)\
**Post date:** [January 13, 2021, 11:40am UTC](https://forum.ansible.com/t/ansible-galaxy-fails-to-install-roles-the-second-time/34430/1 "2021-01-13T11:40:53Z")

</div>

Hi,

I’m using Ansible Galaxy v2.9.15 and attempting to install roles. This is all run as part of a Jenkins pipeline so ansible-galaxy is used across several jobs all installing the same central roles when they’re run.

Here’s essentially what’s happening:

- ansible-galaxy -vvv install --force git+[https://stash/ansible.digital.roles.git,develop](https://stash/ansible.digital.roles.git,develop) ansible-galaxy 2.9.15

config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/home/jenkins-slave/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /usr/bin/ansible-galaxy  
python version = 2.7.5 (default, Aug 13 2020, 02:51:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]  
Using /etc/ansible/ansible.cfg as config file  
Opened /home/jenkins-slave/.ansible/galaxy\_token

Processing role ansible.digital.roles

- changing role ansible.digital.roles from develop to develop

archiving [u’/usr/bin/git’, ‘archive’, u’–prefix=ansible.digital.roles/‘, u’–output=/home/jenkins-slave/.ansible/tmp/ansible-local-5372Tp6n8A/tmpySnNvS.tar’, u’develop’]

- extracting ansible.digital.roles to /home/jenkins-slave/.ansible/roles/ansible.digital.roles

[WARNING]: - ansible.digital.roles was NOT installed successfully: /home /jenkins-slave/.ansible/roles/ansible.digital.roles doesn’t appear to contain a role. please remove this directory manually if you really want to put the role here. ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.

So, this error occurs and if I then re-run this after deleting the ansible.digital.roles directory manually, it works fine. However, re-running again after it succeeds ends up with the above error again.

Does anyone know a solution/work around? Is using --ignore-errors a safe way to workaround this or could it end up masking other errors down the line?

Thanks,  
Riain

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [January 13, 2021, 11:50am UTC](https://forum.ansible.com/t/ansible-galaxy-fails-to-install-roles-the-second-time/34430/2 "2021-01-13T11:50:41Z")

</div>

> Hi,
> 
> I'm using Ansible Galaxy v2.9.15 and attempting to install roles. This is all run as part of a Jenkins pipeline so  
> ansible-galaxy is used across several jobs all installing the same central roles when they're run.
> 
> Here's essentially what's happening:
> 
> + ansible-galaxy -vvv install --force git+[https://stash/ansible.digital.roles.git,develop](https://stash/ansible.digital.roles.git,develop)  
> \<[https://stash/ansible.digital.roles.git,develop&gt](https://stash/ansible.digital.roles.git,develop&gt); ansible-galaxy 2.9.15
> 
> config file = /etc/ansible/ansible.cfg  
> configured module search path = [u'/home/jenkins-slave/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']  
> ansible python module location = /usr/lib/python2.7/site-packages/ansible  
> executable location = /usr/bin/ansible-galaxy  
> python version = 2.7.5 (default, Aug 13 2020, 02:51:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]  
> Using /etc/ansible/ansible.cfg as config file  
> Opened /home/jenkins-slave/.ansible/galaxy\_token
> 
> Processing role ansible.digital.roles  
> - changing role ansible.digital.roles from develop to develop
> 
> archiving [u'/usr/bin/git', 'archive', u'--prefix=ansible.digital.roles/',  
> u'--output=/home/jenkins-slave/.ansible/tmp/ansible-local-5372Tp6n8A/tmpySnNvS.tar', u'develop']  
> - extracting ansible.digital.roles to /home/jenkins-slave/.ansible/roles/ansible.digital.roles
> 
> [WARNING]: - ansible.digital.roles was NOT installed successfully: /home  
> /jenkins-slave/.ansible/roles/ansible.digital.roles doesn't appear to contain a role. please remove this directory  
> manually if you really want to put the role here. ERROR! - you can use --ignore-errors to skip failed roles and finish  
> processing the list.
> 
> So, this error occurs and if I then re-run this after deleting the ansible.digital.roles directory manually, it works  
> fine. However, re-running again after it succeeds ends up with the above error again.
> 
> Does anyone know a solution/work around? Is using --ignore-errors a safe way to workaround this or could it end up  
> masking other errors down the line?
> 
> Thanks,  
> Riain

Hello Riain,

why don't you remove the target directory before running the ansible-galaxy install?

With using --force it downloads and overwrites the files in the target directory anyway.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Riain\_Condon](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@Riain\_Condon](https://forum.ansible.com/u/Riain_Condon)\
**Post date:** [January 13, 2021, 12:04pm UTC](https://forum.ansible.com/t/ansible-galaxy-fails-to-install-roles-the-second-time/34430/3 "2021-01-13T12:04:03Z")

</div>

Hey Racke,

Thanks for the quick reply! That’s a great and simple idea, thanks! I suppose as we are overwriting it anyway it probably would have the same effect on other jobs running.

That being said, is there a way to set the role installation directory on the fly? It might make more sense to install it to the job’s directory and clean that each time, rather than a central directory, if that makes sense.

Thanks again,  
Riain

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [January 13, 2021, 12:09pm UTC](https://forum.ansible.com/t/ansible-galaxy-fails-to-install-roles-the-second-time/34430/4 "2021-01-13T12:09:40Z")

</div>

> Hey Racke,
> 
> Thanks for the quick reply! That's a great and simple idea, thanks! I suppose as we are overwriting it anyway it  
> probably would have the same effect on other jobs running.
> 
> That being said, is there a way to set the role installation directory on the fly? It might make more sense to install  
> it to the job's directory and clean that each time, rather than a central directory, if that makes sense.
> 
> Thanks again,  
> Riain

Hello Riain,

yes it makes sense to install it in the job directory. You can tell Ansible where to look for roles, so that should be  
no problem.

Also if you retrieve the role from a git repository, it probably behaves in the same way when you using git to install  
the role.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Riain\_Condon](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@Riain\_Condon](https://forum.ansible.com/u/Riain_Condon)\
**Post date:** [January 13, 2021, 12:34pm UTC](https://forum.ansible.com/t/ansible-galaxy-fails-to-install-roles-the-second-time/34430/5 "2021-01-13T12:34:37Z")

</div>

Great 😃 thanks a mill, Racke. Just did this and works perfect.

Thanks again,  
Riain
