Hi,
I have one script which includes another and now with ansible 2.2 it generates a fatal error:
script 1: t.yml
---
- hosts: localhost
connection: local
gather_facts: no
tasks:
- set_fact: check_number="0"
- include: y.yml
when: check_number == "1"
script 2: y.yml
---
- set_fact: mymsg="Does this work"
- shell: echo "{{ item }}"
with_items:
- "{{ mymsg }}"
If I execute the script in ansible 2.2 it fails
$ ansible-playbook t.yml
PLAY [localhost] ***************************************************************
TASK [set_fact] ****************************************************************
ok: [localhost]
TASK [set_fact] ****************************************************************
skipping: [localhost]
TASK [command] *****************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "'mymsg' is undefined"}
to retry, use: --limit @/devops/provision/ansible/t.retry
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1
It always ran with previous version although with a error message
$ ansible-playbook t.yml
statically included: /Users/hrf/jelli/devops/provision/ansible/y.yml
PLAY [localhost] ***************************************************************
TASK [set_fact] ****************************************************************
ok: [localhost]
TASK [set_fact] ****************************************************************
skipping: [localhost]
TASK [command] *****************************************************************
[DEPRECATION WARNING]: Skipping task due to undefined Error, in the future this will be a fatal error.: 'mymsg' is undefined.
This feature will be removed in a future release.
Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
skipping: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
This was done before blocks were available. It was my way of executing a block of code on a conditional basis. It seems reasonable that this should work even with ansible 2.2 without being a fatal error.
Thanks,
-Harold