mirror of https://github.com/ansible/ansible.git
Deprecate AGNOSTIC_BECOME_PROMPT
Fixes: #81501 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>pull/84273/head
parent
157ef04b1e
commit
635fd95283
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- become - deprecate AGNOSTIC_BECOME_PROMPT (https://github.com/ansible/ansible/issues/81501).
|
@ -0,0 +1,6 @@
|
|||||||
|
destructive
|
||||||
|
needs/root
|
||||||
|
needs/ssh
|
||||||
|
needs/target/setup_pexpect
|
||||||
|
shippable/posix/group5
|
||||||
|
context/controller
|
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
ANSIBLE_ROLES_PATH=../ ansible-playbook setup.yml
|
@ -0,0 +1,42 @@
|
|||||||
|
- hosts: localhost
|
||||||
|
gather_facts: yes
|
||||||
|
roles:
|
||||||
|
- setup_pexpect
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Test ansible-playbook with AGNOSTIC_BECOME_PROMPT=False
|
||||||
|
block:
|
||||||
|
- name: Create user to connect as
|
||||||
|
user:
|
||||||
|
name: cliuser1
|
||||||
|
shell: /bin/bash
|
||||||
|
groups: wheel
|
||||||
|
append: yes
|
||||||
|
password: "{{ 'secretpassword' | password_hash('sha512', 'mysecretsalt') }}"
|
||||||
|
- name: Create user to become
|
||||||
|
user:
|
||||||
|
name: cliuser2
|
||||||
|
shell: /bin/bash
|
||||||
|
password: "{{ 'secretpassword' | password_hash('sha512', 'mysecretsalt') }}"
|
||||||
|
# Sometimes this file doesn't get removed, and we need it gone to ssh
|
||||||
|
- name: Remove /run/nologin
|
||||||
|
file:
|
||||||
|
path: /run/nologin
|
||||||
|
state: absent
|
||||||
|
# Make Ansible run Python to run Ansible
|
||||||
|
- name: Run the test
|
||||||
|
shell: python test-become-prompt.py {{ ansible_python_interpreter }}
|
||||||
|
always:
|
||||||
|
- name: Remove users
|
||||||
|
user:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- cliuser1
|
||||||
|
- cliuser2
|
||||||
|
# For now, we don't test this everywhere, because `user` works differently
|
||||||
|
# on some platforms, as does sudo/sudoers. On Fedora, we can just add
|
||||||
|
# the user to 'wheel' and things magically work.
|
||||||
|
# TODO: In theory, we should test this with all the different 'become'
|
||||||
|
# plugins in base.
|
||||||
|
when: ansible_distribution == 'Fedora'
|
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# 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_AGNOSTIC_BECOME_PROMPT'] = 'False'
|
||||||
|
|
||||||
|
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',
|
||||||
|
'SUDO password': 'secretpassword\n',
|
||||||
|
},
|
||||||
|
timeout=10
|
||||||
|
)
|
||||||
|
|
||||||
|
print(out)
|
||||||
|
|
||||||
|
assert b'The setting AGNOSTIC_BECOME_PROMPT to False' in out
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue