Last active
May 24, 2016 04:21
-
-
Save janzenz/8030b104c109df3b59f26d133c8af03b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: web2 | |
gather_facts: no | |
remote_user: vagrant | |
tasks: | |
- name: debug user 1 | |
shell: "whoami" | |
- name: debug user 2 | |
shell: "whoami" | |
become: yes | |
become_user: root | |
- name: debug user 3 | |
shell: "whoami" | |
# Result: | |
# vagrant | |
# root | |
# vagrant |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah. This is expected behavior but I see how my answer on SO may have misled you. The new directives/command line options I referred to are set these options on a per-host or per-play basis (these are different from become/become_user, as described in the linked documentation). If you use the become directive in a task, it will indeed be scoped to that task as your gist demonstrates. Sorry for the misunderstanding. If you want to have escalation run for multiple tasks, I think you can use the include task and set the become_user directive on it—not 100% sure though.