<p dir="auto">See sample playbook at <a href="https://github.com/abdulg/ansible-common-roles">https://github.com/abdulg/ansible-common-roles</a></p>
<p dir="auto">Using ansible 1.4.4.</p>
<p dir="auto">When using Ansible roles I ran into a problem where common roles were being skipped. The linked repo is a demonstration of the issue. There are 2 roles, <em>role1</em> and <em>role2</em>, each of which depend on a 3rd role, <em>common</em>.</p>
<p dir="auto">I have three playbooks, <em>playbook.yml</em>, <em>role1.yml</em>, and <em>role2.yml</em>. The first playbook selects a role to execute based upon a variable passed via the command line. The second 2 simply execute <em>role1</em> and <em>role2</em> respectively.</p>
<p dir="auto">Here is the result of running the <em>role1</em> playbook:-</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="⚡ 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"><pre class="notranslate"><code class="notranslate">⚡ 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
</code></pre></div>
<p dir="auto">And as expected, running <em>role2</em> is similar:-</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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"><pre class="notranslate"><code class="notranslate">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
</code></pre></div>
<p dir="auto">But see what happens when I run <em>playbook.yml</em>, wherein I select the role to run via a CL variable. First select to run <em>role1</em>:-</p>
<p dir="auto"><g-emoji class="g-emoji" alias="zap" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/26a1.png">⚡</g-emoji> ansible-playbook -i inventory playbook.yml -e do_role=role1</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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"><pre class="notranslate"><code class="notranslate">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
</code></pre></div>
<p dir="auto">The roles <em>common</em> and <em>role1</em> are run, and <em>role2</em> is skipped. All ok.</p>
<p dir="auto">Now I select <em>role2</em> in <em>playbook.yml</em>_:-</p>
<p dir="auto"><g-emoji class="g-emoji" alias="zap" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/26a1.png">⚡</g-emoji> ansible-playbook -i inventory playbook.yml -e do_role=role2</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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"><pre class="notranslate"><code class="notranslate">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
</code></pre></div>
<p dir="auto">The <em>common</em> role is skipped because <em>role1</em> is skipped, and <em>common</em> is a dependency of <em>role1</em>. <em>common</em> should be not be skipped because it's a dependency of <em>role2</em> .</p>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto"><code class="notranslate">iptables.py</code></p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/share/my_modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]"><pre class="notranslate"><code class="notranslate">ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/share/my_modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="DEFAULT_FORKS(/etc/ansible/ansible.cfg) = 5
DEFAULT_MODULE_PATH(/etc/ansible/ansible.cfg) = [u'/usr/share/my_modules']
DEFAULT_MODULE_UTILS_PATH(/etc/ansible/ansible.cfg) = [u'/usr/share/my_module_utils']
DEFAULT_REMOTE_USER(/etc/ansible/ansible.cfg) = root
DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/roles', u'/usr/share/ansible/roles']
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False"><pre class="notranslate"><code class="notranslate">DEFAULT_FORKS(/etc/ansible/ansible.cfg) = 5
DEFAULT_MODULE_PATH(/etc/ansible/ansible.cfg) = [u'/usr/share/my_modules']
DEFAULT_MODULE_UTILS_PATH(/etc/ansible/ansible.cfg) = [u'/usr/share/my_module_utils']
DEFAULT_REMOTE_USER(/etc/ansible/ansible.cfg) = root
DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/roles', u'/usr/share/ansible/roles']
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="running CentOS Linux release 7.4.1708
manage CentOS Linux 6.X and 7.X"><pre class="notranslate"><code class="notranslate">running CentOS Linux release 7.4.1708
manage CentOS Linux 6.X and 7.X
</code></pre></div>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">i have iptables rule:<br>
<code class="notranslate">iptables -A OUTPUT -p tcp --tcp-flags ALL ACK,RST,SYN,FIN -j DROP</code></p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: TCP ALL ACK,RST,SYN,FIN
  iptables:
    chain: OUTPUT
    protocol: tcp
    tcp_flags: flags=&quot;ALL&quot; flags_set=&quot;ACK,RST,SYN,FIN&quot;
    jump: drop"><pre class="notranslate"><code class="notranslate">- name: TCP ALL ACK,RST,SYN,FIN
  iptables:
    chain: OUTPUT
    protocol: tcp
    tcp_flags: flags="ALL" flags_set="ACK,RST,SYN,FIN"
    jump: drop
