Hi all
I need to trigger an action (generating a file using template) on another server during a play run. Naturally I used delegation. However, if I use variables like ansible_hostname I get the values from the original host. That’s indeed what I would expect on most cases, but is there a way to use the “context” of the target server?
Example playbook:
- hosts: source
tasks: - debug: var=ansible_hostname
delegate_to: target
What I get:
TASK: [debug var=ansible_hostname] ********************************************
ok: [localhost] => {
“ansible_hostname”: “source”
}
What I want to get:
TASK: [debug var=ansible_hostname] ********************************************
ok: [localhost] => {
“ansible_hostname”: “target”
}
Thanks!