--- - name: "Debug | Ping hosts" hosts: all gather_facts: false tasks: - name: "Windows | WinRM ping" when: ansible_connection | default('') == 'winrm' ansible.windows.win_ping: - name: "Linux | Ansible ping" when: ansible_connection | default('ssh') != 'winrm' ansible.builtin.ping: