Kai Stian Olstad
unread,Sep 12, 2016, 7:09:10 AM9/12/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
Hi
I have this simple example.
It work as expected in v2.0.2 but not in 2.1.1
task1.yml
---
- name: Task 1
command: echo "1"
register: result
task2.yml
---
- name: Task 2
command: echo "2"
register: result
playbook.yml
---
- hosts: localhost
vars:
task: "1"
tasks:
- include: task1.yml
when: task == "1"
- include: task2.yml
when: task == "2"
- debug: var=result
Here task 1 should run and task 2 should be skipped, and the content in
result should be from task 1.
In Ansible 2.0.2 I get the result from task 1:
$ ansible-playbook playbook.yml
PLAY [localhost]
***************************************************************
TASK [include]
*****************************************************************
included: /home/kaistian/ansible/test/task1.yml for localhost
TASK [Task 1]
******************************************************************
changed: [localhost]
TASK [include]
*****************************************************************
skipping: [localhost]
TASK [debug]
*******************************************************************
ok: [localhost] => {
"result": {
"changed": true,
"cmd": [
"echo",
"1"
],
"delta": "0:00:00.001446",
"end": "2016-09-12 12:40:38.107604",
"rc": 0,
"start": "2016-09-12 12:40:38.106158",
"stderr": "",
"stdout": "1",
"stdout_lines": [
"1"
],
"warnings": []
}
}
In Ansible 2.1.1 result is overwritten, presumably but the skipped task
2.
$ ansible-playbook playbook.yml
PLAY [localhost]
***************************************************************
TASK [Task 1]
******************************************************************
changed: [localhost]
TASK [Task 2]
******************************************************************
skipping: [localhost]
TASK [debug]
*******************************************************************
ok: [localhost] => {
"result": {
"changed": false,
"skip_reason": "Conditional check failed",
"skipped": true
}
}
Is this a bug in Ansible 2.1.1 or is it a new feature?
--
Kai Stian Olstad