I can't seem to get the register to works with cli_command and looping of multiples commands. Any suggestions?
-
name: Run show commands
hosts:
- all
connection: network_cli
gather_facts: no
vars:
shcmd:
- show bgp sum | match 3356
- show config protocols bgp group Level3
tasks:
- name: create report directory if needed
set_fact:
report_dir: "{{ user_data_path }}/reports"
- name: confirm report directory
file:
path: "{{ report_dir }}"
state: directory
- name: Run commands
cli_command:
command: "{{item}}"
register: "showcmds"
with_items: "{{shcmd}}"
- debug:
msg: "{{ showcmds.stdout_lines }}"
with_items: "{{shcmd}}"