# Interactive Commands via Ansible

**URL:** <https://forum.ansible.com/t/interactive-commands-via-ansible/44812>\
**Category:** Get Help\
**Tags:** cisco, aap, network\
**Created:** [November 7, 2025, 5:27pm UTC](https://forum.ansible.com/t/interactive-commands-via-ansible/44812 "2025-11-07T17:27:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xkevin](https://avatars.discourse-cdn.com/v4/letter/0/7c8e57/32.png) [@0xkevin](https://forum.ansible.com/u/0xkevin)\
**Post date:** [November 7, 2025, 5:27pm UTC](https://forum.ansible.com/t/interactive-commands-via-ansible/44812/1 "2025-11-07T17:27:33Z")

</div>

Hi all, I am struggling to find documentation or a module that will help me resolve this issue that I am experiencing.

The requirement - I am SSHing into a Cisco IOS device and need to run one command that is interactive.

Example of how to do it manually (I removed the values for variables for clarity):

TEST-ROUTER# **copy tftp://{{ tftp\_server }}/{{ filename }} bootflash://{{ filename }} vrf {{number}}**  
Destination filename [XXXXXXXXXXXXXX.crt]? **XXXXXXXXXXXXXX.crt**  
Accessing tftp://XX.XX.XX.XX/XXXXXXXXXXXXXX.crt…  
Loading XXXXXXXXXXXXXX.crt from XX.XX.XX.XX (via Sdwan-system-intf): !  
[OK - 5280 bytes]  
5280 bytes copied in 2.639 secs (1989 bytes/sec)

So as you can see, after providing the command “copy tftp://{{ tftp\_server }}/{{ filename }} bootflash://{{ filename }} vrf {{number}}”, the system prompts for the destination filename which is simply the filename passed.

I have attempted using the ansible .builtin.expect and .ios.ios\_command, however, the ansible playbook continues to timeout on the first command “copy tftp://{{ tftp\_server }}/{{ filename }} bootflash://{{ filename }} vrf {{number}}”.

Here is the task that is failing:

> ```
> - name: Push certificate via TFTP if certificate is not present
> when: dir_check.stdout is not defined or filename not in (dir_check.stdout[0] | default(''))
> cisco.ios.ios_command:
> commands:
> - "copy tftp://{{ tftp_server }}/{{ filename }} bootflash://{{ filename }} vrf 1"
> - "{{ filename }}"
> register: copy_output
> 
> ```

---

<div class="post-metadata">

**Author:** ![gundalow](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/gundalow/32/99_2.png) [@gundalow](https://forum.ansible.com/u/gundalow)\
**Post date:** [November 7, 2025, 5:57pm UTC](https://forum.ansible.com/t/interactive-commands-via-ansible/44812/2 "2025-11-07T17:57:22Z")

</div>

Can you provide the output of `ansible-playbook -vvv ...` when you run this.

Have you see the [Network prompt guide](https://docs.ansible.com/ansible/latest/network/user_guide/network_working_with_command_output.html)

Though a cleaner solution might be to use the [net\_put module](https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/net_put_module.html) to copy the file onto the destination. You might need a task before that to copy from the tftp server to the machine running Ansible, unless it’s available as a network mount somewhere.

---

<div class="post-metadata">

**Author:** ![0xkevin](https://avatars.discourse-cdn.com/v4/letter/0/7c8e57/32.png) [@0xkevin](https://forum.ansible.com/u/0xkevin)\
**Post date:** [November 7, 2025, 7:20pm UTC](https://forum.ansible.com/t/interactive-commands-via-ansible/44812/4 "2025-11-07T19:20:12Z")

</div>

Hi @gundalow,

Thank you for this documentation. When using the ‘ansible.netcommon.cli\_command’, it is working.

The final product looks as such:

> ```
> - name: Push certificate via TFTP if certificate is not present
> when: dir_check.stdout is not defined or filename not in (dir_check.stdout[0] | default(''))
> ansible.netcommon.cli_command:
> command: "copy tftp://{{ tftp_server }}/{{ filename }} bootflash://{{ filename }} vrf 1"
> prompt: "Destination filename.*"
> answer: '{{ filename }}'
> register: copy_output
> 
> ```

---

<div class="post-metadata">

**Author:** ![gundalow](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/gundalow/32/99_2.png) [@gundalow](https://forum.ansible.com/u/gundalow)\
**Post date:** [November 10, 2025, 7:01am UTC](https://forum.ansible.com/t/interactive-commands-via-ansible/44812/5 "2025-11-10T07:01:42Z")

</div>

Glad it’s working, can you please mark my the solution post as “solved”, so it will help others in the future. Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 10, 2025, 7:01am UTC](https://forum.ansible.com/t/interactive-commands-via-ansible/44812/6 "2025-12-10T07:01:51Z")

</div>

Closed on December 10, 2025, 7:01am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
