Summary
The first time sudo is used on a new host, there is a lecture that comes up requiring users to look at the sudo lecture before proceeding.
I am currently trying to set up automation to reimage devices that come preimaged using ansible. The rest of the process is there, but the one thing that is holding me up currently is the sudo lecture. I have loaded the sudo password to the device and it seems to work well except for if it is the first time.
Issue Type
Bug Report
Component Name
become module
Ansible Version
$ ansible --version
ansible 2.9.6
config file = /home/ted_kent/ansible/ansible.cfg
configured module search path = ['/home/ted_kent/ansible/library']
ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.6.9 (default, Mar 15 2022, 13:55:28) [GCC 8.4.0]
Configuration
# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
ANSIBLE_COW_SELECTION(/home/ted_kent/ansible/ansible.cfg) = random
ANSIBLE_COW_WHITELIST(/home/ted_kent/ansible/ansible.cfg) = ['ren', 'stimpy #bud-frogs', 'bunny', 'cheese', 'daemon', 'default', 'dragon', 'elephant-in-snake', 'elephant', 'eyes', '\\']
ANSIBLE_NOCOWS(/home/ted_kent/ansible/ansible.cfg) = True
ANSIBLE_PIPELINING(/home/ted_kent/ansible/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/home/ted_kent/ansible/ansible.cfg) = -o ForwardAgent=yes -o ControlPersist=1800s -o ControlMaster=auto
CACHE_PLUGIN(/home/ted_kent/ansible/ansible.cfg) = memory
CACHE_PLUGIN_TIMEOUT(/home/ted_kent/ansible/ansible.cfg) = 20
COMMAND_WARNINGS(/home/ted_kent/ansible/ansible.cfg) = False
DEFAULT_CALLBACK_PLUGIN_PATH(/home/ted_kent/ansible/ansible.cfg) = ['/home/ted_kent/ansible/callback_plugins']
DEFAULT_CALLBACK_WHITELIST(/home/ted_kent/ansible/ansible.cfg) = ['profile_tasks', 'timer', 'datadog_callback', 'portal-callback']
DEFAULT_FILTER_PLUGIN_PATH(/home/ted_kent/ansible/ansible.cfg) = ['/home/ted_kent/ansible/filter_plugins', '/usr/share/ansible/plugins/filter']
DEFAULT_FORKS(/home/ted_kent/ansible/ansible.cfg) = 35
DEFAULT_GATHERING(/home/ted_kent/ansible/ansible.cfg) = implicit
DEFAULT_GATHER_SUBSET(/home/ted_kent/ansible/ansible.cfg) = ['all']
DEFAULT_HOST_LIST(/home/ted_kent/ansible/ansible.cfg) = ['/home/ted_kent/ansible/inventory']
DEFAULT_INTERNAL_POLL_INTERVAL(/home/ted_kent/ansible/ansible.cfg) = 0.001
DEFAULT_LOG_PATH(/home/ted_kent/ansible/ansible.cfg) = /var/log/ansible.log
DEFAULT_MODULE_PATH(/home/ted_kent/ansible/ansible.cfg) = ['/home/ted_kent/ansible/library']
DEFAULT_REMOTE_USER(/home/ted_kent/ansible/ansible.cfg) = ubuntu
DEFAULT_SCP_IF_SSH(/home/ted_kent/ansible/ansible.cfg) = True
DEFAULT_STDOUT_CALLBACK(/home/ted_kent/ansible/ansible.cfg) = yaml
DEFAULT_STRATEGY_PLUGIN_PATH(/home/ted_kent/ansible/ansible.cfg) = ['/mitogen-0.2.8/ansible_mitogen/plugins/strategy']
DEFAULT_TIMEOUT(/home/ted_kent/ansible/ansible.cfg) = 120
DEFAULT_VARS_PLUGIN_PATH(/home/ted_kent/ansible/ansible.cfg) = ['/home/ted_kent/ansible/vars_plugins', '/usr/share/ansible/plugins/vars']
DEPRECATION_WARNINGS(/home/ted_kent/ansible/ansible.cfg) = False
DISPLAY_SKIPPED_HOSTS(/home/ted_kent/ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/home/ted_kent/ansible/ansible.cfg) = False
RETRY_FILES_ENABLED(/home/ted_kent/ansible/ansible.cfg) = True
RETRY_FILES_SAVE_PATH(/home/ted_kent/ansible/ansible.cfg) = /home/ted_kent/retry
SYSTEM_WARNINGS(/home/ted_kent/ansible/ansible.cfg) = False
OS / Environment
ubuntu
Steps to Reproduce
You'll just need to gather facts on a brand new machine
- name: provision device
become: true
hosts: newhost
gather_facts: true
Expected Results
I would expect it to proceed forward.
Actual Results
TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************
task path: /home/ted_kent/ansible/provision-sestra-pcs-device.yml:19
fatal: [PVtest_host]: FAILED! => changed=false
ansible_facts: {}
failed_modules:
setup:
ansible_facts:
discovered_interpreter_python: /usr/bin/python
failed: true
module_stderr: |-
OpenSSH_7.6p1 Ubuntu-4ubuntu0.5, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /home/ted_kent/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/ted_kent/.ansible/cp/xxxxxxxxx" does not exist
debug1: Executing proxy command: exec ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -W 192.168.8.127:22 -q [email protected]
debug3: timeout: 120000 ms remain after connect
debug1: key_load_public: No such file or directory
debug1: identity file /home/ted_kent/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ted_kent/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ted_kent/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ted_kent/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ted_kent/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ted_kent/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/ted_kent/.ssh/id_ed25519 type 3
debug1: key_load_public: No such file or directory
debug1: identity file /home/ted_kent/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.5
debug1: permanently_drop_suid: 1010
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4p1 Debian-10+deb9u2
debug1: match: OpenSSH_7.4p1 Debian-10+deb9u2 pat OpenSSH* compat 0x04000000
debug2: fd 5 setting O_NONBLOCK
debug2: fd 4 setting O_NONBLOCK
debug1: Authenticating to 192.168.8.127:22 as 'debian'
debug3: hostkeys_foreach: reading file "/home/ted_kent/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/ted_kent/.ssh/known_hosts:2273
debug3: load_hostkeys: loaded 1 keys from 192.168.8.127
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected]om,[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:rj0MzxymSJc05jfw7UsnMZM3H1XHtdiutPzsj5pOTIk
debug3: hostkeys_foreach: reading file "/home/ted_kent/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/ted_kent/.ssh/known_hosts:2273
debug3: load_hostkeys: loaded 1 keys from 192.168.8.127
debug1: Host '192.168.8.127' is known and matches the ECDSA host key.
debug1: Found key in /home/ted_kent/.ssh/known_hosts:2273
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug2: key: /home/ted_kent/.ssh/sestra-ansible (0x555b15bd6f10), agent
debug2: key: /home/ted_kent/.ssh/id_rsa ((nil))
debug2: key: /home/ted_kent/.ssh/id_dsa ((nil))
debug2: key: /home/ted_kent/.ssh/id_ecdsa ((nil))
debug2: key: /home/ted_kent/.ssh/id_ed25519 (0x555b15bd6640)
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx /home/ted_kent/.ssh/sestra-ansible
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/ted_kent/.ssh/id_rsa
debug3: no such identity: /home/ted_kent/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /home/ted_kent/.ssh/id_dsa
debug3: no such identity: /home/ted_kent/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/ted_kent/.ssh/id_ecdsa
debug3: no such identity: /home/ted_kent/.ssh/id_ecdsa: No such file or directory
debug1: Offering public key: ED25519 SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx /home/ted_kent/.ssh/id_ed25519
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (password).
Authenticated to 192.168.8.127 (via proxy).
debug1: setting up multiplex master socket
debug3: muxserver_listen: temporary control path /home/ted_kent/.ansible/cp/xxxxxxxxxxxxxxxxxxxxxxxxxxx
debug2: fd 6 setting O_NONBLOCK
debug3: fd 6 is O_NONBLOCK
debug3: fd 6 is O_NONBLOCK
debug1: channel 0: new [/home/ted_kent/.ansible/cp/95c0ed25db]
debug3: muxserver_listen: mux listener channel 0 fd 6
debug1: control_persist_detach: backgrounding master process
debug2: control_persist_detach: background process is 19160
debug2: fd 6 setting O_NONBLOCK
debug1: forking to background
debug1: Entering interactive session.
debug1: pledge: id
debug2: set_control_persist_exit_time: schedule exit in 1800 seconds
debug1: multiplexing control connection
debug2: fd 7 setting O_NONBLOCK
debug3: fd 7 is O_NONBLOCK
debug1: channel 1: new [mux-control]
debug3: channel_post_mux_listener: new mux channel 1 fd 7
debug3: mux_master_read_cb: channel 1: hello sent
debug2: set_control_persist_exit_time: cancel scheduled exit
debug3: mux_master_read_cb: channel 1 packet type 0x00000001 len 4
debug2: process_mux_master_hello: channel 1 slave version 4
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_master_read_cb: channel 1 packet type 0x10000004 len 4
debug2: process_mux_alive_check: channel 1: alive check
debug3: mux_client_request_alive: done pid = 19162
debug3: mux_client_request_session: session request sent
debug3: mux_master_read_cb: channel 1 packet type 0x10000002 len 277
debug3: process_mux_new_session: got fds stdin 8, stdout 9, stderr 10
debug2: fd 8 setting O_NONBLOCK
debug2: fd 9 setting O_NONBLOCK
debug2: fd 10 setting O_NONBLOCK
debug1: channel 2: new [client-session]
debug2: process_mux_new_session: channel_new: 2 linked to control channel 1
debug2: channel 2: send open
debug3: send packet: type 90
debug3: receive packet: type 80
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 2: callback start
debug1: Requesting authentication agent forwarding.
debug2: channel 2: request [email protected] confirm 0
debug3: send packet: type 98
debug2: client_session2_setup: id 2
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 2: request env confirm 0
debug3: send packet: type 98
debug1: Sending command: /bin/sh -c 'sudo -H -S -p "[sudo via ansible, key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] password:" -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ; /usr/bin/python'"'"' && sleep 0'
debug2: channel 2: request exec confirm 1
debug3: send packet: type 98
debug3: mux_session_confirm: sending success reply
debug2: channel_input_open_confirmation: channel 2: callback done
debug2: channel 2: open confirm rwindow 0 rmax 32768
debug1: mux_client_request_session: master session id: 2
debug2: channel 2: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 2
debug2: exec request accepted on channel 2
debug2: channel 2: read<=0 rfd 8 len 0
debug2: channel 2: read failed
debug2: channel 2: close_read
debug2: channel 2: input open -> drain
debug2: channel 2: ibuf empty
debug2: channel 2: send eof
debug3: send packet: type 96
debug2: channel 2: input drain -> closed
debug2: channel 2: rcvd adjust 65536
debug2: channel 2: rcvd ext data 253
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
debug2: channel 2: written 253 to efd 10
debug2: channel 2: rcvd ext data 66
[sudo via ansible, key=aqejcziejhotyocdgqcvydxjhtflwpda] password:debug2: channel 2: written 66 to efd 10
debug2: channel 2: rcvd ext data 84
Sorry, try again.
[sudo via ansible, key=aqejcziejhotyocdgqcvydxjhtflwpda] password:debug2: channel 2: written 84 to efd 10
debug2: channel 2: rcvd ext data 84
Sorry, try again.
[sudo via ansible, key=aqejcziejhotyocdgqcvydxjhtflwpda] password:debug2: channel 2: written 84 to efd 10
debug2: channel 2: rcvd ext data 4
sudodebug2: channel 2: written 4 to efd 10
debug2: channel 2: rcvd ext data 32
: 3 incorrect password attempts
debug2: channel 2: written 32 to efd 10
debug3: receive packet: type 96
debug2: channel 2: rcvd eof
debug2: channel 2: output open -> drain
debug2: channel 2: obuf empty
debug2: channel 2: close_write
debug2: channel 2: output drain -> closed
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 2 rtype [email protected] reply 0
debug2: channel 2: rcvd eow
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 2 rtype exit-status reply 0
debug3: mux_exit_message: channel 2: exit message, exitval 1
debug3: receive packet: type 97
debug2: channel 2: rcvd close
debug3: channel 2: will not send data after close
debug2: channel 2: send close
debug3: send packet: type 97
debug2: channel 2: is dead
debug2: channel 2: gc: notify user
debug3: mux_master_session_cleanup_cb: entering for channel 2
debug2: channel 1: rcvd close
debug2: channel 1: output open -> drain
debug2: channel 1: close_read
debug2: channel 1: input open -> closed
debug2: channel 2: gc: user detached
debug2: channel 2: is dead
debug2: channel 2: garbage collecting
debug1: channel 2: free: client-session, nchannels 3
debug3: channel 2: status: The following connections are open:
#1 mux-control (t16 nr0 i3/0 o1/16 fd 7/7 cc -1)
#2 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)
debug2: channel 1: obuf empty
debug2: channel 1: close_write
debug2: channel 1: output drain -> closed
debug2: channel 1: is dead (local)
debug2: channel 1: gc: notify user
debug3: mux_master_control_cleanup_cb: entering for channel 1
debug2: channel 1: gc: user detached
debug2: channel 1: is dead (local)
debug2: channel 1: garbage collecting
debug1: channel 1: free: mux-control, nchannels 2
debug3: channel 1: status: The following connections are open:
#1 mux-control (t16 nr0 i3/0 o3/0 fd 7/7 cc -1)
debug2: set_control_persist_exit_time: schedule exit in 1800 seconds
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 1
debug3: send packet: type 1
packet_write_wait: Connection to UNKNOWN port 65535: Broken pipe
module_stdout: ''
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1
warnings:
- Platform linux on host PVtest_host is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
msg: |-
The following modules failed to execute: setup
Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct