Ansible-galaxy not working with sudo

ansiblesudo

I'm having problems instaling plugins with ansible-galaxy.

I've tried 3 things:

Instaling without sudo:

ansible-galaxy install sfromm.epel
[WARNING]: - sfromm.epel was NOT installed successfully: Could not update files in /etc/ansible/roles/sfromm.epel: [Errno 13] Permission denied: '/etc/ansible/roles/sfromm.epel'

Nothing weird here, obviously my user can't write in that folder.


Instaling with sudo su:

$ sudo su
root@notebook# ansible-galaxy install  sfromm.epel 
- ...
- sfromm.epel was installed successfully

As you can see I'm able to install the plugin this way.


Instaling with sudo:

Here is where I don't understand what is happening.

$ sudo ansible-galaxy install  sfromm.epel
[WARNING]: - sfromm.epel was NOT installed successfully: The API server (https://galaxy.ansible.com/api/) is not responding, please try again later

sudo curl https://galaxy.ansible.com/api/ responds OK. I'm not behind a proxy.

Could it be a problem with certificates since the API is https? How can I know where does ansible pick those from?

Best Answer

I'm seeing the same thing. I worked around it by setting ansible_roles=~/.ansible/roles in my ~/.ansible.cfg file and installing the roles without the need for sudo. Does installing them in a system-wide even make sense in most cases? Still, it's annoying and worked in previous versions of ansible (I'm using 2.1.0.0).