docs:tips_n_tricks:ansible.html
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
docs:tips_n_tricks:ansible.html [17.12.2022 15:45 CET] – created peter | docs:tips_n_tricks:ansible.html [07.01.2023 12:35 CET] (current) – [User 'delegate_to' with a different remote user] peter | ||
---|---|---|---|
Line 7: | Line 7: | ||
__References: | __References: | ||
* https:// | * https:// | ||
+ | ===== User ' | ||
+ | Although '' | ||
+ | Following approaches in the task specification did the trick: | ||
+ | ==== Using ' | ||
+ | <code yaml> | ||
+ | - name: Sample delegate_to task with become | ||
+ | delegate_to: | ||
+ | become: yes | ||
+ | become_user: | ||
+ | shell: | | ||
+ | id | ||
+ | whoami | ||
+ | register: shell | ||
+ | |||
+ | - name: Print stdout and stderr | ||
+ | debug: | ||
+ | msg: " | ||
+ | </ | ||
+ | |||
+ | __References__: | ||
+ | * [[https:// | ||
+ | ==== Using ' | ||
+ | <code yaml> | ||
+ | - name: Sample delegate_to task with ansible_user: | ||
+ | delegate_to: | ||
+ | vars: | ||
+ | ansible_user: | ||
+ | shell: | | ||
+ | id | ||
+ | whoami | ||
+ | register: shell | ||
+ | |||
+ | - name: Print stdout and stderr | ||
+ | debug: | ||
+ | msg: " | ||
+ | </ | ||
+ | ==== Adding user to ' | ||
+ | //I consider this dirty// | ||
+ | <code yaml> | ||
+ | - name: Sample delegate_to task with other_user@other_host | ||
+ | delegate_to: | ||
+ | shell: | | ||
+ | id | ||
+ | whoami | ||
+ | register: shell | ||
+ | |||
+ | - name: Print stdout and stderr | ||
+ | debug: | ||
+ | msg: " | ||
+ | </ | ||
+ | |||
+ | __References__: | ||
+ | * [[https:// |
docs/tips_n_tricks/ansible.html.1671288359.txt.gz · Last modified: 17.12.2022 15:45 CET by peter