<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">ansible-playbook, when</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.2.1.0
  config file = /home/skazi/.ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.2.1.0
  config file = /home/skazi/.ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[defaults]
inventory = $HOME/ansible/hosts

gathering = smart
fact_caching = jsonfile
fact_caching_connection = $HOME/.ansible/facts_cache
fact_caching_timeout = 86400

[privilege_escalation]
become=True
become_method=sudo
become_user=root
#become_ask_pass=True"><pre class="notranslate"><code class="notranslate">[defaults]
inventory = $HOME/ansible/hosts

gathering = smart
fact_caching = jsonfile
fact_caching_connection = $HOME/.ansible/facts_cache
fact_caching_timeout = 86400

[privilege_escalation]
become=True
become_method=sudo
become_user=root
#become_ask_pass=True
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Debian Jessie</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Conditions using boolean variables and <code class="notranslate">and</code> are not evaluated correctly when variable values are changed from outside the playbook.</p>
<p dir="auto">The <code class="notranslate">when: ansible_distribution == "Debian" and bool_test</code> expression is correctly evaluated when <code class="notranslate">bool_test</code> is changed inside the playbook but not if it's changed when including playbook in another one or with <code class="notranslate">--extra-vars</code> CLI parameter. The list version of <code class="notranslate">and</code> works correctly.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">test.yaml</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- hosts: all
  vars:
    bool_test: True
  tasks:
    - debug: &quot;msg={{ bool_test }}&quot;

    - name: Run when distro and test list
      debug: &quot;msg='true so running'&quot;
      when:
        - ansible_distribution == &quot;Debian&quot;
        - bool_test

    - name: Run when distro and test
      debug: &quot;msg='true so running'&quot;
      when: ansible_distribution == &quot;Debian&quot; and bool_test

    - name: Run when distro
      debug: &quot;msg='true so running'&quot;
      when: ansible_distribution == &quot;Debian&quot;

    - name: Run when test
      debug: &quot;msg='true so running'&quot;
      when: bool_test"><pre class="notranslate">---
- <span class="pl-ent">hosts</span>: <span class="pl-s">all</span>
  <span class="pl-ent">vars</span>:
    <span class="pl-ent">bool_test</span>: <span class="pl-c1">True</span>
  <span class="pl-ent">tasks</span>:
    - <span class="pl-ent">debug</span>: <span class="pl-s"><span class="pl-pds">"</span>msg={{ bool_test }}<span class="pl-pds">"</span></span>

    - <span class="pl-ent">name</span>: <span class="pl-s">Run when distro and test list</span>
      <span class="pl-ent">debug</span>: <span class="pl-s"><span class="pl-pds">"</span>msg='true so running'<span class="pl-pds">"</span></span>
      <span class="pl-ent">when</span>:
        - <span class="pl-s">ansible_distribution == "Debian"</span>
        - <span class="pl-s">bool_test</span>

    - <span class="pl-ent">name</span>: <span class="pl-s">Run when distro and test</span>
      <span class="pl-ent">debug</span>: <span class="pl-s"><span class="pl-pds">"</span>msg='true so running'<span class="pl-pds">"</span></span>
      <span class="pl-ent">when</span>: <span class="pl-s">ansible_distribution == "Debian" and bool_test</span>

    - <span class="pl-ent">name</span>: <span class="pl-s">Run when distro</span>
      <span class="pl-ent">debug</span>: <span class="pl-s"><span class="pl-pds">"</span>msg='true so running'<span class="pl-pds">"</span></span>
      <span class="pl-ent">when</span>: <span class="pl-s">ansible_distribution == "Debian"</span>

    - <span class="pl-ent">name</span>: <span class="pl-s">Run when test</span>
      <span class="pl-ent">debug</span>: <span class="pl-s"><span class="pl-pds">"</span>msg='true so running'<span class="pl-pds">"</span></span>
      <span class="pl-ent">when</span>: <span class="pl-s">bool_test</span></pre></div>
<p dir="auto">test2.yml</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- include: test.yml bool_test=False
- include: test.yml bool_test=True"><pre class="notranslate">---
- <span class="pl-ent">include</span>: <span class="pl-s">test.yml bool_test=False</span>
- <span class="pl-ent">include</span>: <span class="pl-s">test.yml bool_test=True</span></pre></div>
<p dir="auto">shell</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook test.yml --limit localhost
$ ansible-playbook test.yml --limit localhost --extra-vars bool_test=False
$ ansible-playbook test2.yml --limit localhost"><pre class="notranslate"><code class="notranslate">$ ansible-playbook test.yml --limit localhost
$ ansible-playbook test.yml --limit localhost --extra-vars bool_test=False
$ ansible-playbook test2.yml --limit localhost
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook test.yml --limit localhost

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: true
}

