Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not build Windows by Packer using Qemu + Ansible + WinRM #4773

ruzickap opened this issue Apr 6, 2017 · 6 comments

Can not build Windows by Packer using Qemu + Ansible + WinRM #4773

ruzickap opened this issue Apr 6, 2017 · 6 comments


Copy link

ruzickap commented Apr 6, 2017

I'm trying to build the Windows Server 2016 using Qemu + Ansible + WinRM. I would like to use Ansible for windows configuration by using winrm like it's described here:

I do have the installed in the ~/.ansible/plugins/connection_plugins/ directory and configured in ~/.ansible.cfg:

$ grep connection_plugins ~/.ansible.cfg
connection_plugins = ~/.ansible/plugins/connection_plugins/:/usr/share/ansible_plugins/connection_plugins
$ ls -la ~/.ansible/plugins/connection_plugins/
-rw-rw-r-- 1 ruzickap ruzickap 511 Apr  6 11:32 /home/ruzickap/.ansible/plugins/connection_plugins/

The WinRM is enabled when Windows Server (by running Autounattend.xml is installed and packer can use it. When the provisioning part started - ansible can not use WinRM properly and I got the error (see the log).

Simple ansible playbook "win.yml":

- hosts: all
  gather_facts: no

    - name: Start NTP service (w32time)
        name: w32time
        state: started

    - name: Configure NTP
      raw: w32tm /config /manualpeerlist:"" /reliable:yes /update

    - name: Enable Remote Desktop
      raw: set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0

    - name: Allow connections from computers running any version of Remote Desktop (less secure)
        key: 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp'
        value: UserAuthentication
        data: 0
        datatype: dword

    - name: Allow RDP traffic
      raw: Enable-NetFirewallRule -DisplayGroup "Remote Desktop"

Packer template "windows-server-2016-eval-ansible.json":

      "name": "windows-server-2016-eval",
      "type": "qemu",
      "iso_checksum_type": "sha256",
      "iso_checksum": "1ce702a578a3cb1ac3d14873980838590f06d5b7101c5daaccbac9d73f1fb50f",
      "iso_urls": [ "" ],
      "communicator": "winrm",
      "winrm_username": "Administrator",
      "winrm_password": "vagrant",
      "winrm_timeout": "12h",
      "winrm_use_ssl": "true",
      "winrm_insecure": "true",

      "qemuargs": [[ "-display", "gtk" ], [ "-m", "4G" ], [ "-smp", 2 ]],
      "disk_size": "51200",

      "disk_interface": "ide",
      "net_device": "e1000",

      "floppy_files": [
  "provisioners": [
      "type": "ansible",
      "user": "vagrant",
      "playbook_file": "win.yml",
      "extra_arguments": [
        "--connection", "packer",
        "--extra-vars", "ansible_shell_type=powershell ansible_shell_executable=None",
  "post-processors": [
        "type": "vagrant",
        "output": "{{ user `name` }}-{{.Provider}}.box"
Copy link

mwhooker commented Apr 6, 2017

Thanks for the report, @ruzickap. If you don't get any help here, you might have better luck sending an email to the mailing list. People who look at the github issues tend to be most helpful when it comes to bugs in the source code

Copy link

andmos commented Jun 1, 2017

@ruzickap have you come any way with this? I am looking to do something similar with Server 2012 on a CentOS build server, would be nice to know if I only have trouble in front of me..

Copy link
Contributor Author

ruzickap commented Jun 1, 2017

I'm sorry, but I have never seen packer configuration files + ansible playbooks which I can deploy windows machine using Qemu + Ansible + WinRM.
I hope somebody will describe it properly one day (or packer will support it - like it's in the documentation)...

Copy link

From the logs it looks like the template in the original post works fine except that it fails on some ansible task. If you edit the playbook to just have the first task and run doesn't it work then?

Copy link
Contributor Author

ruzickap commented Oct 7, 2017

Hello guys.

I just tested it with Ansible 2.4 and the bug was fixed.

Closing the issue...

@ruzickap ruzickap closed this as completed Oct 7, 2017
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days . This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashicorp hashicorp locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

4 participants