Last active
September 21, 2016 17:09
-
-
Save odyssey4me/7cdcc70a60895a1280221e454cff10b6 to your computer and use it in GitHub Desktop.
Ansible 2.1.1 regression for conditional include handling: https://github.com/ansible/ansible/issues/17687
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
apt-get update && \ | |
apt-get purge -y nano && \ | |
apt-get install -y git vim tmux fail2ban build-essential python2.7 python-dev libssl-dev libffi-dev | |
curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python2.7 | |
pip install ansible==2.1.0 | |
ansible-playbook -i inventory.ini 02-playbook.yml -vv | |
pip install -U ansible==2.1.1 | |
ansible-playbook -i inventory.ini 02-playbook.yml -vv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[all] | |
localhost ansible_connection=local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Test conditional block (yes) | |
hosts: localhost | |
gather_facts: false | |
tasks: | |
- block: | |
- debug: | |
msg: "block -> include_me: {{ include_me }}" | |
- debug: | |
msg: "block -> arbitrary message" | |
when: include_me | bool | |
vars: | |
include_me: yes | |
- name: Test conditional block (no) | |
hosts: localhost | |
gather_facts: false | |
tasks: | |
- block: | |
- debug: | |
msg: "block -> include_me: {{ include_me }}" | |
- debug: | |
msg: "block -> arbitrary message" | |
when: include_me | bool | |
vars: | |
include_me: no | |
- name: Test conditional include (yes) | |
hosts: localhost | |
gather_facts: false | |
tasks: | |
- include: 03-included-task.yml | |
when: include_me | bool | |
vars: | |
include_me: yes | |
- name: Test conditional include (no) | |
hosts: localhost | |
gather_facts: false | |
tasks: | |
- include: 03-included-task.yml | |
when: include_me | bool | |
vars: | |
include_me: no | |
- name: Test both conditional block and conditional include together (yes) | |
hosts: localhost | |
gather_facts: false | |
tasks: | |
- block: | |
- debug: | |
msg: "block -> include_me: {{ include_me }}" | |
- debug: | |
msg: "block -> arbitrary message" | |
- include: 03-included-task.yml | |
when: include_me | bool | |
vars: | |
include_me: yes | |
- name: Test both conditional block and conditional include together (yes) | |
hosts: localhost | |
gather_facts: false | |
tasks: | |
- block: | |
- debug: | |
msg: "block -> include_me: {{ include_me }}" | |
- debug: | |
msg: "block -> arbitrary message" | |
- include: 03-included-task.yml | |
when: include_me | bool | |
vars: | |
include_me: no |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- debug: | |
msg: "included-task -> include_me: {{ include_me }}" | |
- debug: | |
msg: "included-task -> arbitrary message" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@ansible1:~# ansible-playbook -i inventory.ini 02-playbook.yml -vv | |
No config file found; using defaults | |
PLAYBOOK: 02-playbook.yml ****************************************************** | |
6 plays in 02-playbook.yml | |
PLAY [Test conditional block (yes)] ******************************************** | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:7 | |
ok: [localhost] => { | |
"msg": "block -> include_me: True" | |
} | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:9 | |
ok: [localhost] => { | |
"msg": "block -> arbitrary message" | |
} | |
PLAY [Test conditional block (no)] ********************************************* | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:20 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:22 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
PLAY [Test conditional include (yes)] ****************************************** | |
TASK [include] ***************************************************************** | |
task path: /root/02-playbook.yml:32 | |
included: /root/03-included-task.yml for localhost | |
TASK [debug] ******************************************************************* | |
task path: /root/03-included-task.yml:2 | |
ok: [localhost] => { | |
"msg": "included-task -> include_me: True" | |
} | |
TASK [debug] ******************************************************************* | |
task path: /root/03-included-task.yml:5 | |
ok: [localhost] => { | |
"msg": "included-task -> arbitrary message" | |
} | |
PLAY [Test conditional include (no)] ******************************************* | |
TASK [include] ***************************************************************** | |
task path: /root/02-playbook.yml:41 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
PLAY [Test both conditional block and conditional include together (yes)] ****** | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:51 | |
ok: [localhost] => { | |
"msg": "block -> include_me: True" | |
} | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:53 | |
ok: [localhost] => { | |
"msg": "block -> arbitrary message" | |
} | |
TASK [include] ***************************************************************** | |
task path: /root/02-playbook.yml:55 | |
included: /root/03-included-task.yml for localhost | |
TASK [debug] ******************************************************************* | |
task path: /root/03-included-task.yml:2 | |
ok: [localhost] => { | |
"msg": "included-task -> include_me: True" | |
} | |
TASK [debug] ******************************************************************* | |
task path: /root/03-included-task.yml:5 | |
ok: [localhost] => { | |
"msg": "included-task -> arbitrary message" | |
} | |
PLAY [Test both conditional block and conditional include together (yes)] ****** | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:65 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:67 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
TASK [include] ***************************************************************** | |
task path: /root/02-playbook.yml:69 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
PLAY RECAP ********************************************************************* | |
localhost : ok=10 changed=0 unreachable=0 failed=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@ansible1:~# ansible-playbook -i inventory.ini 02-playbook.yml -vv | |
No config file found; using defaults | |
PLAYBOOK: 02-playbook.yml ****************************************************** | |
6 plays in 02-playbook.yml | |
PLAY [Test conditional block (yes)] ******************************************** | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:7 | |
ok: [localhost] => { | |
"msg": "block -> include_me: True" | |
} | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:9 | |
ok: [localhost] => { | |
"msg": "block -> arbitrary message" | |
} | |
PLAY [Test conditional block (no)] ********************************************* | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:20 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:22 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
PLAY [Test conditional include (yes)] ****************************************** | |
TASK [debug] ******************************************************************* | |
task path: /root/03-included-task.yml:2 | |
ok: [localhost] => { | |
"msg": "included-task -> include_me: True" | |
} | |
TASK [debug] ******************************************************************* | |
task path: /root/03-included-task.yml:5 | |
ok: [localhost] => { | |
"msg": "included-task -> arbitrary message" | |
} | |
PLAY [Test conditional include (no)] ******************************************* | |
TASK [debug] ******************************************************************* | |
task path: /root/03-included-task.yml:2 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
TASK [debug] ******************************************************************* | |
task path: /root/03-included-task.yml:5 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
PLAY [Test both conditional block and conditional include together (yes)] ****** | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:51 | |
ok: [localhost] => { | |
"msg": "block -> include_me: True" | |
} | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:53 | |
ok: [localhost] => { | |
"msg": "block -> arbitrary message" | |
} | |
TASK [debug] ******************************************************************* | |
task path: /root/03-included-task.yml:2 | |
ok: [localhost] => { | |
"msg": "included-task -> include_me: True" | |
} | |
TASK [debug] ******************************************************************* | |
task path: /root/03-included-task.yml:5 | |
ok: [localhost] => { | |
"msg": "included-task -> arbitrary message" | |
} | |
PLAY [Test both conditional block and conditional include together (yes)] ****** | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:65 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
TASK [debug] ******************************************************************* | |
task path: /root/02-playbook.yml:67 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
TASK [debug] ******************************************************************* | |
task path: /root/03-included-task.yml:2 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
TASK [debug] ******************************************************************* | |
task path: /root/03-included-task.yml:5 | |
skipping: [localhost] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true} | |
PLAY RECAP ********************************************************************* | |
localhost : ok=8 changed=0 unreachable=0 failed=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment