0

Playbook.yml

---
- name: connectionTest
  hosts: Windows
  tasks:
  - name: "Windows Connect"
    win_command: hostname
    register: wincmd_out

Variable declared in Inventories Project/inventories/XXX_Local/

[Windows]
XXVMxxxxxxx

Error Message:

fatal: [XXVMxxxxxxx]: UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: Control socket \"/tmp/awx_1636443_S7HHdB/cp/6b18046463\" does not exist\r\ndebug2: resolving \"XXVMxxxxxxx\" port 22\r\nssh: Could not resolve hostname XXVMxxxxxxx: Name or service not known", 
    "unreachable": true
}

1 Answer 1

1

Looking at your code it seems you try to connect to a Windows host. Usually you connect windows via WinRM and not via ssh

The user guide for this can be found here: https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html

For Ansible to communicate to a Windows host and use Windows modules, the Windows host must meet the following requirements:

  • Ansible’s supported Windows versions generally match those under current and extended support from Microsoft. Supported desktop OSs include Windows 7, 8.1, and 10, and supported server OSs are Windows Server 2008, 2008 R2, 2012, 2012 R2, 2016, and 2019.
  • Ansible requires PowerShell 3.0 or newer and at least .NET 4.0 to be installed on the Windows host.
  • A WinRM listener should be created and activated. More details for this can be found below.

Then you need to tell ansible to connect wia winrm

...
ansible_connection=winrm
...

Checkout the details here: https://www.ansible.com/blog/connecting-to-a-windows-host

1
  • Yes your correct, in group_vars i mentioned ansible_connection=winrm , but i don't no why it is trying to connect via ssh Commented Sep 26, 2019 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.