<p dir="auto">I wrote some code broken into roles. I tagged all the tasks in a role with the role name. The idea was to apply individual roles via <code class="notranslate">-t</code>, but I had trouble getting role dependencies to run.</p>
<p dir="auto">Ansible config to see the issue consists of three roles, each with a debug task which prints the role name. Roles <code class="notranslate">foo</code> and <code class="notranslate">bar</code> both depend on role <code class="notranslate">common</code>. All the tasks in a role are tagged with the role name. (See the patch with all the config below.)</p>
<p dir="auto">When applying the <code class="notranslate">bar</code> role using <code class="notranslate">-t</code>, the <code class="notranslate">common</code> role isn't invoked, even though <code class="notranslate">bar</code> depends on <code class="notranslate">common</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook -t bar -i hosts --connection=local playbook.yml

PLAY [all] ********************************************************************

GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

TASK: [debug msg='bar'] *******************************************************
ok: [127.0.0.1] =&gt; {&quot;item&quot;: &quot;&quot;, &quot;msg&quot;: &quot;bar&quot;}

PLAY RECAP ********************************************************************
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0"><pre class="notranslate"><code class="notranslate">$ ansible-playbook -t bar -i hosts --connection=local playbook.yml

PLAY [all] ********************************************************************

GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

TASK: [debug msg='bar'] *******************************************************
ok: [127.0.0.1] =&gt; {"item": "", "msg": "bar"}

PLAY RECAP ********************************************************************
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0
</code></pre></div>
<p dir="auto">When applying the <code class="notranslate">foo</code> role I see the expected behavior, the tasks in <code class="notranslate">common</code> run because <code class="notranslate">foo</code> depends on <code class="notranslate">common</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook -t foo -i hosts --connection=local playbook.yml

PLAY [all] ********************************************************************

GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

TASK: [debug msg='common'] ****************************************************
ok: [127.0.0.1] =&gt; {&quot;item&quot;: &quot;&quot;, &quot;msg&quot;: &quot;common&quot;}

TASK: [debug msg='foo'] *******************************************************
ok: [127.0.0.1] =&gt; {&quot;item&quot;: &quot;&quot;, &quot;msg&quot;: &quot;foo&quot;}

PLAY RECAP ********************************************************************
127.0.0.1                  : ok=3    changed=0    unreachable=0    failed=0"><pre class="notranslate"><code class="notranslate">$ ansible-playbook -t foo -i hosts --connection=local playbook.yml

PLAY [all] ********************************************************************

GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

TASK: [debug msg='common'] ****************************************************
ok: [127.0.0.1] =&gt; {"item": "", "msg": "common"}

TASK: [debug msg='foo'] *******************************************************
ok: [127.0.0.1] =&gt; {"item": "", "msg": "foo"}

