# Can ios\_config handle responding to two prompts in a row?

**URL:** <https://forum.ansible.com/t/can-ios-config-handle-responding-to-two-prompts-in-a-row/29859>\
**Category:** Ansible Project\
**Created:** [March 11, 2019, 2:58am UTC](https://forum.ansible.com/t/can-ios-config-handle-responding-to-two-prompts-in-a-row/29859 "2019-03-11T02:58:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibdg](https://avatars.discourse-cdn.com/v4/letter/i/9e8a1a/32.png) [@ibdg](https://forum.ansible.com/u/ibdg)\
**Post date:** [March 11, 2019, 2:58am UTC](https://forum.ansible.com/t/can-ios-config-handle-responding-to-two-prompts-in-a-row/29859/1 "2019-03-11T02:58:25Z")

</div>

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:

```auto
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:

```auto
- 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:

```auto
"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.

---

<div class="post-metadata">

**Author:** ![ibdg](https://avatars.discourse-cdn.com/v4/letter/i/9e8a1a/32.png) [@ibdg](https://forum.ansible.com/u/ibdg)\
**Post date:** [March 11, 2019, 4:43am UTC](https://forum.ansible.com/t/can-ios-config-handle-responding-to-two-prompts-in-a-row/29859/2 "2019-03-11T04:43:06Z")

</div>

Just noticed, my title here is wrong, it should be ‘ios\_command’ not ‘ios\_config’

---

<div class="post-metadata">

**Author:** ![ganeshrn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ganeshrn/32/1021_2.png) [@ganeshrn](https://forum.ansible.com/u/ganeshrn)\
**Post date:** [March 11, 2019, 4:48am UTC](https://forum.ansible.com/t/can-ios-config-handle-responding-to-two-prompts-in-a-row/29859/3 "2019-03-11T04:48:12Z")

</div>

You can use cli\_command module available in Ansible 2.7 version onwards

[https://docs.ansible.com/ansible/latest/modules/cli\_command\_module.html](https://docs.ansible.com/ansible/latest/modules/cli_command_module.html)

The task can be modified as below to support multiple prompts.

```auto
- name: Respond to double-password prompt
  cli_command:
    commands:
      - command: crypto pki server my-ca start

```

```auto
        check_all: True
        prompt: 

```

```auto
         - "password"

```

```auto
         - "enter password"

```

```auto
        answer: 

```

```auto
          - "mypassword\r"

```

```auto
          - "mypassword\r"

```

---

<div class="post-metadata">

**Author:** ![ibdg](https://avatars.discourse-cdn.com/v4/letter/i/9e8a1a/32.png) [@ibdg](https://forum.ansible.com/u/ibdg)\
**Post date:** [March 11, 2019, 10:52pm UTC](https://forum.ansible.com/t/can-ios-config-handle-responding-to-two-prompts-in-a-row/29859/4 "2019-03-11T22:52:13Z")

</div>

Great, thanks for that.
