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

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/de2aaa007b6ee8c448dfca0a3f5b7a88%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to