cf.
Github closed issue - delegate_to with remote_user on ansible 2.0 #13323,
Reddit - Delegate_to and another user,
google.groups - Indicating username with delegate_to
Although remote_user
ought to work by task with delegate_to
1) it doen't when I tried.
Following approaches in the task specification did the trick:
- name: Sample delegate_to task with become delegate_to: other_host become: yes become_user: other_user shell: | id whoami register: shell - name: Print stdout and stderr debug: msg: "OUT:\n{{ shell.stdout}}\nERROR:\n{{ shell.stderr }}"
References:
- name: Sample delegate_to task with ansible_user: other_user delegate_to: other_host vars: ansible_user: other_user shell: | id whoami register: shell - name: Print stdout and stderr debug: msg: "OUT:\n{{ shell.stdout}}\nERROR:\n{{ shell.stderr }}"
I consider this dirty
- name: Sample delegate_to task with other_user@other_host delegate_to: other_user@other_host shell: | id whoami register: shell - name: Print stdout and stderr debug: msg: "OUT:\n{{ shell.stdout}}\nERROR:\n{{ shell.stderr }}"
References: