使用Ansible的要求是:
> 1.Connect to the router first.
> 2.Then push debug commands to the router.(using ansible playbook)
> 3.Ansible will wait for few seconds because router will take some time to dump the output on the monitor screen(CLI of router).
> 4.Then gather all that debug logs from the Router to the controller and save it in text file.
问题是:使用ansible收集此调试输出时使用什么模块?
我希望这个时间要求非常清晰和全面。
$$此外,我可以使用'show log'并收集数据,但我的要求是收集路由器在屏幕上转储的所有输出(CLI)。
注意:当我们在路由器上启用调试并启用“日志监视器调试”时,日志将打印在屏幕上而非缓冲区中。如何将这些调试保存在变量中?
---
- name: Gathering outputs from single hosts
hosts: network
connection: local
gather_facts: True
tasks:
- name: Pushing debug commands
ios_command:
commands:
- debug ip packet detail
- term mon
- pause:
seconds: 5
- name: Gathering debugs
ios_command:
commands:
- show ip int brief
- show log
register: print_output
- debug: var=print_output.stdout_lines
/etc/ansible$ cat hosts
[local]
127.0.0.1
[network]
2.2.2.2