</code></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto"><code class="notranslate">/usr/sbin/iptables -t filter -A OUTPUT -p tcp --tcp-flags ALL ACK,RST,SYN,FIN -j drop</code></p>
<h5 dir="auto">ACTUAL RESULTS</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fatal: [192.168.0.151]: FAILED! =&gt; {
    &quot;changed&quot;: false,
    &quot;cmd&quot;: &quot;/usr/sbin/iptables -t filter -A OUTPUT -p tcp --tcp-flags A,L,L A,C,K,,,R,S,T,,,S,Y,N,,,F,I,N -j drop&quot;,
    &quot;invocation&quot;: {
        &quot;module_args&quot;: {
            &quot;action&quot;: &quot;append&quot;,
            &quot;chain&quot;: &quot;OUTPUT&quot;,
            &quot;comment&quot;: null,
            &quot;ctstate&quot;: [],
            &quot;destination&quot;: null,
            &quot;destination_port&quot;: null,
            &quot;flush&quot;: false,
            &quot;fragment&quot;: null,
            &quot;goto&quot;: null,
            &quot;icmp_type&quot;: null,
            &quot;in_interface&quot;: null,
            &quot;ip_version&quot;: &quot;ipv4&quot;,
            &quot;jump&quot;: &quot;drop&quot;,
            &quot;limit&quot;: null,
            &quot;limit_burst&quot;: null,
            &quot;match&quot;: [],
            &quot;out_interface&quot;: null,
            &quot;policy&quot;: null,
            &quot;protocol&quot;: &quot;tcp&quot;,
            &quot;reject_with&quot;: null,
            &quot;set_counters&quot;: null,
            &quot;set_dscp_mark&quot;: null,
            &quot;set_dscp_mark_class&quot;: null,
            &quot;source&quot;: null,
            &quot;source_port&quot;: null,
            &quot;state&quot;: &quot;present&quot;,
            &quot;table&quot;: &quot;filter&quot;,
            &quot;tcp_flags&quot;: {
                &quot;flags&quot;: &quot;ALL&quot;,
                &quot;flags_set&quot;: &quot;ACK,RST,SYN,FIN&quot;
            },
            &quot;to_destination&quot;: null,
            &quot;to_ports&quot;: null,
            &quot;to_source&quot;: null,
            &quot;uid_owner&quot;: null
        }
    },
    &quot;msg&quot;: &quot;iptables v1.4.21: Unknown TCP flag `A'\nTry `iptables -h' or 'iptables --help' for more information.&quot;,
    &quot;rc&quot;: 2,
    &quot;stderr&quot;: &quot;iptables v1.4.21: Unknown TCP flag `A'\nTry `iptables -h' or 'iptables --help' for more information.\n&quot;,
    &quot;stderr_lines&quot;: [
        &quot;iptables v1.4.21: Unknown TCP flag `A'&quot;,
        &quot;Try `iptables -h' or 'iptables --help' for more information.&quot;
    ],
    &quot;stdout&quot;: &quot;&quot;,
    &quot;stdout_lines&quot;: []
}

"><pre class="notranslate"><code class="notranslate">fatal: [192.168.0.151]: FAILED! =&gt; {
    "changed": false,
    "cmd": "/usr/sbin/iptables -t filter -A OUTPUT -p tcp --tcp-flags A,L,L A,C,K,,,R,S,T,,,S,Y,N,,,F,I,N -j drop",
    "invocation": {
        "module_args": {
            "action": "append",
            "chain": "OUTPUT",
            "comment": null,
            "ctstate": [],
            "destination": null,
            "destination_port": null,
            "flush": false,
            "fragment": null,
            "goto": null,
            "icmp_type": null,
            "in_interface": null,
            "ip_version": "ipv4",
            "jump": "drop",
            "limit": null,
            "limit_burst": null,
            "match": [],
            "out_interface": null,
            "policy": null,
            "protocol": "tcp",
            "reject_with": null,
            "set_counters": null,
            "set_dscp_mark": null,
            "set_dscp_mark_class": null,
            "source": null,
            "source_port": null,
            "state": "present",
            "table": "filter",
            "tcp_flags": {
                "flags": "ALL",
                "flags_set": "ACK,RST,SYN,FIN"
            },
            "to_destination": null,
            "to_ports": null,
            "to_source": null,
            "uid_owner": null
        }
    },
    "msg": "iptables v1.4.21: Unknown TCP flag `A'\nTry `iptables -h' or 'iptables --help' for more information.",
    "rc": 2,
    "stderr": "iptables v1.4.21: Unknown TCP flag `A'\nTry `iptables -h' or 'iptables --help' for more information.\n",
    "stderr_lines": [
        "iptables v1.4.21: Unknown TCP flag `A'",
        "Try `iptables -h' or 'iptables --help' for more information."
    ],
    "stdout": "",
    "stdout_lines": []
}


</code></pre></div>