<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Feature Idea</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">ansible 1.8 (or greater)</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">A special tag <em>all</em> matching all possible tags might make working with tags easier and less error-prone.</p>
<h5 dir="auto">Motivation:</h5>
<p dir="auto">It's useful to organize larger playbooks by assigning tags to tasks. This allows to run only a subset of a playbook's tasks.</p>
<p dir="auto">However, in some cases it might make sense to always run a task. Controlling monitoring comes to mind:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- nagios: action=downtime minutes=10 service=some_service host=some.host
  tags:
    - foo
    - bar

- command: /usr/bin/foo
  tags: foo

- command: /usr/bin/bar
  tags: bar"><pre class="notranslate">- <span class="pl-ent">nagios</span>: <span class="pl-s">action=downtime minutes=10 service=some_service host=some.host</span>
  <span class="pl-ent">tags</span>:
    - <span class="pl-s">foo</span>
    - <span class="pl-s">bar</span>

- <span class="pl-ent">command</span>: <span class="pl-s">/usr/bin/foo</span>
  <span class="pl-ent">tags</span>: <span class="pl-s">foo</span>

- <span class="pl-ent">command</span>: <span class="pl-s">/usr/bin/bar</span>
  <span class="pl-ent">tags</span>: <span class="pl-s">bar</span></pre></div>
<p dir="auto">If later on a new task with tag <em>baz</em> is introduced into this playbook, <em>baz</em> has to be added to the tags of the <em>nagios</em> task as well.</p>
<p dir="auto">This is no problem in small playbooks, but once several roles are used in combination with <code class="notranslate">pre_tasks</code>/<code class="notranslate">post_tasks</code>, keeping track of all tags involved may become cumbersome.</p>
<h5 dir="auto">Rationale:</h5>
<p dir="auto">The current system requires a certain amount of bookkeeping, often spanning several different files, in order to achieve something that can be explained easily in natural language: "make sure this task always runs"</p>
<p dir="auto">If this bookkeeping is not kept up, when calling <code class="notranslate">ansible-playbook</code> with the <code class="notranslate">--tags</code> option, running playbooks might fail (because some essential initial task did not run), or unwanted side effects may occur (monitoring alerts because no downtime was scheduled for example)</p>
<p dir="auto">For these cases it might make sense to have a special tag matching every possible tag (therefore meaning "all tags") instead of listing all those tags explicitly.</p>
<p dir="auto">There is a tag that currently makes no sense to assign to any task: the tag <em>all</em>.</p>
<p dir="auto">This is because <em>all</em> has a special meaning for <code class="notranslate">ansible-playbook</code>: rather than "execute only tasks with a tag called <em>all</em>", providing <code class="notranslate">--tags all</code> (the default) to <code class="notranslate">ansible-playbook</code> means "execute all tasks".</p>
<p dir="auto">In other words, a task tagged (only) with <em>all</em> is run under the exact same conditions as an untagged task.</p>
<p dir="auto">There seems currently no reason whatsoever to tag a task with <em>all</em>, and it is to be expected that not many (if any) existing playbooks do this. If there are playbooks out there doing so, they can be converted into equivalent playbooks by simply omitting the <em>all</em> tag in it's current form.</p>
<h5 dir="auto">Proposal:</h5>
<p dir="auto">If the currently meaningless tag <em>all</em> were to gain the semantic "match every possible tag" the abovementioned difficulties could be tackled easily and without losing much (if anything).</p>
<p dir="auto">The monitoring example from above would then look like this:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- nagios: action=downtime minutes=10 service=some_service host=some.host
  tags: all

- command: /usr/bin/foo
  tags: foo

- command: /usr/bin/bar
  tags: bar"><pre class="notranslate">- <span class="pl-ent">nagios</span>: <span class="pl-s">action=downtime minutes=10 service=some_service host=some.host</span>
  <span class="pl-ent">tags</span>: <span class="pl-s">all</span>

- <span class="pl-ent">command</span>: <span class="pl-s">/usr/bin/foo</span>
  <span class="pl-ent">tags</span>: <span class="pl-s">foo</span>

- <span class="pl-ent">command</span>: <span class="pl-s">/usr/bin/bar</span>
  <span class="pl-ent">tags</span>: <span class="pl-s">bar</span></pre></div>
