# Ansible.windows.win\_regedit is trying to use ssh

**URL:** <https://forum.ansible.com/t/ansible-windows-win-regedit-is-trying-to-use-ssh/2005>\
**Category:** Get Help\
**Tags:** windows\
**Created:** [October 27, 2023, 7:05pm UTC](https://forum.ansible.com/t/ansible-windows-win-regedit-is-trying-to-use-ssh/2005 "2023-10-27T19:05:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tlemons](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@tlemons](https://forum.ansible.com/u/tlemons)\
**Post date:** [October 27, 2023, 7:05pm UTC](https://forum.ansible.com/t/ansible-windows-win-regedit-is-trying-to-use-ssh/2005/1 "2023-10-27T19:05:31Z")

</div>

Hi - I’m using the ansible.windows.win\_regedit in one of my plays. In some of our Ansible environments, this module executes successfully; in other environments, it fails with the error:

```auto
fatal: [ldpdd193.hop.lab.emc.com]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host ldpdd193.hop.lab.emc.com port 22: Connection refused", "unreachable": true}

```

Here is the task code:

```auto
- name: "Set primary DNS suffix"
  ansible.windows.win_regedit:
    path: HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\
    name: Domain
    data: '{{ domain }}'

```

I have the following Windows-specific variables defined in the inventory file:

```auto
# For Windows systems
    ansible_winrm_server_cert_validation: ignore
    ansible_port: 5985
    ansible_winrm_transport: ntlm
    ansible_connection: winrm
    #ansible_connection: psrp
    ansible_winrm_message_encryption: always
    winrm_use_ssl: false
    ansible_winrm_scheme: http

```

Here are some relevant version numbers:

# ansible --version

ansible [core 2.15.5]  
config file = None  
configured module search path = [‘/root/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python3.10/site-packages/ansible  
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections  
executable location = /usr/bin/ansible  
python version = 3.10.13 (main, Sep 05 2023, 11:46:10) [GCC] (/usr/bin/python3.10)  
jinja version = 3.1.2  
libyaml = True  
ansible-galaxy collection list | grep win  
ansible.windows 1.14.0  
community.windows 1.13.0

I’m trying to compare the non-working and working environments now. But it would help if I knew why some Ansible executions would seemingly ignore the defined communication variables. Thanks!

---

<div class="post-metadata">

**Author:** ![ptn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ptn/32/481_2.png) [@ptn](https://forum.ansible.com/u/ptn)\
**Post date:** [October 30, 2023, 7:31pm UTC](https://forum.ansible.com/t/ansible-windows-win-regedit-is-trying-to-use-ssh/2005/2 "2023-10-30T19:31:44Z")

</div>

Hi,

You could list defined variables for a specific host this way: `ansible -i <inventoryFile> <targetHost> -m debug -a "var=hostvars[inventory_hostname]"`, see if you spot something that could override your Windows-specific connection vars.

---

<div class="post-metadata">

**Author:** ![tlemons](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@tlemons](https://forum.ansible.com/u/tlemons)\
**Post date:** [October 31, 2023, 4:17pm UTC](https://forum.ansible.com/t/ansible-windows-win-regedit-is-trying-to-use-ssh/2005/3 "2023-10-31T16:17:38Z")

</div>

Hi Pierre - thanks very much for this suggestion! tl
