Issue with variable not interpolated using synchronize module

Hello,
I created a playbook with a simple role to try the synchronize module, but when I run the playbook the hostname variable is not resolved and I get this error:

ssh: Could not resolve hostname {{ app.vm.hostname }}

The expected value should be vm.station; I don’t understand the reason, but for example the ssh user is interpolated correctly (see the verbose output at the end of this post). Any help on what to change to make it work would be greatly appreciated.

Python: 3.6.1 / Ansible: 2.4.2.0

Directory layout:

`

.
├── ansible.cfg
├── hosts
├── playbook.yml
├── roles
│ └── config
│ └── tasks
│ └── main.yaml
└── vars
└── main.yml
`

ansible.cfg:

[defaults] inventory = ./hosts roles_path = ./roles

hosts:

all: hosts: vm: ansible_host: "{{ app.vm.hostname }}" ansible_user: "{{ app.vm.user.username }}" ansible_ssh_pass: "{{ app.vm.user.password }}" ansible_python_interpreter: /usr/bin/python3

vars/main.yml:

`
app: {
‘vm’: {
user: {
username: “user”,
password: “user”
},
hostname: “vm.station”
}
}

`

playbook.yml:

`

  • hosts: all
    become: true
    vars_files:
  • vars/main.yml
    roles:
  • {role: ‘config’, tags: ‘config-all’}
    `

roles/config/tasks/main.yaml:

`

  • synchronize:
    src: /tmp/foobar.txt
    dest: /tmp
    `

Command and output:

`
$ ansible-playbook playbook.yml -K -vvv


TASK [config : synchronize] *****************************************************************
fatal: [vm]: FAILED! => {
“changed”: false,
“cmd”: “/usr/bin/rsync --delay-updates -F --compress --archive --rsh=/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null --rsync-path=sudo rsync --out-format=<>%i %n%L /tmp/foobar.txt user@{{ app.vm.hostname }}:/tmp”,
“invocation”: {
“module_args”: {
“_local_rsync_path”: “rsync”,
“_substitute_controller”: false,
“archive”: true,
“checksum”: false,
“compress”: true,
“copy_links”: false,
“delete”: false,
“dest”: “user@{{ app.vm.hostname }}:/tmp”, # <-------- LOOK HERE
“dest_port”: null,
“dirs”: false,
“existing_only”: false,
“group”: null,
“links”: null,
“mode”: “push”,
“owner”: null,
“partial”: false,
“perms”: null,
“private_key”: null,
“recursive”: null,
“rsync_opts”: null,
“rsync_path”: “sudo rsync”,
“rsync_timeout”: 0,
“set_remote_user”: true,
“src”: “/tmp/foobar.txt”,
“ssh_args”: null,
“times”: null,
“verify_host”: false
}
},
“msg”: “ssh: Could not resolve hostname {{ app.vm.hostname }}: Name or service not known\r\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]\n”,
“rc”: 255
}
to retry, use: --limit @/tmp/ansible_webdev/playbook.retry

`