<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic how to deal with prompts when using ios_config ansible module in Network Devices</title>
    <link>https://community.cisco.com/t5/network-devices/how-to-deal-with-prompts-when-using-ios-config-ansible-module/m-p/5146547#M475</link>
    <description>&lt;P&gt;Trying to use ios_config module, with 'src' parameter pointing to a set of dynamically generated lines of configuration. We put these all together and send it to a final module which uses ios_config to try and configure the device. For one such scenario on one platform, i'm getting following prompt which is causing the workflow to time out;&lt;BR /&gt;Static entry in use, do you want to delete child entries? [no]:&lt;BR /&gt;(adding a clear ip nat trans forced command before the remove command doesn't clear the prompt appearing)&lt;BR /&gt;From what i can see, there doesn't seem to be a way to handle prompts within the ios_config module, and the other suggestions ive come across, which are to use cli_command or ios_command modules don't seem to allow me to specify a 'src' file, instead require the commands to be defined within the task. Is there a workaround?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2024 08:29:15 GMT</pubDate>
    <dc:creator>pcook10</dc:creator>
    <dc:date>2024-07-18T08:29:15Z</dc:date>
    <item>
      <title>how to deal with prompts when using ios_config ansible module</title>
      <link>https://community.cisco.com/t5/network-devices/how-to-deal-with-prompts-when-using-ios-config-ansible-module/m-p/5146547#M475</link>
      <description>&lt;P&gt;Trying to use ios_config module, with 'src' parameter pointing to a set of dynamically generated lines of configuration. We put these all together and send it to a final module which uses ios_config to try and configure the device. For one such scenario on one platform, i'm getting following prompt which is causing the workflow to time out;&lt;BR /&gt;Static entry in use, do you want to delete child entries? [no]:&lt;BR /&gt;(adding a clear ip nat trans forced command before the remove command doesn't clear the prompt appearing)&lt;BR /&gt;From what i can see, there doesn't seem to be a way to handle prompts within the ios_config module, and the other suggestions ive come across, which are to use cli_command or ios_command modules don't seem to allow me to specify a 'src' file, instead require the commands to be defined within the task. Is there a workaround?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 08:29:15 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/how-to-deal-with-prompts-when-using-ios-config-ansible-module/m-p/5146547#M475</guid>
      <dc:creator>pcook10</dc:creator>
      <dc:date>2024-07-18T08:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to deal with prompts when using ios_config ansible module</title>
      <link>https://community.cisco.com/t5/network-devices/how-to-deal-with-prompts-when-using-ios-config-ansible-module/m-p/5146629#M476</link>
      <description>&lt;P&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/1757929"&gt;@pcook10&lt;/a&gt;&amp;nbsp;so what you are seeing is kinda of expected,&amp;nbsp;&lt;SPAN&gt;ios_config module &lt;/SPAN&gt;&lt;SPAN&gt;in&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;ansible &lt;/SPAN&gt;&lt;SPAN&gt;is&lt;/SPAN&gt;&lt;SPAN&gt; designed &lt;/SPAN&gt;&lt;SPAN&gt;for&lt;/SPAN&gt; &lt;SPAN&gt;bulk&lt;/SPAN&gt;&lt;SPAN&gt; configuration changes but lacks built&lt;/SPAN&gt;&lt;SPAN&gt;-in&lt;/SPAN&gt;&lt;SPAN&gt; prompt handling sadly. Check out&amp;nbsp;&lt;A href="https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/cli_command_module.html" target="_blank"&gt;https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/cli_command_module.html&lt;/A&gt;&amp;nbsp;he&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;module &lt;/SPAN&gt;&lt;SPAN&gt;is&lt;/SPAN&gt;&lt;SPAN&gt; your best bet &lt;/SPAN&gt;&lt;SPAN&gt;for&lt;/SPAN&gt; &lt;SPAN&gt;interacting&lt;/SPAN&gt; &lt;SPAN&gt;with&lt;/SPAN&gt;&lt;SPAN&gt; prompts as you can use a loop to feed it commands &lt;/SPAN&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; your dynamically generated configuration file.&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Hope this helps.&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Jul 2024 11:07:21 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/how-to-deal-with-prompts-when-using-ios-config-ansible-module/m-p/5146629#M476</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2024-07-18T11:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to deal with prompts when using ios_config ansible module</title>
      <link>https://community.cisco.com/t5/network-devices/how-to-deal-with-prompts-when-using-ios-config-ansible-module/m-p/5202788#M506</link>
      <description>&lt;P&gt;Handling interactive prompts like "Static entry in use, do you want to delete child entries? [no]:" can be tricky with modules like ios_config since it doesn’t have a built-in way to respond to such prompts. For this scenario, I suggest a different approach using a combination of cli_command and ios_config modules.&lt;/P&gt;&lt;H3&gt;Solution Approach&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Use the cli_command Module:&lt;/STRONG&gt; Use the cli_command module to perform the specific command that triggers the prompt and pass the required input using the wait_for and prompt options. This allows us to simulate a manual response to the interactive prompt.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Leverage ignore_errors:&lt;/STRONG&gt; You can use ignore_errors on this specific command task so that the overall playbook execution is not halted if the command fails or the prompt appears unexpectedly.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Continue with ios_config:&lt;/STRONG&gt; After handling the prompt, continue using ios_config for the rest of your configuration commands.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here’s an example of how this could be structured in a playbook:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="ruby"&gt;---
- name: Handle Interactive Prompt and Apply Configuration
  hosts: switches
  gather_facts: no
  connection: network_cli
  tasks:
    - name: Remove static NAT entry with prompt handling
      cli_command:
        command: "no ip nat inside source static tcp 10.1.1.1 80 192.168.1.1 80"
        prompt: "Static entry in use, do you want to delete child entries?"
        answer: "yes"
        wait_for: 5
      register: nat_removal_result
      ignore_errors: yes

    - name: Validate NAT removal
      debug:
        msg: "{{ nat_removal_result }}"

    - name: Apply configuration from file using ios_config
      ios_config:
        src: "/path/to/generated/config"
      when: nat_removal_result is succeeded&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;Explanation&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;cli_command:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;This module is used to send the command that triggers the prompt (no ip nat inside...).&lt;/LI&gt;&lt;LI&gt;The prompt and answer fields are used to respond to the interactive prompt with "yes".&lt;/LI&gt;&lt;LI&gt;The wait_for field ensures the task waits for the specified time to confirm the command’s response.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;register and ignore_errors:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The output is registered to a variable nat_removal_result and errors are ignored.&lt;/LI&gt;&lt;LI&gt;You can inspect the output using a debug statement for troubleshooting.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;ios_config after Prompt Handling:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Once the prompt is handled, proceed to use ios_config with your dynamic configuration file.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Thu, 03 Oct 2024 07:32:17 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/how-to-deal-with-prompts-when-using-ios-config-ansible-module/m-p/5202788#M506</guid>
      <dc:creator>Ehsan Momeni Bashusqeh</dc:creator>
      <dc:date>2024-10-03T07:32:17Z</dc:date>
    </item>
  </channel>
</rss>

