Ansible Galaxy error “list index out of range” during role installation

ERROR! Unexpected Exception, this is probably a bug: list index out of range

was the message I was met with when recently tried using ansible-galaxy.  I decided to use Ansible for a Jenkins project instead of Puppet because a role for Jenkins v2 already exists on Ansible Galaxy.

The error

When I attempted to install the Jenkins role using the ansible-galaxy command into my home directory I received what looks like a programming error.

$ ansible-galaxy install geerlingguy.jenkins
- downloading role 'jenkins', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-jenkins/archive/3.2.2.tar.gz
- extracting geerlingguy.jenkins to /etc/ansible/roles/geerlingguy.jenkins
- extracting geerlingguy.jenkins to /usr/share/ansible/roles/geerlingguy.jenkins
ERROR! Unexpected Exception, this is probably a bug: list index out of range
to see the full traceback, use -vvv

list index out of range usually means something internal failed in a bad way.

The solution

Turning to Google, I found https://github.com/ansible/galaxy/issues/149.   Basically, ansible-galaxy does not take into which account is running the ansible-galaxy command.  It reads the ansible configuration file and uses the defined directory.  This results in ansible-galaxy wanting to write to /etc/ansible which a regular user account cannot write to.

Using the -p flag I was able to my home directory and install the role.

$ ansible-galaxy install -vvv -p /home/example/src/ansible/jenkins/roles geerlingguy.jenkins
ansible-galaxy 2.4.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/example/.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 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Using /etc/ansible/ansible.cfg as config file
Opened /home/example/.ansible_galaxy
Processing role geerlingguy.jenkins
Opened /home/example/.ansible_galaxy
- downloading role 'jenkins', owned by geerlingguy
https://galaxy.ansible.com/api/v1/roles/?owner__username=geerlingguy&name=jenkins
https://galaxy.ansible.com/api/v1/roles/440/versions/?page_size=50
- downloading role from https://github.com/geerlingguy/ansible-role-jenkins/archive/3.2.2.tar.gz
- extracting geerlingguy.jenkins to /home/example/src/ansible/jenkins/roles/geerlingguy.jenkins
- geerlingguy.jenkins (3.2.2) was installed successfully
- adding dependency: geerlingguy.java
Processing role geerlingguy.java
Opened /home/example/.ansible_galaxy
- downloading role 'java', owned by geerlingguy
https://galaxy.ansible.com/api/v1/roles/?owner__username=geerlingguy&name=java
https://galaxy.ansible.com/api/v1/roles/439/versions/?page_size=50
- downloading role from https://github.com/geerlingguy/ansible-role-java/archive/1.7.4.tar.gz
- extracting geerlingguy.java to /home/example/src/ansible/jenkins/roles/geerlingguy.java
- geerlingguy.java (1.7.4) was installed successfully

 

Leave a Reply

Your email address will not be published. Required fields are marked *