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
docs:tips_n_tricks:ansible.html
Table of Contents
Ansible
Make Output human readable
User 'delegate_to' with a different remote user
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:
Using 'become'
- 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:
Using 'ansible_user'
- 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 }}"
Adding user to 'delegate_to'
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:
docs/tips_n_tricks/ansible.html.txt · Last modified: 07.01.2023 12:35 CET by peter