How to output a "show" command result from Cisco ASA in playbook?

705 Views Asked by At

Relatively new to Ansible but I'm just wondering what the syntax looks like if I want to run a command on an ASA like show run | i opmanager and then print the output. I have put a pause in because after the output is printed I want it to wait before continuing.

I have an ASA I want to configure with the playbook to see if i can deploy new SNMPv3 credentials to whilst also removing an old set.

This task removes any existing ManageEngine config for SNMP
  tasks:
    - name: Show remainging opmanager config
    asa_command:
      commands: show run | i opmanager 
      register: ManageEngine
      pause:
        prompt: "Do you want to proceed? (yes/no)"
        register: confirm
1

There are 1 best solutions below

0
U880D On

Regarding your question

I'm just wondering what the syntax looks like

you may have a look into the Ansible Collections documentation Run arbitrary commands on Cisco ASA devices, the documentation of debug_module to Print statements during execution and the pause_module to Pause playbook execution.

  # This task removes any existing ManageEngine config for SNMP

  tasks:

    - name: Show remaining opmanager config
      asa_command:
        commands: show run | i opmanager 
      register: ManageEngine

    - name: Show result
      debug:
        msg: "{{ ManageEngine }}"

    - name: Pause until confirmation
      pause:
        prompt: "Do you want to proceed? (yes/no)"