Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible, role not found error

I try to play following playbook against localhost to provision Vagrant machine

---
- hosts: all
  become: yes
  roles:
    - base
    - jenkins

I have cloned necessary roles from github and they resides in a relative path roles/{role name}

Executing following command: ansible-playbook -i "localhost," -c local playbook.yml outputs this error:

==> default: ERROR! the role 'geerlingguy.java' was not found in /home/vagrant/provisioning/roles:/home/vagrant/provisioning:/etc/ansible/roles:/home/vagrant/provisioning/roles
==> default:
==> default: The error appears to have been in '/home/vagrant/provisioning/roles/jenkins/meta/main.yml': line 3, column 5, but may
==> default: be elsewhere in the file depending on the exact syntax problem.
==> default:
==> default: The offending line appears to be:
==> default:
==> default: dependencies:
==> default:   - geerlingguy.java
==> default:     ^ here

I cloned the missing dependency from github, and tried to reside it in relative path of roles/java and roles/geerlingguy/java, but either didn't solve the problem, and error stays the same.

I want to keep all roles locally in the synced provisioning folder, without using ansible-galaxy runtime, to make the provisioning method as self contained as possible.

Here is the provision folder structure as it is now

.
├── playbook.yml
└── roles
    ├── base
    │   └── tasks
    │       └── main.yml
    ├── java
    │   ├── defaults
    │   │   └── main.yml
    │   ├── meta
    │   │   └── main.yml
    │   ├── README.md
    │   ├── tasks
    │   │   ├── main.yml
    │   │   ├── setup-Debian.yml
    │   │   ├── setup-FreeBSD.yml
    │   │   └── setup-RedHat.yml
    │   ├── templates
    │   │   └── java_home.sh.j2
    │   ├── tests
    │   │   └── test.yml
    │   └── vars
    │       ├── Debian.yml
    │       ├── Fedora.yml
    │       ├── FreeBSD.yml
    │       ├── RedHat.yml
    │       ├── Ubuntu-12.04.yml
    │       ├── Ubuntu-14.04.yml
    │       └── Ubuntu-16.04.yml
    └── jenkins
        ├── defaults
        │   └── main.yml
        ├── handlers
        │   └── main.yml
        ├── meta
        │   └── main.yml
        ├── README.md
        ├── tasks
        │   ├── main.yml
        │   ├── plugins.yml
        │   ├── settings.yml
        │   ├── setup-Debian.yml
        │   └── setup-RedHat.yml
        ├── templates
        │   └── basic-security.groovy
        ├── tests
        │   ├── requirements.yml
        │   ├── test-http-port.yml
        │   ├── test-jenkins-version.yml
        │   ├── test-plugins-with-pinning.yml
        │   ├── test-plugins.yml
        │   ├── test-prefix.yml
        │   └── test.yml
        └── vars
            ├── Debian.yml
            └── RedHat.yml
like image 367
Tuomas Toivonen Avatar asked Oct 05 '16 12:10

Tuomas Toivonen


3 Answers

Simple symbolic link works like a charm without any installations:

$ mkdir /home/USER/ansible && ln -s /home/USER/GIT/ansible-root/roles
like image 69
user14909454 Avatar answered Nov 02 '22 19:11

user14909454


You should install or clone all required roles in the /roles folder (or in the system folder)

ansible-galaxy install -p ROLES_PATH geerlingguy.java

should fix this specific problem.

However, the best practice should be the use of a requirements.yml file where you require all the needed roles and then install them with ansible-galaxy directly in your playbook.

- name: run ansible galaxy
  local_action: command ansible-galaxy install -r requirements.yml --ignore-errors
like image 43
Diego Ferri Avatar answered Nov 02 '22 20:11

Diego Ferri


Here is the solution: the required path for the role is roles/geerlingguy.java/, not roles/geerlingguy/java/

like image 1
Tuomas Toivonen Avatar answered Nov 02 '22 19:11

Tuomas Toivonen