Packer: Chef-solo provisioning on Windows

Created on 4 Aug 2017  Â·  20Comments  Â·  Source: hashicorp/packer

Chef solo isn't installing on Windows Server 2008 R2. Other provisioning like shell and powershell are working fine, but when it comes to chef-solo provisioning, the inbuilt installation script gets stuck.

I tried the following workarounds:

  • Overriding the inbuilt command with install_command. Doesnt work
  • Have a shell provisioning with installation command. Doesnt work
  • Have a powershell provisioning with installation command. Doesnt work

The guest VM is Windows Server 2008 R2. It has dotNet 4.5 and Windows Management Framework 5.0 installed (Powershell v5 is present).

  • Packer version : Tested with 1.0.0 and 1.0.3
  • Host platform : Ubuntu 16.04
  • End output from logs:

    2017/08/04 21:10:01 [INFO] (telemetry) Starting provisioner chef-solo
    2017/08/04 21:10:01 ui: ==> virtualbox-iso: Provisioning with chef-solo
    2017/08/04 21:10:01 ui:     virtualbox-iso: Installing Chef...
    2017/08/04 21:10:01 packer: 2017/08/04 21:10:01 opening new ssh session
    2017/08/04 21:10:01 packer: 2017/08/04 21:10:01 starting remote command: powershell.exe -Command ". { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; Install-Project"
    2017/08/04 21:10:22 ui:     virtualbox-iso:
    2017/08/04 21:10:22 ui:     virtualbox-iso: ModuleType Version    Name                                ExportedCommands
    2017/08/04 21:10:22 ui:     virtualbox-iso: ---------- -------    ----                                ----------------
    2017/08/04 21:10:22 ui:     virtualbox-iso: Script     0.0        Omnitruck                           {Get-ProjectMetada...
    
  • Provisioning script:

    {
      "type": "chef-solo",
      "guest_os_type": "windows",
      "cookbook_paths": ["chef/cookbooks"],
      "run_list": [
        "recipe[metasploitable::root_certs]",
        "recipe[metasploitable::vagrant_ssh]",
        "recipe[metasploitable::disable_auto_logon]",
        "recipe[metasploitable::enable_rdp]"
      ]
    },
    

Look at the entire script here.

bug buildevirtualbox community-supported plugin provisionechef windows-guest

All 20 comments

I'm experiencing the same issue. I left the provisioner going for almost 45 minutes and didn't make any progress. Note the timestamp of the process start time and the current system time.
screen shot 2017-08-04 at 1 27 39 pm

I also tried various different install_command variations and didn't fix it. I did try running the command from the command line within the VM, and it works fine there.

I then tried to install using the chef msi instead of the powershell script. I hit the same issue as described here.

Thanks for reporting. Looks like this is related to https://github.com/hashicorp/packer/issues/4994. Might close one of these issues as a duplicate. I'm gonna take a few minutes to investigate now.

@Chan9390 any chance you can give me a gist containing your complete logs with PACKER_LOG=1 ?

Hey @SwampDragons sorry for being late.
The script doesnt stop and chef-solo / chef-client is not installed. Here's the log file:
packerlogs.txt
The packer script could be found here.

Thanks. Will report back when I have an update.

@SwampDragons Any updates ?

Hadn't gotten a chance to look at it yet -- I'll make sure to let you know when I do.

the output is slightly different from #4994

@Chan9390 could you add the autounattend file so we can try to reproduce this?

Autounattend.xml : Autounattend.xml.tar.gz
You can find the windows_2008_r2.json file at https://github.com/rapid7/metasploitable3/blob/windows_chef/windows_2008_r2.json

To reproduce on your side you could clone the repository : https://github.com/rapid7/metasploitable3/tree/windows_chef , checkout to windows_chef branch and start the packer build.

@SwampDragons @mwhooker Any updates ?

We did just merge some code that changed the chef provisioner install -- do you think you can try on 1.1.3 and tell us if you're experiencing the issue still?

Hey @SwampDragons , I updated packer but still I see the same error.

I've repro'd with virtualbox on my mac.

@jbarnett-r7 is your example also on virtualbox?

Correct. Latest version.

On Dec 15, 2017 6:24 PM, "SwampDragons" notifications@github.com wrote:

@jbarnett-r7 https://github.com/jbarnett-r7 is your example also on
virtualbox?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hashicorp/packer/issues/5220#issuecomment-352144115,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALq28RnbCFsPXR6PJ3QKkvGcicrzgNk4ks5tAw3IgaJpZM4Ot7ar
.

Hrm. the chef command is never returning from here https://github.com/hashicorp/packer/blob/aab786dd1ae730f208c3f901c6059c007f666500/communicator/ssh/communicator.go#L112 and I can't figure out why.

Any updates @SwampDragons ?

No -- I haven't had a chance to come back to this because of internal development obligations. I'll update when I get a chance to investigate further, or someone else can.

Any updates ?

No updates; this is a community-supported provisioner so it's fairly low on the core maintianer's priority list. One thing I find strange is that the bento box project that builds a windows 2008 box successfully installs chef with powershell.exe -Command "(new-object Net.WebClient).DownloadString('https://omnitruck.chef.io/install.ps1') | iex; install" but when I try to run the same command to install chef on your metasploitable box, I can't. If you can figure out what the difference is, you'll be on your way. Edit: looks like that box uses winrm, so it may be the communicator.

Was this page helpful?
0 / 5 - 0 ratings