So this is conditionals on Ansible:
- debug:
var: x
when: x is not defined
Is there anyway to apply conditionals for junos_commands? Like:
tasks:
- name: Show logs
junos_command:
commands:
- show interfaces
when: apply this condition
Yes, you can use when with junos_command but you need to apply conditions to the when statement. For example:
yum:
name: iotop
state: present
when: ansible_os_family == "RedHat"
This will install iotop only if system is a RedHat family. You can also apply conditions from scripts or tasks that were run before and you have registered there result. More information can be find here: https://docs.ansible.com/ansible/2.7/user_guide/playbooks_conditionals.html