<p dir="auto">Adding a task tagged <em>baz</em> later on does not require any changes whatsoever to the <em>nagios</em> task.</p>
<p dir="auto">The name <em>all</em> should hint to the fact that all tags are meant.</p>
<p dir="auto">And finally, this would also mirror the host group <em>all</em> which in turn includes every possible host.</p>
<h5 dir="auto">Related:</h5>
<p dir="auto">Issue <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="42811559" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/9010" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/9010/hovercard" href="https://github.com/ansible/ansible/issues/9010">#9010</a> seems to discuss things that might overlap with this proposal.</p>
<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">ansible <code class="notranslate">devel</code>, commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/f488de85997079f480d504f73537e3e33ff2495b/hovercard" href="https://github.com/ansible/ansible/commit/f488de85997079f480d504f73537e3e33ff2495b"><tt>f488de8</tt></a></p>
<h5 dir="auto">Ansible Configuration:</h5>
<p dir="auto">no changes</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">ansible on Mac OS X 10.11.1<br>
managing docker container with CentOS 6 (docker image "centos:centos6")</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">Running ansible-playbook, a task executing on "docker" connection makes ansible-playbook process hang. The issue occurs since commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/f488de85997079f480d504f73537e3e33ff2495b/hovercard" href="https://github.com/ansible/ansible/commit/f488de85997079f480d504f73537e3e33ff2495b"><tt>f488de8</tt></a>.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">I created a bash script to reproduce this issue:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#!/bin/bash

# start docker container
CONTAINER_ID=&quot;$(docker run -d -t -h testhost centos:centos6)&quot;

# create ansible inventory
echo &quot;testhost ansible_connection=docker ansible_host=${CONTAINER_ID}&quot; &gt; inventory

# create ansible playbook
echo &quot;- hosts: testhost&quot; &gt; playbook.yml
echo &quot;  tasks:&quot; &gt;&gt; playbook.yml
echo &quot;    - name: host is reachable&quot; &gt;&gt; playbook.yml
echo &quot;      ping:&quot; &gt;&gt; playbook.yml

# run ansible playbook
ansible-playbook -i inventory playbook.yml

# remove docker container
docker rm -f &quot;${CONTAINER_ID}&quot;"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#!</span>/bin/bash</span>

<span class="pl-c"><span class="pl-c">#</span> start docker container</span>
CONTAINER_ID=<span class="pl-s"><span class="pl-pds">"</span><span class="pl-s"><span class="pl-pds">$(</span>docker run -d -t -h testhost centos:centos6<span class="pl-pds">)</span></span><span class="pl-pds">"</span></span>

<span class="pl-c"><span class="pl-c">#</span> create ansible inventory</span>
<span class="pl-c1">echo</span> <span class="pl-s"><span class="pl-pds">"</span>testhost ansible_connection=docker ansible_host=<span class="pl-smi">${CONTAINER_ID}</span><span class="pl-pds">"</span></span> <span class="pl-k">&gt;</span> inventory

<span class="pl-c"><span class="pl-c">#</span> create ansible playbook</span>
<span class="pl-c1">echo</span> <span class="pl-s"><span class="pl-pds">"</span>- hosts: testhost<span class="pl-pds">"</span></span> <span class="pl-k">&gt;</span> playbook.yml
<span class="pl-c1">echo</span> <span class="pl-s"><span class="pl-pds">"</span>  tasks:<span class="pl-pds">"</span></span> <span class="pl-k">&gt;&gt;</span> playbook.yml
<span class="pl-c1">echo</span> <span class="pl-s"><span class="pl-pds">"</span>    - name: host is reachable<span class="pl-pds">"</span></span> <span class="pl-k">&gt;&gt;</span> playbook.yml
<span class="pl-c1">echo</span> <span class="pl-s"><span class="pl-pds">"</span>      ping:<span class="pl-pds">"</span></span> <span class="pl-k">&gt;&gt;</span> playbook.yml

<span class="pl-c"><span class="pl-c">#</span> run ansible playbook</span>
ansible-playbook -i inventory playbook.yml

<span class="pl-c"><span class="pl-c">#</span> remove docker container</span>
docker rm -f <span class="pl-s"><span class="pl-pds">"</span><span class="pl-smi">${CONTAINER_ID}</span><span class="pl-pds">"</span></span></pre></div>
<p dir="auto">This fails since commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/f488de85997079f480d504f73537e3e33ff2495b/hovercard" href="https://github.com/ansible/ansible/commit/f488de85997079f480d504f73537e3e33ff2495b"><tt>f488de8</tt></a>.</p>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">Run the minimal playbook without hanging indefinitely.</p>
<h5 dir="auto">Actual Results:</h5>
<p dir="auto">Minimal playbook hangs indefinitely.</p>