Issue 1:
Hi,

i'm facing an issue with the with_items option in combination with a variable to replace + a fixed string behind the variable name. The issue came up after updating from 1.9.4 to 2.0.0.2.

Environment:

Ansible: 2.0.0.2-1

OS: Ubuntu 14.04

Python: 2.7.5-5ubuntu3

Steps To Reproduce:

site.yml

---
- hosts: localhost
tags: withitems
roles:
- { role: withitems }

roles/withitems/tasks/main.yml

---
- name: debug01
debug: msg={{ role_name }}

- name: debug02
debug: msg="{{ role_name }}_anystring"
with_items: nameofrole_anystring

- name: debug03
debug: msg={{ item.name }}
with_items: nameofrole_anystring

- name: debug04
debug: msg={{ item }}
with_items: "{{ role_name }}_anystring"

- name: debug05
debug: msg={{ item.name }}
with_items:
- { name: foo }

- name: debug06
debug: msg={{ item.name }}
with_items: "{{ role_name }}_anystring"

roles/withitems/vars/main.yml

---
role_name: nameofrole

nameofrole_anystring:
- { name: foo }

When executing this on Ansible 1.9.4:

:~ ansible --version
ansible 1.9.4
configured module search path = None

:~ ansible-playbook testsite.yml --tags withitems

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

TASK: [withitems | debug01] ***************************************************
ok: [localhost] => {
"msg": "nameofrole"
}

TASK: [withitems | debug02] ***************************************************
ok: [localhost] => (item={'name': 'foo'}) => {
"item": {
"name": "foo"
},
"msg": "nameofrole_anystring"
}

TASK: [withitems | debug03] ***************************************************
ok: [localhost] => (item={'name': 'foo'}) => {
"item": {
"name": "foo"
},
"msg": "foo"
}

TASK: [withitems | debug04] ***************************************************
ok: [localhost] => (item={'name': 'foo'}) => {
"item": {
"name": "foo"
},
"msg": "{'name':"
}

TASK: [withitems | debug05] ***************************************************
ok: [localhost] => (item={'name': 'foo'}) => {
"item": {
"name": "foo"
},
"msg": "foo"
}

TASK: [withitems | debug06] ***************************************************
ok: [localhost] => (item={'name': 'foo'}) => {
"item": {
"name": "foo"
},
"msg": "foo"
}

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

When executing this on Ansible 2.0.0.2:

:~ ansible --version
ansible 2.0.0.2
config file = /root/ansible-test/ansible.cfg
configured module search path = Default w/o overrides

:~ ansible-playbook testsite.yml --tags withitems

PLAY ***************************************************************************

TASK [withitems : debug01] *****************************************************
ok: [localhost] => {
"msg": "withitems"
}

TASK [withitems : debug02] *****************************************************
ok: [localhost] => (item={u'name': u'foo'}) => {
"item": {
"name": "foo"
},
"msg": "withitems_anystring"
}

TASK [withitems : debug03] *****************************************************
ok: [localhost] => (item={u'name': u'foo'}) => {
"item": {
"name": "foo"
},
"msg": "foo"
}

TASK [withitems : debug04] *****************************************************
ok: [localhost] => (item=withitems_anystring) => {
"item": "withitems_anystring",
"msg": "withitems_anystring"
}

TASK [withitems : debug05] *****************************************************
ok: [localhost] => (item={u'name': u'foo'}) => {
"item": {
"name": "foo"
},
"msg": "foo"
}

TASK [withitems : debug06] *****************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "ERROR! 'unicode object' has no attribute 'name'"}

PLAY RECAP *********************************************************************
localhost : ok=5 changed=0 unreachable=0 failed=1

Actual Results:

Using with_items: "{{ variable_name }}_fixedstring" the playbook fails to find attributes on the item.

Expected Results:

Usage of above combination is able to find attributes like it was in version <2.0.

Let me know if i can provide further details. Thank you for your help.

Issue 2:
Issue Type: Bug Report/Regression

Ansible Version:

ansible 2.0.0 (f41dd57)

Ansible Configuration:

self-packaged version based on above revision

Environment:

openSuSE Leap 42.1

Summary:

Substituting variable names based on other variables does not work in ansible 2.0.0 but used to work in 1.9.4.

This should either be fixed or stated more prominently in the Changelog as it breaks existing playbooks.

Steps To Reproduce:

Example playbook:

vars:
packages_install_42:
- bash
- zsh

tasks:
- name: install stuff
zypper: name={{item}} state=present
with_items: packages_install_{{ansible_distribution_major_version}}

Expected Results:

Variable packages_install_42 is used, the packages bash and zsh are installed.

Actual Results:

The task fails:

(item=[u'packages_install_42']) => {"failed": true, "item": ["packages_install_42"], "msg": "No provider of 'packages_install_42' found.\n", "rc": 104}