Ansible - Reduce on screen outputs

Viewed 60

I have below task in my playbook, which generates lots of outputs on the screen. Is there a way to hide those lines (e.g. ok: [LAB_RT03] => (item=show runn) on-screen? Items in the file are list of show commands to run on network devices. In reality there will be 10's of commands.

The task

- name: "retrieve show commands  from Routers "
 ios_command:
   commands: 
   - command: "{{ item }}"
 loop: "{{ lookup('file', './commands/ios_commands.txt').splitlines() }}"
 register: ios_output
 ignore_errors: true
 when: ansible_network_os == 'ios'

Outputs:

ok: [LAB_RT03] => (item=show runn)
ok: [LAB_RT04] => (item=show runn)
ok: [LAB_RT04] => (item=show version)
ok: [LAB_RT03] => (item=show version)
ok: [LAB_RT04] => (item=show ip route vrf ext)
ok: [LAB_RT03] => (item=show ip route vrf ext)
1 Answers

When you add your playbook loop control label 'LAB_RTO3' as following the example you can limit the displayed output.

- name: "retrieve show commands  from Routers "
 ios_command:
   commands: 
   - command: "{{ item }}"
 loop: "{{ lookup('file', './commands/ios_commands.txt').splitlines() }}"
 loop_control:
   label: "{{ LAB_RT03 }}"
 register: ios_output
 ignore_errors: true
 when: ansible_network_os == 'ios'
Related