02-02-2024 09:43 PM
Hello,
I am working on a Metric check list including show commands.
Some of those commands provide output with a delay or even require to hit "enter" to scroll further down.
I was wondering, what the best approach would be to tackle this issue.
Not sure if the following module would be the proper approach:
Thanks,
Solved! Go to Solution.
02-09-2024 10:52 PM
Ok, I think I solved it by also changig the timeout.
Now, Ansible is waiting until command output and captures the whole output of " show version installed"
# Example – show version installed on Cisco Cat9k
---
- name: Ansible site-ios-xe-L2-L3-Metrics-Check-IDF_@M.Wolf_Jan2024
hosts: MTIDFiosxe
vars_files:
- /home/wolfm/Ansible/vault_password.yml
vars:
ansible_become_pass: "{{ vault_sudo_password }}"
ansible_python_interpreter: /usr/bin/python3
ansible_command_timeout: 120
- name: Task30 sh version installed
ios_command:
commands: sh version installed
wait_for: result[0] contains Provisioning File
:
- name: Task30 sh version install install after upgrade
debug:
var: output30
02-03-2024 10:15 AM
Yes, an example
- name: Run show version and check to see if output contains IOS cisco.ios.ios_command: commands: show version wait_for: result[0] contains IOS
02-09-2024 09:39 PM
Thank you Ruben.
There is one more challenge.
If show command requires to hit enter for "more".
For example "sh version installed" requires to hit more to scroll down.
Please advise.
Thanks.
02-09-2024 10:52 PM
Ok, I think I solved it by also changig the timeout.
Now, Ansible is waiting until command output and captures the whole output of " show version installed"
# Example – show version installed on Cisco Cat9k
---
- name: Ansible site-ios-xe-L2-L3-Metrics-Check-IDF_@M.Wolf_Jan2024
hosts: MTIDFiosxe
vars_files:
- /home/wolfm/Ansible/vault_password.yml
vars:
ansible_become_pass: "{{ vault_sudo_password }}"
ansible_python_interpreter: /usr/bin/python3
ansible_command_timeout: 120
- name: Task30 sh version installed
ios_command:
commands: sh version installed
wait_for: result[0] contains Provisioning File
:
- name: Task30 sh version install install after upgrade
debug:
var: output30
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide