Background
I am experimenting with Ansible (1.9.4) roles and I am trying to get the hang of role dependencies.
I have created the following roles:
- A role that installs the Oracle JDK (ansible-java8)
- A role that installs Tomcat (ansible-tomcat7)
The second role defines the first as a dependency in /ansible-tomcat7/meta/main.yml
:
dependencies:
- { role: java8 }
I also included a requirements.yml file with the following:
- name: java8
src: 'https://github.com/gregwhitaker/ansible-java8'
I have added the following configuration to my /etc/ansible/ansible.cfg
to configure my roles_path to a place in my home directory:
roles_path = ~/ansible/roles
I then installed the ansible-java8
role as java8
using the following command:
ansible-galaxy install -r requirements.yml
Once the command was ran I can see the java8 role in the ~/ansible/roles directory.
However, when I run a playbook that calls the tomcat7 role only that role is executed. The java8 role is not executed before the tomcat7 role.
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [default]
TASK: [Install Tomcat7 (Ubuntu)] **********************************************
changed: [default] => (item=tomcat7,libtcnative-1,libapr1)
TASK: [Install Tomcat7 (Debian)] **********************************************
skipping: [default]
TASK: [Install Tomcat7 (Amazon Linux)] ****************************************
skipping: [default]
PLAY RECAP ********************************************************************
default
Questions
- Is this the correct way to define dependent roles or have I totally missed something?
- Am I correct in thinking that since I marked the tomcat7 role as depending on java8 that the java8 role should have been located from the roles_path and ran first?
- What mistake am I making that is causing the java8 role to not run before the tomcat7 role?