<p dir="auto">Sometimes you want to define a complex variable dictionary and do not want to create a separate vault file for passwords. It would be cool for history purpose to use a plain yml file for variable definition and inline vault variable content like the following. This feature is described by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/jpmens/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/jpmens">@jpmens</a> on <a href="http://jpmens.net/2014/02/22/my-thoughts-on-ansible-s-vault/" rel="nofollow">http://jpmens.net/2014/02/22/my-thoughts-on-ansible-s-vault/</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="nameserver: 10.0.0.1
admin: Jane Jolie
dbpassword: @vault@&quot;AHchx0a+G8mejs84tGxCNKxMFP7tM7Y7kl&quot;
webservertype: nginx"><pre class="notranslate"><code class="notranslate">nameserver: 10.0.0.1
admin: Jane Jolie
dbpassword: @vault@"AHchx0a+G8mejs84tGxCNKxMFP7tM7Y7kl"
webservertype: nginx
</code></pre></div>
<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">2.0.0 (devel <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/139138c6049a375acd7cf765b987b8223d19b1b6/hovercard" href="https://github.com/ansible/ansible/commit/139138c6049a375acd7cf765b987b8223d19b1b6"><tt>139138c</tt></a>)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.0.0 (devel 139138c604) last updated 2015/07/03 12:38:26 (GMT +200)
lib/ansible/modules/core: (detached HEAD ff69ce7912) last updated 2015/07/03 12:38:49 (GMT +200)
lib/ansible/modules/extras: (detached HEAD 4e48ef9eca) last updated 2015/07/03 12:38:49 (GMT +200)
v1/ansible/modules/core: (detached HEAD f8d8af17cd) last updated 2015/06/11 22:17:01 (GMT +200)
v1/ansible/modules/extras: (detached HEAD 495ad450e5) last updated 2015/06/11 22:17:04 (GMT +200)
configured module search path = /opt/ansible/library"><pre class="notranslate"><code class="notranslate">ansible 2.0.0 (devel 139138c604) last updated 2015/07/03 12:38:26 (GMT +200)
lib/ansible/modules/core: (detached HEAD ff69ce7912) last updated 2015/07/03 12:38:49 (GMT +200)
lib/ansible/modules/extras: (detached HEAD 4e48ef9eca) last updated 2015/07/03 12:38:49 (GMT +200)
v1/ansible/modules/core: (detached HEAD f8d8af17cd) last updated 2015/06/11 22:17:01 (GMT +200)
v1/ansible/modules/extras: (detached HEAD 495ad450e5) last updated 2015/06/11 22:17:04 (GMT +200)
configured module search path = /opt/ansible/library
</code></pre></div>
<h5 dir="auto">Ansible Configuration:</h5>
<p dir="auto">Not sure it has any relevance, but just to be sure: I installed via git to <code class="notranslate">/opt/ansible</code>. I didn't change anything in the config. I can't find ansible.cfg i the above path, though (the issue guide lines asks me to compare that with the most recent version on git)</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Local: Ubuntu 15.04. The issues reproduces on local connection and on a Ubuntu 14.04 vagrant VM box.</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">As the title states:  Tasks are executed duplicate times when including plays from 'master play', i.e. a play that does nothing than include other plays. Task in the first included play gets executed once, tasks in the next included play gets executed twice ... and so forth (the example below is just for two plays).</p>
<p dir="auto">(I'm not sure if the task actually gets executed more than once or if it's just an issue with the terminal out output)</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">Put the files below in the same folder and run: <code class="notranslate">$ ansible-playbook masterplay.yml -i 127.0.0.1,</code> (inlucde the trailing comma).  You can also just grab the files here: <a href="https://gist.github.com/andersbc/33daefe44e31eccd21aa">https://gist.github.com/andersbc/33daefe44e31eccd21aa</a>.</p>
<p dir="auto">masterplay.yml:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
---
- include: play_a.yml
- include: play_b.yml"><pre class="notranslate">---
- <span class="pl-ent">include</span>: <span class="pl-s">play_a.yml</span>
- <span class="pl-ent">include</span>: <span class="pl-s">play_b.yml</span></pre></div>
<p dir="auto">play_a.yml:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
---
- hosts: 127.0.0.1
  connection: local
  name: play a
  vars:
    foo: bar
  tasks:
  - name: the task in play a
    debug: msg=&quot;{{ foo }}&quot;"><pre class="notranslate">---
- <span class="pl-ent">hosts</span>: <span class="pl-s">127.0.0.1</span>
  <span class="pl-ent">connection</span>: <span class="pl-s">local</span>
  <span class="pl-ent">name</span>: <span class="pl-s">play a</span>
  <span class="pl-ent">vars</span>:
    <span class="pl-ent">foo</span>: <span class="pl-s">bar</span>
  <span class="pl-ent">tasks</span>:
  - <span class="pl-ent">name</span>: <span class="pl-s">the task in play a</span>
    <span class="pl-ent">debug</span>: <span class="pl-s">msg="{{ foo }}"</span></pre></div>
<p dir="auto">play_b.yml:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
---
- hosts: 127.0.0.1
  connection: local
  name: play b
  vars:
    foo2: bar
  tasks:
  - name: the task in play b
    debug: msg=&quot;{{ foo2 }}&quot;"><pre class="notranslate">---
- <span class="pl-ent">hosts</span>: <span class="pl-s">127.0.0.1</span>
  <span class="pl-ent">connection</span>: <span class="pl-s">local</span>
  <span class="pl-ent">name</span>: <span class="pl-s">play b</span>
  <span class="pl-ent">vars</span>:
    <span class="pl-ent">foo2</span>: <span class="pl-s">bar</span>
  <span class="pl-ent">tasks</span>:
  - <span class="pl-ent">name</span>: <span class="pl-s">the task in play b</span>
    <span class="pl-ent">debug</span>: <span class="pl-s">msg="{{ foo2 }}"</span></pre></div>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">Only one execution of the task in the second included play (play b)</p>
<h5 dir="auto">Actual Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY: play a ********************************************************************

TASK [setup] ********************************************************************
ok: [127.0.0.1]

TASK [the task in play a] *******************************************************
ok: [127.0.0.1] =&gt; {
    &quot;msg&quot;: &quot;bar&quot;, 
    &quot;changed&quot;: false
}

PLAY: play b ********************************************************************

PLAY: play b ********************************************************************

TASK [the task in play b] *******************************************************

TASK [the task in play b] *******************************************************
ok: [127.0.0.1] =&gt; {
    &quot;msg&quot;: &quot;bar&quot;, 
    &quot;changed&quot;: false
}
ok: [127.0.0.1]

PLAY RECAP **********************************************************************
127.0.0.1                  : ok=3    changed=0    unreachable=0    failed=0   "><pre class="notranslate"><code class="notranslate">PLAY: play a ********************************************************************

TASK [setup] ********************************************************************
ok: [127.0.0.1]

TASK [the task in play a] *******************************************************
ok: [127.0.0.1] =&gt; {
    "msg": "bar", 
    "changed": false
}

PLAY: play b ********************************************************************

PLAY: play b ********************************************************************

TASK [the task in play b] *******************************************************

TASK [the task in play b] *******************************************************
ok: [127.0.0.1] =&gt; {
    "msg": "bar", 
    "changed": false
}
ok: [127.0.0.1]

PLAY RECAP **********************************************************************
127.0.0.1                  : ok=3    changed=0    unreachable=0    failed=0   
</code></pre></div>