win_become: Added support to become a service user (#30407)

* win_become: Added support to become a service user

* fixes for linting

* changes to get local and network service working

* fixed linting issues again

* pleasing pepe
pull/31506/head
Jordan Borean 7 years ago committed by Matt Davis
parent 4e22677e7d
commit 82fa922491

@ -590,9 +590,6 @@ class PlayContext(Base):
if not self.become_user:
raise AnsibleError(("The 'runas' become method requires a username "
"(specify with the '--become-user' CLI arg, the 'become_user' keyword, or the 'ansible_become_user' variable)"))
if not self.become_pass:
raise AnsibleError(("The 'runas' become method requires a password "
"(specify with the '-K' CLI arg or the 'ansible_become_password' variable)"))
becomecmd = cmd
elif self.become_method == 'doas':

File diff suppressed because it is too large Load Diff

@ -74,6 +74,42 @@
- name: test with module that will return non-zero exit code (https://github.com/ansible/ansible/issues/30468)
vars: *become_vars
setup:
- name: test become with SYSTEM account
win_command: whoami
become: yes
become_method: runas
become_user: SYSTEM
register: whoami_out
- name: verify output
assert:
that:
- whoami_out.stdout_lines[0] == "nt authority\\system"
- name: test become with NetworkService account
win_command: whoami
become: yes
become_method: runas
become_user: NetworkService
register: whoami_out
- name: verify output
assert:
that:
- whoami_out.stdout_lines[0] == "nt authority\\network service"
- name: test become with LocalService account
win_command: whoami
become: yes
become_method: runas
become_user: LocalService
register: whoami_out
- name: verify output
assert:
that:
- whoami_out.stdout_lines[0] == "nt authority\\local service"
# FUTURE: test raw + script become behavior once they're running under the exec wrapper again
# FUTURE: add standalone playbook tests to include password prompting and play become keywords

Loading…
Cancel
Save