Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

Lookup plugin API, vars, templating? Not exactly sure.

ANSIBLE VERSION

ansible 2.4.2.0
config file = None
configured module search path = [u'/Users/dale/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /Users/dale/.vpy/2.7/lib/python2.7/site-packages/ansible
executable location = /Users/dale/.vpy/2.7/bin/ansible
python version = 2.7.14 (default, Sep 22 2017, 00:05:22) [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]

CONFIGURATION

Default configuration in use

OS / ENVIRONMENT

Mac OS X 10.11.6

SUMMARY

Inventory variables (and probably other variables too) seen from a lookup plugin do not have Jinja expressions expanded.

I cannot tell if this is related to, or even duplicate of, #20545. I'm also not sure if this is a regression of other issues such as #8213.

STEPS TO REPRODUCE

inventory.yml:

all:
hosts:
localhost:
foo: bar
baz: '{{ foo }}'

lookup_plugins/example_plugin.py:

from ansible.plugins import lookup as ansible_lookup
class LookupModule(ansible_lookup.LookupBase):
def run(self, terms, variables=None, **kwargs):
return [variables['baz']]

site.yml:

- hosts: localhost
gather_facts: false
tasks:
- debug:
msg: 'should say "bar": {{ baz }}'
- debug:
msg: 'should say "bar": {{ lookup("example_plugin") }}'

EXPECTED RESULTS

I expected {{ foo }} to be expanded like so:

$ ansible-playbook -i inventory.yml -l localhost site.yml

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

TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "should say \"bar\": bar"
}

TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "should say \"bar\": bar"
}

ACTUAL RESULTS

The lookup plugin sees {{ foo }} instead of the expansion of that into bar:

$ ansible-playbook -i inventory.yml -l localhost site.yml

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

TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "should say \"bar\": bar"
}

TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "should say \"bar\": {{ foo }}"
}

Issue 2:
ISSUE TYPE

Bug Report

ANSIBLE VERSION

ansible 2.1.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides

CONFIGURATION

[ssh_connection]

ssh_args = -o ControlMaster=no -o ControlPersist=60s

OS / ENVIRONMENT

Control machine: OSX El Capitan latest

Target Machine: VMWare Debian 3.13.0-91-generic

SUMMARY

delegate_to causes wrong user to be used to connect to target machine

STEPS TO REPRODUCE

I have an inventory file as such:

build_machine ansible_host=localhost ansible_connection=local
staging_machine ansible_host=my.staging.host ansible_user=stager

I have a playbook running synchronize:

- name: Copy build to staging
hosts: staging_machine
tasks:
- synchronize: src=somefolder dest=otherfolder
delegate_to: staging_machine
remote_user: stager

EXPECTED RESULTS

I expected the playbook to synchronize folders between build and staging machine.

ACTUAL RESULTS

The task prompts for password of the wrong user:

local-mac-user@my-staging-host's password:

Playbook works with version 2.0.2.0.