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:
parent
4e22677e7d
commit
82fa922491
3 changed files with 744 additions and 542 deletions
|
@ -590,9 +590,6 @@ class PlayContext(Base):
|
||||||
if not self.become_user:
|
if not self.become_user:
|
||||||
raise AnsibleError(("The 'runas' become method requires a username "
|
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)"))
|
"(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
|
becomecmd = cmd
|
||||||
|
|
||||||
elif self.become_method == 'doas':
|
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)
|
- name: test with module that will return non-zero exit code (https://github.com/ansible/ansible/issues/30468)
|
||||||
vars: *become_vars
|
vars: *become_vars
|
||||||
setup:
|
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: 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
|
# FUTURE: add standalone playbook tests to include password prompting and play become keywords
|
||||||
|
|
Loading…
Reference in a new issue