ruzickap / packer-templates

Scripts and Templates used for generating Vagrant images
Apache License 2.0
443 stars 113 forks source link

QEMU Windows 10 connection refused with Ansible #450

Closed jrowinski3d closed 1 year ago

jrowinski3d commented 1 year ago

As per the title, I am getting Connection Refused in my Windows 10 VM.

qemu: fatal: [127.0.0.1]: UNREACHABLE! => {"changed": false, "msg": "ssl: HTTPSConnectionPool(host='127.0.0.1', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x1029cb190>: Failed to establish a new connection: [Errno 61] Connection refused'))", "unreachable": true}

I put in a breakpoint prior to Ansible and do see that WinRM is running on both HTTP(S).

I am running on on OSX, I am wondering if anyone else has these issues?

$ pip3 list | grep ansible
ansible            7.2.0
ansible-core       2.14.2

$ packer --version
1.8.6
ruzickap commented 1 year ago

Hello. It looks like the problem is in Ansible version: https://github.com/ruzickap/packer-templates/issues/411

Can you please try Ansible 5.x

jrowinski3d commented 1 year ago

You are correct @ruzickap . I will see if I can dig into it to determine whats happening with higher versions of Ansible. Something seems to point to https://github.com/ansible/ansible/issues/69542

jrowinski3d commented 1 year ago

Just to update, switching to this setup works: Came across this doc: https://docs.ansible.com/ansible/latest/os_guide/windows_winrm.html#what-is-winrm

Specifically talks about the no_proxy option on MacOSX

      {
        "type": "ansible",
        "extra_arguments": [
          "-e", "ansible_shell_type=powershell",
          "-e", "ansible_shell_executable=None",
          "-e", "ansible_winrm_server_cert_validation=ignore",
          "-e", "ansible_password='{{ user `winrm_password` }}'"
        ],
        "use_proxy": false,
        "playbook_file": "ansible/main.yml",
        "user": '{{ user `winrm_user` }}'
      },
ruzickap commented 1 year ago

Just to update, switching to this setup works: Came across this doc: docs.ansible.com/ansible/latest/os_guide/windows_winrm.html#what-is-winrm

Specifically talks about the no_proxy option on MacOSX

      {
        "type": "ansible",
        "extra_arguments": [
          "-e", "ansible_shell_type=powershell",
          "-e", "ansible_shell_executable=None",
          "-e", "ansible_winrm_server_cert_validation=ignore",
          "-e", "ansible_password='{{ user `winrm_password` }}'"
        ],
        "use_proxy": false,
        "playbook_file": "ansible/main.yml",
        "user": '{{ user `winrm_user` }}'
      },

Thank you for the tip. Few years back the packer "ansible" provider was broken and there were some issues with using winrm - that's the reason why I'm not using it.

I tried the code above and it is working fine - I'm going to use it in the templates.

Thank you

PetrR