Cross posted from stackoverflow
<https://stackoverflow.com/questions/55094553/ios-command-aborting-when-trying-to-respond-to-double-confirmation-prompt>
I'm setting up a root CA on a Cisco IOS router and trying to use the
ios_command module to run the command crypto pki server my-ca start.
On running it, the following happens:
GW1(config)#do crypto pki server my-ca start
%Some server settings cannot be changed after CA certificate generation.
% Please enter a passphrase to protect the private key
% or type Return to exit
Password:
Re-enter password:
% Certificate Server enabled.
GW1(config)#
When trying to automate this in ansible, this is what I've been trying:
- name: Respond to double-password prompt
ios_command:
commands:
- command: crypto pki server my-ca start
prompt: 'assword:'
answer: "mypassword\r"
The output when running the playbook is as follows:
"stdout_lines": [
[
"%Some server settings cannot be changed after CA certificate
generation.",
"% Please enter a passphrase to protect the private key",
"% or type Return to exit",
"Password: ",
"",
"Re-enter password: ",
"% Aborted."
]
]
It looks like the second prompt causes it to just cancel out by submitting
"\r" rather than submitting "mypassword\r" again like it does at the first
prompt.
I gave the ios_command prompt string 'assword:' so it should have matched
both "Password: " and "Re-enter password: " but that didn't make a
difference.
Is there a way to make the ios_command module handle this double-prompt? As
far as I can tell, I can't put the password into the crypto pki server my-ca
start
command.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/91ffb29d-94b4-49e0-9a85-4194b21129b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.