Closed
Description
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: https://www.packer.io/docs/provisioners/ansible.html
I do have the packer.py 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/packer.py
-rw-rw-r-- 1 ruzickap ruzickap 511 Apr 6 11:32 /home/ruzickap/.ansible/plugins/connection_plugins/packer.py
The WinRM is enabled when Windows Server (by running Autounattend.xml https://gist.github.com/ruzickap/8d5d96fbc24cda80a0ff2fc0c9b8835e) 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).
- Packer version: Packer v1.0.0
- Host platform: Fedora 25
- Debug log output: https://gist.github.com/ruzickap/6d76a30f4d7578b1a87b8723f5068211
- Templates + Files:
Simple ansible playbook "win.yml":
---
- hosts: all
gather_facts: no
tasks:
- name: Start NTP service (w32time)
win_service:
name: w32time
state: started
- name: Configure NTP
raw: w32tm /config /manualpeerlist:"ntp.cesnet.cz" /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)
win_regedit:
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":
{
"builders":
[
{
"name": "windows-server-2016-eval",
"type": "qemu",
"iso_checksum_type": "sha256",
"iso_checksum": "1ce702a578a3cb1ac3d14873980838590f06d5b7101c5daaccbac9d73f1fb50f",
"iso_urls": [ "http://care.dlservice.microsoft.com/dl/download/1/4/9/149D5452-9B29-4274-B6B3-5361DBDA30BC/14393.0.161119-1705.RS1_REFRESH_SERVER_EVAL_X64FRE_EN-US.ISO" ],
"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": [
"Autounattend.xml"
]
}
],
"provisioners": [
{
"type": "ansible",
"user": "vagrant",
"playbook_file": "win.yml",
"extra_arguments": [
"--connection", "packer",
"--extra-vars", "ansible_shell_type=powershell ansible_shell_executable=None",
"-vvv"
]
}
],
"post-processors": [
[
{
"type": "vagrant",
"output": "{{ user `name` }}-{{.Provider}}.box"
}
]
]
}