Skip to content

Commit a3927a6

Browse files
committed
✨ prompt_password: test sudo password early
1 parent 631dabb commit a3927a6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

roles/prompt_password/tasks/main.yml

+14-3
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,34 @@
22
# - copy_to_become_password: true to automatically set `become_password`
33
# as well (if not yet defined).
44
---
5+
- name: SET_FACT | init
6+
ansible.builtin.set_fact:
7+
password_prompt:
8+
tags: always
9+
510
- name: Prompt for ssh password if necessary
611
when: ansible_password is undefined
712
block:
8-
- name: Conditionally prompt for ssh password
13+
- name: PAUSE | Conditionally prompt for ssh password
914
ansible.builtin.pause:
1015
prompt: "Password for {{ ansible_user | d('') }}@{{ ansible_host | d('unknown') }}"
1116
echo: false
1217
register: password_prompt
1318
no_log: true
1419

15-
- name: Set ansible_password
20+
- name: SET_FACT | Set ansible_password
1621
ansible.builtin.set_fact:
1722
ansible_password: "{{ password_prompt.user_input }}"
1823
no_log: true
1924

20-
- name: Set ansible_become_password to be the same as ssh password
25+
- name: SET_FACT | Set ansible_become_password to be the same as ssh password
2126
ansible.builtin.set_fact:
2227
ansible_become_password: "{{ ansible_password }}"
2328
no_log: true
2429
when: copy_to_become_password | d(false) and ansible_become_password is undefined
30+
31+
- name: COMMAND | Test the password for fail-fast
32+
ansible.builtin.command: '/usr/bin/true'
33+
changed_when: false
34+
become: true
35+
when: password_prompt.user_input is defined

0 commit comments

Comments
 (0)