TASK [Run when distro and test list] *******************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when distro and test] ************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when test] ***********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

PLAY RECAP *********************************************************************
localhost                  : ok=5    changed=0    unreachable=0    failed=0   "><pre class="notranslate"><code class="notranslate">$ ansible-playbook test.yml --limit localhost

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "msg": true
}

TASK [Run when distro and test list] *******************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when distro and test] ************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when test] ***********************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

PLAY RECAP *********************************************************************
localhost                  : ok=5    changed=0    unreachable=0    failed=0   
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook test.yml --limit localhost --extra-vars bool_test=False

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: false
}

TASK [Run when distro and test list] *******************************************
skipping: [localhost]

TASK [Run when distro and test] ************************************************
skipping: [localhost]

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when test] ***********************************************************
skipping: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0   "><pre class="notranslate"><code class="notranslate">$ ansible-playbook test.yml --limit localhost --extra-vars bool_test=False

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "msg": false
}

TASK [Run when distro and test list] *******************************************
skipping: [localhost]

TASK [Run when distro and test] ************************************************
skipping: [localhost]

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when test] ***********************************************************
skipping: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0   
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook test2.yml  --limit localhost

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: false
}

TASK [Run when distro and test list] *******************************************
skipping: [localhost]

TASK [Run when distro and test] ************************************************
skipping: [localhost]

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when test] ***********************************************************
skipping: [localhost]

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: true
}

TASK [Run when distro and test list] *******************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when distro and test] ************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when test] ***********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

PLAY RECAP *********************************************************************
localhost                  : ok=8    changed=0    unreachable=0    failed=0   "><pre class="notranslate"><code class="notranslate">$ ansible-playbook test2.yml  --limit localhost

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "msg": false
}

TASK [Run when distro and test list] *******************************************
skipping: [localhost]

TASK [Run when distro and test] ************************************************
skipping: [localhost]

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when test] ***********************************************************
skipping: [localhost]

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "msg": true
}

TASK [Run when distro and test list] *******************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when distro and test] ************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when test] ***********************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

PLAY RECAP *********************************************************************
localhost                  : ok=8    changed=0    unreachable=0    failed=0   
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook test.yml --limit localhost

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: true
}

TASK [Run when distro and test list] *******************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when distro and test] ************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when test] ***********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

PLAY RECAP *********************************************************************
localhost                  : ok=5    changed=0    unreachable=0    failed=0   "><pre class="notranslate"><code class="notranslate">$ ansible-playbook test.yml --limit localhost

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "msg": true
}

TASK [Run when distro and test list] *******************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when distro and test] ************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when test] ***********************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

PLAY RECAP *********************************************************************
localhost                  : ok=5    changed=0    unreachable=0    failed=0   
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook test.yml --limit localhost --extra-vars bool_test=False

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: false
}

TASK [Run when distro and test list] *******************************************
skipping: [localhost]

TASK [Run when distro and test] ************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when test] ***********************************************************
skipping: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0   "><pre class="notranslate"><code class="notranslate">$ ansible-playbook test.yml --limit localhost --extra-vars bool_test=False

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "msg": false
}

TASK [Run when distro and test list] *******************************************
skipping: [localhost]

TASK [Run when distro and test] ************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when test] ***********************************************************
skipping: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0   
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook test2.yml  --limit localhost

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: false
}

TASK [Run when distro and test list] *******************************************
skipping: [localhost]

TASK [Run when distro and test] ************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when test] ***********************************************************
skipping: [localhost]

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: true
}

TASK [Run when distro and test list] *******************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when distro and test] ************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

TASK [Run when test] ***********************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;true so running&quot;
}

PLAY RECAP *********************************************************************
localhost                  : ok=8    changed=0    unreachable=0    failed=0   "><pre class="notranslate"><code class="notranslate">$ ansible-playbook test2.yml  --limit localhost

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "msg": false
}

TASK [Run when distro and test list] *******************************************
skipping: [localhost]

TASK [Run when distro and test] ************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when test] ***********************************************************
skipping: [localhost]

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

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "msg": true
}

TASK [Run when distro and test list] *******************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when distro and test] ************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when distro] *********************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

TASK [Run when test] ***********************************************************
ok: [localhost] =&gt; {
    "msg": "true so running"
}

PLAY RECAP *********************************************************************
localhost                  : ok=8    changed=0    unreachable=0    failed=0   
</code></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">extra-vars<br>
when</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.1.1.0"><pre class="notranslate"><code class="notranslate">ansible 2.1.1.0
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<h5 dir="auto">OS / ENVIRONMENT</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Darwin alfheim.local 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64"><pre class="notranslate"><code class="notranslate">Darwin alfheim.local 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64
</code></pre></div>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">Unable to pass boolean variable False via <code class="notranslate">--extra-vars</code> arguments</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cat test.yml"><pre class="notranslate"><code class="notranslate">cat test.yml
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- hosts: localhost
  vars:
  - foobar: True
  tasks:
  - debug: var=foobar

  - debug: var=foobar
    when: not foobar

  - debug: var=foobar
    when: foobar

