Avoid conditionals

Write better playbooks! Avoid Ansible Conditionals! There are more efficient ways to write multi-vendor network automation playbooks. I recommend this with_first_found trick so that I can separate each network platform into its own file. This makes it much easier to extend an Ansible Playbook and actually reduces the amount of code (no when statements needed!)


At execution time, does this help avoid all the “skipped” outputs that would normally show up? For instance with the original version of your script, all EOS devices would have a status of “skipped” for the IOS task.

You could use
ANSIBLE_DISPLAY_SKIPPED_HOSTS=false ansible-playbook …
or use an appropriate stdout_callback in ansible.cfg

ansible.cfg: Unfortunately the following is obsolete

Obsolete as of 2.14

display_skipped_hosts = true

There’s surely more ways to suppress the output

I was thinking about a situation where I want to keep the skipped messages for some tasks but not pollute the output logs with unnecessary skipped messages.