Debian Codegraph @

test/support/windows-integration/plugins/become/runas.py

raw
1 # -*- coding: utf-8 -*-
2 # Copyright: (c) 2018, Ansible Project
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4 from __future__ import annotations
5
6 DOCUMENTATION = """
7 become: runas
8 short_description: Run As user
9 description:
10 - This become plugins allows your remote/login user to execute commands as another user via the windows runas facility.
11 author: ansible (@core)
12 version_added: "2.8"
13 options:
14 become_user:
15 description: User you 'become' to execute the task
16 ini:
17 - section: privilege_escalation
18 key: become_user
19 - section: runas_become_plugin
20 key: user
21 vars:
22 - name: ansible_become_user
23 - name: ansible_runas_user
24 env:
25 - name: ANSIBLE_BECOME_USER
26 - name: ANSIBLE_RUNAS_USER
27 required: True
28 become_flags:
29 description: Options to pass to runas, a space delimited list of k=v pairs
30 default: ''
31 ini:
32 - section: privilege_escalation
33 key: become_flags
34 - section: runas_become_plugin
35 key: flags
36 vars:
37 - name: ansible_become_flags
38 - name: ansible_runas_flags
39 env:
40 - name: ANSIBLE_BECOME_FLAGS
41 - name: ANSIBLE_RUNAS_FLAGS
42 become_pass:
43 description: password
44 ini:
45 - section: runas_become_plugin
46 key: password
47 vars:
48 - name: ansible_become_password
49 - name: ansible_become_pass
50 - name: ansible_runas_pass
51 env:
52 - name: ANSIBLE_BECOME_PASS
53 - name: ANSIBLE_RUNAS_PASS
54 notes:
55 - runas is really implemented in the powershell module handler and as such can only be used with winrm connections.
56 - This plugin ignores the 'become_exe' setting as it uses an API and not an executable.
57 - The Secondary Logon service (seclogon) must be running to use runas
58 """
59
60 from ansible.plugins.become import BecomeBase
61
62
63 class BecomeModule(BecomeBase):
64
65 name = 'runas'
66
67 def build_become_command(self, cmd, shell):
68 # runas is implemented inside the winrm connection plugin
69 return cmd