--- - name: Verify SSH Connectivity hosts: all tasks: - name: Gather facts for network devices when: ansible_network_os is defined ansible.netcommon.cli_command: command: show version register: result - name: Print version for network devices when: ansible_network_os is defined ansible.builtin.debug: msg: "{{ result.stdout }}" - name: Gather facts for regular servers when: ansible_network_os is not defined ansible.builtin.setup: - name: Ping all hosts ansible.builtin.ping: