File: test_k_and_K.py

package info (click to toggle)
ansible-core 2.19.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 32,944 kB
  • sloc: python: 181,408; cs: 4,929; sh: 4,661; xml: 34; makefile: 21
file content (25 lines) | stat: -rw-r--r-- 583 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python3
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import annotations

import os
import sys

import pexpect

os.environ['ANSIBLE_NOCOLOR'] = '1'

out = pexpect.run(
    'ansible -c ssh -i localhost, -u cliuser1 -e ansible_python_interpreter={0} '
    '-m command -a whoami -Kkb --become-user cliuser2 localhost'.format(sys.argv[1]),
    events={
        'SSH password:': 'secretpassword\n',
        'BECOME password': 'secretpassword\n',
    },
    timeout=10
)

print(out)

assert b'cliuser2' in out