$ cat inv
local ansible_connection=local
$ cat extra.yml
---
- set_fact: bar=hello
- debug: msg="baz {{ bar }}"
$ cat playbook.yml
---
- hosts: local
tasks:
- include: extra.yml
when: bar is not defined
$ ansible-playbook -i inv playbook.yml
PLAY [local] ******************************************************************
GATHERING FACTS ***************************************************************
ok: [local]
TASK: [set_fact bar=hello] ****************************************************
ok: [local]
TASK: [debug msg="baz {{ bar }}"] *********************************************
skipping: [local]
PLAY RECAP ********************************************************************
local : ok=2 changed=0 unreachable=0 failed=0
$
On 11/11/14 18:32, Petros Moisiadis wrote:
Obviously, I meant 'when: ...' and not 'with: ...'Hello,
Does it work as expected if you replace "with: bar is not defined" with "with: bar is undefined" ?