PLAY RECAP ********************************************************************
127.0.0.1                  : ok=3    changed=0    unreachable=0    failed=0
</code></pre></div>
<p dir="auto">One interesting thing I noticed is that reordering the roles in <code class="notranslate">playbook.yml</code> changes the behavior so that <code class="notranslate">common</code> runs with <code class="notranslate">bar</code> instead of <code class="notranslate">foo</code>.</p>
<p dir="auto">Here is the entire config:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="diff -uNr ansible/hosts ansible-role-dependencies-issue/hosts
--- ansible/hosts       1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/hosts       2013-10-02 12:20:02.334617837 -0400
@@ -0,0 +1 @@
+127.0.0.1
diff -uNr ansible/playbook.yml ansible-role-dependencies-issue/playbook.yml
--- ansible/playbook.yml        1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/playbook.yml        2013-10-02 13:46:49.322634918 -0400
@@ -0,0 +1,6 @@
+---
+- hosts: all
+  roles:
+    #- { role: common, tags: [ 'common' ] }
+    - { role: foo, tags: [ 'foo' ] }
+    - { role: bar, tags: [ 'bar' ] }
diff -uNr ansible/roles/bar/meta/main.yml ansible-role-dependencies-issue/roles/bar/meta/main.yml
--- ansible/roles/bar/meta/main.yml     1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/roles/bar/meta/main.yml     2013-10-02 09:59:56.426590262 -0400
@@ -0,0 +1,3 @@
+---
+dependencies:
+  - { role: common }
diff -uNr ansible/roles/bar/tasks/main.yml ansible-role-dependencies-issue/roles/bar/tasks/main.yml
--- ansible/roles/bar/tasks/main.yml    1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/roles/bar/tasks/main.yml    2013-10-02 09:43:57.334587115 -0400
@@ -0,0 +1,2 @@
+---
+- debug: msg='bar'
diff -uNr ansible/roles/common/meta/main.yml ansible-role-dependencies-issue/roles/common/meta/main.yml
--- ansible/roles/common/meta/main.yml  1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/roles/common/meta/main.yml  2013-10-02 13:48:36.466635270 -0400
@@ -0,0 +1,2 @@
+---
+#allow_duplicates: yes
diff -uNr ansible/roles/common/tasks/main.yml ansible-role-dependencies-issue/roles/common/tasks/main.yml
--- ansible/roles/common/tasks/main.yml 1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/roles/common/tasks/main.yml 2013-10-02 09:44:01.470587129 -0400
@@ -0,0 +1,2 @@
+---
+- debug: msg='common'
diff -uNr ansible/roles/foo/meta/main.yml ansible-role-dependencies-issue/roles/foo/meta/main.yml
--- ansible/roles/foo/meta/main.yml     1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/roles/foo/meta/main.yml     2013-10-02 10:10:24.866592323 -0400
@@ -0,0 +1,3 @@
+---
+dependencies:
+  - { role: common }
diff -uNr ansible/roles/foo/tasks/main.yml ansible-role-dependencies-issue/roles/foo/tasks/main.yml
--- ansible/roles/foo/tasks/main.yml    1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/roles/foo/tasks/main.yml    2013-10-02 09:44:01.386587129 -0400
@@ -0,0 +1,2 @@
+---
+- debug: msg='foo'"><pre class="notranslate"><code class="notranslate">diff -uNr ansible/hosts ansible-role-dependencies-issue/hosts
--- ansible/hosts       1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/hosts       2013-10-02 12:20:02.334617837 -0400
@@ -0,0 +1 @@
+127.0.0.1
diff -uNr ansible/playbook.yml ansible-role-dependencies-issue/playbook.yml
--- ansible/playbook.yml        1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/playbook.yml        2013-10-02 13:46:49.322634918 -0400
@@ -0,0 +1,6 @@
+---
+- hosts: all
+  roles:
+    #- { role: common, tags: [ 'common' ] }
+    - { role: foo, tags: [ 'foo' ] }
+    - { role: bar, tags: [ 'bar' ] }
diff -uNr ansible/roles/bar/meta/main.yml ansible-role-dependencies-issue/roles/bar/meta/main.yml
--- ansible/roles/bar/meta/main.yml     1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/roles/bar/meta/main.yml     2013-10-02 09:59:56.426590262 -0400
@@ -0,0 +1,3 @@
+---
+dependencies:
+  - { role: common }
diff -uNr ansible/roles/bar/tasks/main.yml ansible-role-dependencies-issue/roles/bar/tasks/main.yml
--- ansible/roles/bar/tasks/main.yml    1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/roles/bar/tasks/main.yml    2013-10-02 09:43:57.334587115 -0400
@@ -0,0 +1,2 @@
+---
+- debug: msg='bar'
diff -uNr ansible/roles/common/meta/main.yml ansible-role-dependencies-issue/roles/common/meta/main.yml
--- ansible/roles/common/meta/main.yml  1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/roles/common/meta/main.yml  2013-10-02 13:48:36.466635270 -0400
@@ -0,0 +1,2 @@
+---
+#allow_duplicates: yes
diff -uNr ansible/roles/common/tasks/main.yml ansible-role-dependencies-issue/roles/common/tasks/main.yml
--- ansible/roles/common/tasks/main.yml 1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/roles/common/tasks/main.yml 2013-10-02 09:44:01.470587129 -0400
@@ -0,0 +1,2 @@
+---
+- debug: msg='common'
diff -uNr ansible/roles/foo/meta/main.yml ansible-role-dependencies-issue/roles/foo/meta/main.yml
--- ansible/roles/foo/meta/main.yml     1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/roles/foo/meta/main.yml     2013-10-02 10:10:24.866592323 -0400
@@ -0,0 +1,3 @@
+---
+dependencies:
+  - { role: common }
diff -uNr ansible/roles/foo/tasks/main.yml ansible-role-dependencies-issue/roles/foo/tasks/main.yml
--- ansible/roles/foo/tasks/main.yml    1969-12-31 19:00:00.000000000 -0500
+++ ansible-role-dependencies-issue/roles/foo/tasks/main.yml    2013-10-02 09:44:01.386587129 -0400
@@ -0,0 +1,2 @@
+---
+- debug: msg='foo'
</code></pre></div>
<p dir="auto">Documentation on apt_repository module claims update_cache default value is yes. However, it only updates cache when declared explicitly, which means it is not yes by default.</p>