Ansible.windows.win_regedit is trying to use ssh

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:

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:

- 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:

# 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!

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.

Hi Pierre - thanks very much for this suggestion! tl