packer chef-solo issue (windows)

260 views
Skip to first unread message

Fabio Mosti

unread,
Dec 11, 2014, 8:17:54 AM12/11/14
to packe...@googlegroups.com
Hi,
I'm having a weird issue when using packer and chef-solo to configure winrm in windows 2008R2.

My setup is Windows2008R2 with OpenSSH.

I have a single recipe with a single simple resource:

powershell_script 'enable winrm' do
 code <<-EOH
 winrm quickconfig -q
  EOH
end

It fails with this error:

     virtualbox-ovf: [2014-12-11T12:03:41-08:00] INFO: Running queued delayed notifications before re-raising exception
    virtualbox-ovf: [2014-12-11T12:03:41-08:00] ERROR: Running exception handlers
    virtualbox-ovf: [2014-12-11T12:03:41-08:00] ERROR: Exception handlers complete
    virtualbox-ovf: [2014-12-11T12:03:41-08:00] FATAL: Stacktrace dumped to C:/chef/cache/chef-stacktrace.out
    virtualbox-ovf: [2014-12-11T12:03:41-08:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: powershell_script[enable winrm] (paas_windows::enable_winrm line 1) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
    virtualbox-ovf: ---- Begin output of "powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy RemoteSigned -InputFormat None -File "C:/Users/Administrator/AppData/Local/Temp/chef-script20141211-1980-6u6cd3.ps1" ----
    virtualbox-ovf: STDOUT:
    virtualbox-ovf: STDERR: WSManFault    Message = Access is denied

The same resource is executed properly if I execute chef-solo (installed by packer) in the same VM, with the same configuration and the same ssh credential from my terminal.
Example:

ssh -l Administrator localhost -p 4104 "c:/opscode/chef/bin/chef-solo --no-color -c c:/windows/temp/solo.rb -j c:/windows/temp/node.json"



[2014-12-11T12:17:17-08:00] INFO: Processing powershell_script[enable winrm] action run (paas_windows::enable_winrm line 1)
[2014-12-11T12:17:17-08:00] INFO: powershell_script[enable winrm] ran successfully
[2014-12-11T12:17:17-08:00] INFO: Chef Run complete in 0.609375 seconds
[2014-12-11T12:17:17-08:00] INFO: Running report handlers
[2014-12-11T12:17:17-08:00] INFO: Report handlers complete

follow my provisioners block:
"provisioners": [
 {
     "type": "chef-solo",
     "cookbook_paths": ["./cookbook"],
     "install_command": "echo \"\n\" | powershell -Command \"(New-Object System.Net.WebClient).DownloadFile('https://opscode-omnibus-packages.s3.amazonaws.com/windows/2008r2/x86_64/chef-windows-11.16.4-1.windows.msi', 'C:\\Windows\\Temp\\chef.msi’)\" ; cmd /c 'msiexec /qb /i C:\\Windows\\Temp\\chef.msi'",
     "execute_command": "c:/opscode/chef/bin/chef-solo --no-color -c {{.ConfigPath}} -j {{.JsonPath}}",
     "staging_directory": "c:/windows/temp",
     "prevent_sudo": true,
     "skip_install": false,
     "run_list": ["paas_windows::enable_winrm"]
   }

Any Ideas ?

Fabian Ruff

unread,
Dec 11, 2014, 4:20:28 PM12/11/14
to packe...@googlegroups.com
Hi Fabio,

I experienced exactly the same issues you are describing when trying to enable winrm via a shell provisioner on windows 2008.
It seems something is odd/different about the ssh session packer sets up compared to a manual one on windows.
Maybe it is only related to the openssh server I used (http://www.mls-software.com/opensshd.html). I didn't try another one.

Unfortunately I was unable to solve this problem and worked around it by enabling winrm via Autounattended.xml.
I believe this bug is related: https://github.com/mitchellh/packer/issues/700
During my brief debugging session the only difference between packers ssh session and a manual one was a different value in the `USERNAME` variable as described in this comment: https://github.com/mitchellh/packer/issues/700#issuecomment-31147548


Kind regards,
Fabian

Fabio Mosti

unread,
Dec 11, 2014, 4:44:52 PM12/11/14
to packe...@googlegroups.com
Hi Fabian,

Thanks so much for your reply, I really appreciate it.

Cheers,
Fabio 
Reply all
Reply to author
Forward
0 new messages