- hosts: localhost
  vars:
  - foobar: False
  tasks:
  - debug: var=foobar

  - debug: var=foobar
    when: not foobar

  - debug: var=foobar
    when: foobar"><pre class="notranslate"><code class="notranslate">- hosts: localhost
  vars:
  - foobar: True
  tasks:
  - debug: var=foobar

  - debug: var=foobar
    when: not foobar

  - debug: var=foobar
    when: foobar

- hosts: localhost
  vars:
  - foobar: False
  tasks:
  - debug: var=foobar

  - debug: var=foobar
    when: not foobar

  - debug: var=foobar
    when: foobar
</code></pre></div>

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

<p dir="auto">Running playbook without passing extra-vars to override foobar variable works as expected.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook -i inventory test.yml"><pre class="notranslate"><code class="notranslate">ansible-playbook -i inventory test.yml
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;foobar&quot;: true
}

TASK [debug] *******************************************************************
skipping: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;foobar&quot;: true
}

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;foobar&quot;: false
}

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;foobar&quot;: false
}

TASK [debug] *******************************************************************
skipping: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=6    changed=0    unreachable=0    failed=0"><pre class="notranslate"><code class="notranslate">PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "foobar": true
}

TASK [debug] *******************************************************************
skipping: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "foobar": true
}

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "foobar": false
}

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "foobar": false
}

TASK [debug] *******************************************************************
skipping: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=6    changed=0    unreachable=0    failed=0
</code></pre></div>
<p dir="auto">Running playbook with passing foobar=True as extra-vars parameter works as expected.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook -i inventory test.yml -e foobar=True"><pre class="notranslate"><code class="notranslate">ansible-playbook -i inventory test.yml -e foobar=True
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;foobar&quot;: true
}

TASK [debug] *******************************************************************
skipping: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;foobar&quot;: true
}

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;foobar&quot;: true
}

TASK [debug] *******************************************************************
skipping: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;foobar&quot;: true
}

PLAY RECAP *********************************************************************
localhost                  : ok=6    changed=0    unreachable=0    failed=0"><pre class="notranslate"><code class="notranslate">PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "foobar": true
}

TASK [debug] *******************************************************************
skipping: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "foobar": true
}

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "foobar": true
}

TASK [debug] *******************************************************************
skipping: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "foobar": true
}

PLAY RECAP *********************************************************************
localhost                  : ok=6    changed=0    unreachable=0    failed=0
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>


<p dir="auto">Running playbook with passing foobar=False as extra-vars parameter does <em>not</em> work as expected. Both <code class="notranslate">when: foobar</code> as <code class="notranslate">when: not foobar</code> are skipped. Only <code class="notranslate">when: foobar</code> should be skipped.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook -i inventory test.yml -e foobar=False"><pre class="notranslate"><code class="notranslate">ansible-playbook -i inventory test.yml -e foobar=False
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;foobar&quot;: false
}

TASK [debug] *******************************************************************
skipping: [localhost]

TASK [debug] *******************************************************************
skipping: [localhost]

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;foobar&quot;: false
}

TASK [debug] *******************************************************************
skipping: [localhost]

TASK [debug] *******************************************************************
skipping: [localhost]

PLAY RECAP *********************************************************************"><pre class="notranslate"><code class="notranslate">PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "foobar": false
}

TASK [debug] *******************************************************************
skipping: [localhost]

TASK [debug] *******************************************************************
skipping: [localhost]

PLAY [localhost] ***************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    "foobar": false
}

TASK [debug] *******************************************************************
skipping: [localhost]

TASK [debug] *******************************************************************
skipping: [localhost]

PLAY RECAP *********************************************************************
</code></pre></div>
<p dir="auto">Note that the variable is interpreted as boolean as it displays <code class="notranslate">'foobar: false'</code>, while if I would pass <code class="notranslate">-e foobar=false"</code> it would show <code class="notranslate">'foobar: "false"'</code> as it then gets interpreted as string. The only way I could get the example to work is when I change <code class="notranslate">when: not foobar</code> to <code class="notranslate">when: not foobar|bool</code>, but this isn't mentioned in the documentation at <a href="http://docs.ansible.com/ansible/playbooks_conditionals.html#the-when-statement" rel="nofollow">http://docs.ansible.com/ansible/playbooks_conditionals.html#the-when-statement</a> (see use of boolean variable epic).</p>
<p dir="auto">Any ideas how to resolve this issue?</p>