Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

dependency

ANSIBLE VERSION

ansible 2.1.3.0
config file =
configured module search path = Default w/o overrides

CONFIGURATION

default configuration without any changes

OS / ENVIRONMENT

N/A (tested on Mac and Windows)

SUMMARY

Variables that get available by using dependencies in meta-information of a role do not propagate their variables correctly if they got set during inclusion of the role.

I have not found anything in the changelog or documentation stating that this is now changed and correct behaviour, so I assume that it is a bug.

STEPS TO REPRODUCE

One has two roles, one base-role and one role that will be used as a dependency role in the base role:

example-role

meta/main.yml

---

dependencies:
- role: dependency-role
base_path: "/another/base"

tasks/main.yml

---

- name: show example role ouput
debug:
msg: "base_path={{ base_path }}, detailled_path={{ detailled_path }}"

dependency-role

vars/main.yml

---

base_path: "/some/base/path"

detailled_path: "{{ base_path }}/detailed"

tasks/main.yml

---

- name: show example role ouput
debug:
msg: "base_path={{ base_path }}, detailled_path={{ detailled_path }}"

playbook

---

- hosts: localhost
gather_facts: no
connection: local
become: no
roles:
- dependency-role
- example-role

EXPECTED RESULTS

As of Ansible 2.0.2.0, the variable adjusted by including the dependency-role is available in the example-role after solving the dependency:

No config file found; using defaults

PLAYBOOK: play.yml *************************************************************
1 plays in play.yml

PLAY [localhost] ***************************************************************

TASK [dependency-role : Show dependency debut output] **************************
task path: /Users/stli/projects/ansible-test/roles/dependency-role/tasks/main.yml:3
ok: [localhost] => {
"msg": "base_path=/some/base/path, detailled_path=/some/base/path/detailed"
}

TASK [dependency-role : Show dependency debut output] **************************
task path: /Users/stli/projects/ansible-test/roles/dependency-role/tasks/main.yml:3
ok: [localhost] => {
"msg": "base_path=/another/base, detailled_path=/another/base/detailed"
}

TASK [example-role : show example role ouput] **********************************
task path: /Users/stli/projects/ansible-test/roles/example-role/tasks/main.yml:3
ok: [localhost] => {
"msg": "base_path=/another/base, detailled_path=/another/base/detailed"
}

PLAY RECAP *********************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0

ACTUAL RESULTS

In Ansible 2.1.3.0 (also tested in 2.1.0.0 - 2.1.2.0), the variable will use its defaults afterwards, without taking the included variable in account

No config file found; using defaults

PLAYBOOK: play.yml *************************************************************
1 plays in play.yml

PLAY [localhost] ***************************************************************

TASK [dependency-role : Show dependency debut output] **************************
task path: /Users/stli/projects/ansible-test/roles/dependency-role/tasks/main.yml:3
ok: [localhost] => {
"msg": "base_path=/some/base/path, detailled_path=/some/base/path/detailed"
}

TASK [dependency-role : Show dependency debut output] **************************
task path: /Users/stli/projects/ansible-test/roles/dependency-role/tasks/main.yml:3
ok: [localhost] => {
"msg": "base_path=/another/base, detailled_path=/another/base/detailed"
}

TASK [example-role : show example role ouput] **********************************
task path: /Users/stli/projects/ansible-test/roles/example-role/tasks/main.yml:3
ok: [localhost] => {
"msg": "base_path=/some/base/path, detailled_path=/some/base/path/detailed"
}

PLAY RECAP *********************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0

The whole test can be found in a repo of mine, including the output of the different versions I tried this with.

Issue 2:
ISSUE TYPE

Bug Report

ANSIBLE VERSION

Commit 3b69ef7e8b34d736770aed8f2b31cfec522ed2d8

CONFIGURATION

Ansible from Source (since commit 33de770 ) and dependencies with pip

OS / ENVIRONMENT

Docker Image library/jenkins:1.651.1 with Ansible from Source

Also Ubuntu 16.04

SUMMARY

Ansible is confused by passing dictionaries through nested role dependencie calls. See steps to reproduce and expected/actual results for explanation.

STEPS TO REPRODUCE

The following files will demonstrate the bug and are also available for download at https://github.com/ThomasSteinbach/ansible_bug_15996

Playbooks site.yml:

roles:
- role: testone
onevar: onevarcontent

testone/meta/main.yml:

dependencies:
- role: testtwo
initial:
ONE: "{{ onevar }}"
TWO: zwei

testtwo/meta/main.yml:

dependencies:
- role: testthree
inside_var: "{{ initial.ONE }}"

testthree/tasks/main.yml:

- include: test.yml

testthree/tasks/test.yml

- debug: msg="everythingsfine"
when: "{{ inside_var == 'onevarcontent' }}"

EXPECTED RESULTS

Ansible 2.0.2.0 installed with pip behaves like expected:

PLAY [this playbook is for testing purposes] ***********************************

TASK [testthree : include] *****************************************************
included: /home/uid1000/ansible/ansible_playbooks/test/roles/testthree/tasks/test.yml for localhost

TASK [testthree : debug] *******************************************************
ok: [localhost] => {
"msg": "everythingsfine"
}

ACTUAL RESULTS

The latest Ansible version from source seems to be broken and leads to following result:

PLAY [this playbook is for testing purposes] ***********************************

TASK [testthree : include] *****************************************************
included: /var/jenkins_home/workspace/develop/xarifP/test/roles/testthree/tasks/test.yml for acia.vm

TASK [testthree : debug] *******************************************************
fatal: [acia.vm]: FAILED! => {"failed": true, "msg": "The conditional check '{{ inside_var == 'onevarcontent' }}' failed. The error was: error while evaluating conditional ({{ inside_var == 'onevarcontent' }}): {{ initial.ONE }}: 'initial' is undefined\n\nThe error appears to have been in '/var/jenkins_home/workspace/develop/xarifP/test/roles/testthree/tasks/test.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- debug: msg=\"everythingsfine\"\n ^ here\n"}