Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

core, I think?

ANSIBLE VERSION

ansible 2.3.0.0
config file = /Users/oliver/.ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.11 (default, Jan 22 2016, 08:29:18) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]

CONFIGURATION

My ~/.ansible.cfg contains only the following:

[defaults]
transport=paramiko
timeout=60
remote_tmp = /tmp/.ansible/tmp

OS / ENVIRONMENT

Running on macOS Sierra 10.12.4

Managing OEL 6.4

SUMMARY

I'm trying to specify a role dependency, giving a path to the dependency role that includes a variable defined in my group_vars, but I get ERROR! 'common_roles_path' is undefined. It only works if I define the variable in the play that uses the role.

STEPS TO REPRODUCE

My directory structure is as follows

common_roles/
foo/
project/
group_vars/
all.yml
roles/
server/
defaults/
main.yml
meta/
main.yml
tasks/
main.yml
vars/
main.yml
hosts
sites.yml

project/group_vars/all.yml, project/roles/server/defaults/main.yml and project/roles/server/vars/main.yml all contain

---

common_roles_path: "{{ playbook_dir }}/../common_roles"

project/roles/server/meta/main.yml contains

---

dependencies:
- role: "{{ common_roles_path }}/foo"

project/roles/server/tasks/main.yml contains

---

- include_role:
name: "{{ common_roles_path }}/foo"

project/hosts contains

[servers]
project.dev.vm

project/sites.yml contains

---

- name: Install project server
hosts: servers
roles:
- server

EXPECTED RESULTS

I expect the role at common_roles/foo to be executed as a dependency, then run again due to the include_role task.

ACTUAL RESULTS

I get the following:

$ ansible-playbook -vvvv -i hosts sites.yml
Using /Users/oliver/.ansible.cfg as config file
ERROR! 'common_roles_path' is undefined

However, if I modify project/sites.yml to contain

---

- name: Install project server
hosts: servers
roles:
- server
vars:
common_roles_path: "{{ playbook_dir }}/../common_roles"

then everything works as expected. It also works if I remove project/roles/server/meta and just rely on the include_role task (so the same variable used there is OK).

The duplicate variable definitions in project/roles/server/defaults and project/roles/server/vars were only added to check if it was some scoping issue, their presence or absence makes no difference.

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

Modules using Python Lambda/Map functions

ANSIBLE VERSION

ansible --version
ansible 2.2.1.0
config file = /automation/ansible/playbooks/ansible.cfg
configured module search path = ['library']

CONFIGURATION

[defaults]
forks = 50
transport = smart
gathering = explicit
library = library
action_plugins = action_plugins
callback_plugins = callback_plugins
lookup_plugins = lookup_plugins
vars_plugins = vars_plugins
filter_plugins = filter_plugins
roles_path = roles:provisioning/roles
bin_ansible_callbacks = True
force_color = 1
host_key_checking = False
retry_files_enabled = False

[ssh_connection]
# Using control persist allows for connection re-use and can improve
# performance by a large margin, *IF* it is compatible with our setup
# -> needs to be checked first...
ssh_args = -o ControlMaster=auto -o ControlPersist=1h -vvv
pipelining = True

OS / ENVIRONMENT

CentOS 6.4

SUMMARY

We are in process of upgrading our Ansible 1.8.2 code to Ansible 2.x. We have custom Ansible modules that use common 'lambda' and 'map' Python functions to manipulate a list of instances (basically a list containing dictionaries). We noticed the lambda/map function combination is producing different results in Ansible 1.8.2 compared to Ansible 2.2.1.0. Using Ansible 2.x the lambda/map functions do not result in changing the variable at all. However using Ansible 1.x the correct changes are done. The Python version is the same for both Ansible 1.x and Ansible 2.x (Python 2.7.10). The only changes are the necessary upgrades that are done using pip command to upgrade to Ansible 2.x.

STEPS TO REPRODUCE

Create a custom module using the following code, and then call this module using a simple playbook with a task:

import traceback
def addme(i):
i['my'] = 'test'

def main(module):
result = {
'changed': False,
'timings': {}
}

try:
x = [{"example-key": "example-value"}]
f = lambda i:addme(i)
y = map(f, x)
result['x'] = x
result['y'] = str(y)
module.exit_json(**result)
except Exception:
module.fail_json(msg=traceback.format_exc().splitlines())
module.exit_json(**result)
}

EXPECTED RESULTS

We expect that the 'addme' function adds the key 'my' with value 'test' to the variable 'x'.

Ansible 1.x produces this result, however Ansible 2.x does not add this key/value and does not have any errors at all.

The results of 'x' should be:

"x": [
{
"example-key": "example-value",
"my": "test"
}
],

ACTUAL RESULTS

Using Ansible 2.x we actually get no change to the 'x' variable:

"x": [
{
"example-key": "example-value"
}
],