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
This commit is contained in:
Jordan Borean 2017-10-10 10:58:29 +10:00 committed by Matt Davis
commit 82fa922491
3 changed files with 744 additions and 542 deletions

View file

@ -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