Using ansible 1.4.4.
When using Ansible roles I ran into a problem where common roles were being skipped. This repo is a demonstration of the issue. There are 2 roles, role1 and role2, each of which depend on a 3rd role, common.
I have three playbooks, role1.yml, role2.yml and playbook.yml. The first playbook selects a role to execute based upon a variable passed via the command line. The second 2 simply execute role1 and role2 respectively.
Here is the result of running the role1 playbook:-
⚡ ansible-playbook -i inventory role1.yml
PLAY [Playbook to do role 1] **************************************************
GATHERING FACTS ***************************************************************
ok: [abdul]
TASK: [common | A common task] ************************************************
changed: [abdul]
TASK: [role1 | A role1 task] **************************************************
changed: [abdul]
PLAY RECAP ********************************************************************
abdul : ok=3 changed=2 unreachable=0 failed=0
And as expected, running role2 is similar:-
PLAY [Playbook to do role2] ***************************************************
GATHERING FACTS ***************************************************************
ok: [abdul]
TASK: [common | A common task] ************************************************
changed: [abdul]
TASK: [role2 | A role2 task] **************************************************
changed: [abdul]
PLAY RECAP ********************************************************************
abdul : ok=3 changed=2 unreachable=0 failed=0
But see what happens when I run playbook.yml, wherein I select the role to run via a CL variable. First select to run role1:-
⚡ ansible-playbook -i inventory playbook.yml -e do_role=role1
PLAY [Configure depending on passed in variable] ******************************
GATHERING FACTS ***************************************************************
ok: [abdul]
TASK: [common | A common task] ************************************************
changed: [abdul]
TASK: [role1 | A role1 task] **************************************************
changed: [abdul]
TASK: [role2 | A role2 task] **************************************************
skipping: [abdul]
PLAY RECAP ********************************************************************
abdul : ok=3 changed=2 unreachable=0 failed=0
The roles common and role1 are run, and role2 is skipped. All ok.
Now I select role2 in playbook.yml_:-
⚡ ansible-playbook -i inventory playbook.yml -e do_role=role2
PLAY [Configure depending on passed in variable] ******************************
GATHERING FACTS ***************************************************************
ok: [abdul]
TASK: [common | A common task] ************************************************
skipping: [abdul]
TASK: [role1 | A role1 task] **************************************************
skipping: [abdul]
TASK: [role2 | A role2 task] **************************************************
changed: [abdul]
PLAY RECAP ********************************************************************
abdul : ok=2 changed=1 unreachable=0 failed=0
The common role is skipped, obviously because role1 is skipped, and common is a dependency of role1.