mirror of
https://github.com/ansible/ansible.git
synced 2026-08-05 16:13:06 +02:00
Make timeout on become an unreachable error (#84589)
* Make timeout on become an unreachable error Fixes #84468
This commit is contained in:
@@ -54,10 +54,10 @@
|
||||
ansible_su_prompt_l10n: NOT_A_VALID_PROMPT
|
||||
ansible_local_become_success_timeout: 3 # actual become success timeout
|
||||
ansible_ssh_timeout: 3 # connection timeout, which results in an N+2 second select timeout
|
||||
ignore_errors: yes
|
||||
ignore_unreachable: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- wrong_su_prompt is failed
|
||||
- wrong_su_prompt is unreachable
|
||||
- ansible_connection != "local" or wrong_su_prompt.msg is contains "Timed out waiting for become success or become password prompt"
|
||||
- ansible_connection != "ssh" or wrong_su_prompt.msg is contains "waiting for privilege escalation prompt"
|
||||
|
||||
@@ -115,12 +115,12 @@
|
||||
ansible_become_flags: "{{ default_sudo_flags ~ intermediate }} --bogus-prompt"
|
||||
ansible_local_become_success_timeout: 2
|
||||
raw: exit 99
|
||||
ignore_errors: true
|
||||
ignore_unreachable: true
|
||||
register: prompt_timeout
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- prompt_timeout is failed
|
||||
- prompt_timeout is unreachable
|
||||
- prompt_timeout.msg is contains "Timed out waiting for become success or become password prompt"
|
||||
- prompt_timeout.msg is contains "BOGUSPROMPT"
|
||||
- prompt_timeout.rc is not defined
|
||||
|
||||
@@ -79,3 +79,6 @@ ANSIBLE_CONFIG=./test_ssh_defaults.cfg ansible-playbook verify_config.yml "$@"
|
||||
# ensure we handle cp with spaces correctly, otherwise would fail with
|
||||
# `"Failed to connect to the host via ssh: command-line line 0: keyword controlpath extra arguments at end of line"`
|
||||
ANSIBLE_SSH_CONTROL_PATH='/tmp/ssh cp with spaces' ansible -m ping all -e ansible_connection=ssh -i test_connection.inventory "$@"
|
||||
|
||||
# Test that timeout on waiting on become is an unreachable error
|
||||
ansible-playbook test_unreachable_become_timeout.yml "$@"
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
- hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
become_unreachable_test_user: become_unreachable_test_user1
|
||||
ansible_connection: ssh
|
||||
ansible_ssh_timeout: 3
|
||||
tasks:
|
||||
- name: Test that timeout on waiting on become is an unreachable error
|
||||
block:
|
||||
- user:
|
||||
name: "{{ become_unreachable_test_user }}"
|
||||
shell: "{{ lookup('pipe', 'which bash') }}"
|
||||
|
||||
- lineinfile:
|
||||
name: "~/.bash_profile"
|
||||
regexp: "^sleep \\d+"
|
||||
line: "sleep 5"
|
||||
create: true
|
||||
become: true
|
||||
become_user: "{{ become_unreachable_test_user }}"
|
||||
|
||||
- command: whoami
|
||||
loop:
|
||||
- 1
|
||||
- 2
|
||||
register: r
|
||||
ignore_errors: true
|
||||
ignore_unreachable: true
|
||||
timeout: 15
|
||||
become: true
|
||||
become_user: "{{ become_unreachable_test_user }}"
|
||||
become_flags: "-i" # force loading .bash_profile to timeout become
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- r.results|length == 2
|
||||
- r.results[0]["msg"] is contains("Timeout (5s) waiting for privilege escalation prompt:")
|
||||
- r.results[1]["msg"] is contains("Timeout (5s) waiting for privilege escalation prompt:")
|
||||
- r is unreachable
|
||||
always:
|
||||
- user:
|
||||
name: "{{ become_unreachable_test_user }}"
|
||||
state: absent
|
||||
Reference in New Issue
Block a user