- name: Try connecting to linux ping: register: lin_ping_data ignore_unreachable: true ignore_errors: true - name: Set shell to powershell set_fact: ansible_shell_type: powershell when: lin_ping_data is undefined or lin_ping_data.unreachable is defined - name: Try connecting to windows win_ping: register: win_ping_data ignore_unreachable: true ignore_errors: true - name: Set connection parameters and paths for Windows become: false set_fact: ansible_shell_type: powershell ansible_connection: ssh ansible_become_method: runas ansible_become_flags: "" ansible_become_user: "{{ windows_user }}" logon_type: interactive installers: \\ucilnicesmb.fri1.uni-lj.si\ucilnice_d\install when: win_ping_data is defined and win_ping_data.ping is defined - name: Set connection parameters and paths for Ubuntu set_fact: ansible_become_method: sudo ansible_become_flags: "" ansible_ssh_extra_args: '-o ForwardX11=yes' installers: /mnt/ucilnice_d/install when: lin_ping_data is defined and lin_ping_data.ping is defined