mwrock / packer-templates

Templates for creating vagrant boxes
Other
536 stars 250 forks source link

ChefDK14 w/ chef-solo run fails due to Mixin #113

Open darkn3rd opened 6 years ago

darkn3rd commented 6 years ago

SUMMARY

Building Windows2016 fails in current Chef. Recommend jettisoning Chef as seems too cumbersome to maintain, and use something similar to Windows2012 w/ powershell scripts.

STEPS

cd cookbooks/packer-templates
rm Berksfile.lock
berks
berks vendor ../../vendor/cookbooks
cd ../..
packer build \
 -var 'iso_url=/path/to/14393.0.160715-1616.RS1_RELEASE_SERVER_EVAL_X64FRE_EN-US.ISO' \
 -force \
 -only virtualbox-iso \
 vbox-2016.json

RESULT

…
…
==> virtualbox-iso: Provisioning with chef-solo
    virtualbox-iso: Installing Chef...
    virtualbox-iso:
    virtualbox-iso: ModuleType Version    Name                                ExportedCommands
    virtualbox-iso: ---------- -------    ----                                ----------------
    virtualbox-iso: Script     0.0        Omnitruck                           {Get-ProjectMetadata, Install-Project, install}
    virtualbox-iso: Installing chef from C:\Users\vagrant\AppData\Local\Temp\chef-client-14.2.0-1-x64.msi
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso: Creating directory: C:/Windows/Temp/packer-chef-solo
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso:     Directory: C:\Windows\Temp
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso: Mode                LastWriteTime         Length Name
    virtualbox-iso: ----                -------------         ------ ----
    virtualbox-iso: d-----        6/17/2018   8:54 AM                packer-chef-solo
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso: 'skipping chmod 0777 C:/Windows/Temp/packer-chef-solo'
    virtualbox-iso: Creating directory: C:/Windows/Temp/packer-chef-solo/cookbooks-0
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso:     Directory: C:\Windows\Temp\packer-chef-solo
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso: Mode                LastWriteTime         Length Name
    virtualbox-iso: ----                -------------         ------ ----
    virtualbox-iso: d-----        6/17/2018   8:54 AM                cookbooks-0
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso: 'skipping chmod 0777 C:/Windows/Temp/packer-chef-solo/cookbooks-0'
    virtualbox-iso: Creating directory: C:/Windows/Temp/packer-chef-solo/cookbooks-1
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso:     Directory: C:\Windows\Temp\packer-chef-solo
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso: Mode                LastWriteTime         Length Name
    virtualbox-iso: ----                -------------         ------ ----
    virtualbox-iso: d-----        6/17/2018   8:55 AM                cookbooks-1
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso: 'skipping chmod 0777 C:/Windows/Temp/packer-chef-solo/cookbooks-1'
    virtualbox-iso: Creating configuration file 'solo.rb'
    virtualbox-iso: Creating JSON attribute file
    virtualbox-iso: Executing Chef: c:/opscode/chef/bin/chef-solo.bat --no-color -c C:/Windows/Temp/packer-chef-solo/solo.rb -j C:/Windows/Temp/packer-chef-solo/node.json
    virtualbox-iso: Starting Chef Client, version 14.2.0
    virtualbox-iso: resolving cookbooks for run list: ["wsus-client::configure", "packer-templates::install_ps_modules", "packer-templates::vbox_guest_additions", "packer-templates::uninstall_powershell_ise", "packer-templates::delete_pagefile"]
    virtualbox-iso: [2018-06-17T08:57:31+00:00] WARN: Child with name 'packer-templates' found in multiple directories: C:/Windows/Temp/packer-chef-solo/cookbooks-0/packer-templates and C:/Windows/Temp/packer-chef-solo/cookbooks-1/packer-templates
    virtualbox-iso: [2018-06-17T08:57:31+00:00] WARN: Child with name 'packer-templates' found in multiple directories: C:/Windows/Temp/packer-chef-solo/cookbooks-0/packer-templates and C:/Windows/Temp/packer-chef-solo/cookbooks-1/packer-templates
    virtualbox-iso: [2018-06-17T08:57:31+00:00] WARN: Child with name 'packer-templates' found in multiple directories: C:/Windows/Temp/packer-chef-solo/cookbooks-0/packer-templates and C:/Windows/Temp/packer-chef-solo/cookbooks-1/packer-templates
    virtualbox-iso: [2018-06-17T08:57:31+00:00] WARN: Child with name 'packer-templates' found in multiple directories: C:/Windows/Temp/packer-chef-solo/cookbooks-0/packer-templates and C:/Windows/Temp/packer-chef-solo/cookbooks-1/packer-templates
    virtualbox-iso: Synchronizing Cookbooks:
    virtualbox-iso:   - wsus-client (2.0.0)
    virtualbox-iso:   - packer-templates (0.1.0)
    virtualbox-iso:   - windows (4.3.2)
    virtualbox-iso: Installing Cookbook Gems:
    virtualbox-iso: Compiling Cookbooks...
    virtualbox-iso:
    virtualbox-iso: ================================================================================
    virtualbox-iso: Recipe Compile Error in c:/windows/temp/packer-chef-solo/local-mode-cache/cache/cookbooks/windows/libraries/windows_package.rb
    virtualbox-iso: ================================================================================
    virtualbox-iso:
    virtualbox-iso: LoadError
    virtualbox-iso: ---------
    virtualbox-iso: cannot load such file -- chef/mixin/language
    virtualbox-iso:
    virtualbox-iso: System Info:
    virtualbox-iso: ------------
    virtualbox-iso: chef_version=14.2.0
    virtualbox-iso: platform=windows
    virtualbox-iso: platform_version=10.0.14393
    virtualbox-iso: ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32]
    virtualbox-iso: program_name=c:/opscode/chef/bin/chef-solo
    virtualbox-iso: executable=c:/opscode/chef/bin/chef-solo
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso: Running handlers:
    virtualbox-iso: [2018-06-17T08:57:32+00:00] ERROR: Running exception handlers
    virtualbox-iso: [2018-06-17T08:57:32+00:00] ERROR: Running exception handlers
    virtualbox-iso: Running handlers complete
    virtualbox-iso: [2018-06-17T08:57:32+00:00] ERROR: Exception handlers complete
    virtualbox-iso: [2018-06-17T08:57:32+00:00] ERROR: Exception handlers complete
    virtualbox-iso: Chef Client failed. 0 resources updated in 06 seconds
    virtualbox-iso: [2018-06-17T08:57:32+00:00] FATAL: Stacktrace dumped to c:/windows/temp/packer-chef-solo/local-mode-cache/cache/chef-stacktrace.out
    virtualbox-iso: [2018-06-17T08:57:32+00:00] FATAL: Stacktrace dumped to c:/windows/temp/packer-chef-solo/local-mode-cache/cache/chef-stacktrace.out
    virtualbox-iso: [2018-06-17T08:57:32+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
    virtualbox-iso: [2018-06-17T08:57:32+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
    virtualbox-iso: [2018-06-17T08:57:32+00:00] FATAL: LoadError: cannot load such file -- chef/mixin/language
    virtualbox-iso: [2018-06-17T08:57:32+00:00] FATAL: LoadError: cannot load such file -- chef/mixin/language
==> virtualbox-iso: Deregistering and deleting VM...
==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored: Error executing Chef: Non-zero exit status: 1
darkn3rd commented 6 years ago

The compile error for windows/libraries/windows_package.rb is due to the removal of chef/mixin/language in Chef 14. But the windows_package.rb still relies on this.

Thus it seems that windows_package.rb is no longer compatible with Chef 14, which is what vbox-2016.json attempts to use.

darkn3rd commented 6 years ago

Upon further research, it seems according to docs from https://github.com/chef-cookbooks/windows, quite a few of the libraries have been updated and included as resources in Chef 14. So I removed the dependency on the windows cookbook, and so far it seems to be working.

Update: Current ChefDK, remove the dependency to windows library, fixes it.

darkn3rd commented 6 years ago

I created this blog to give a how-to step-by-step and workaround for issue:

darkn3rd commented 6 years ago

Related. The cookbook shouldn't crash the very least. Wrote up bug in https://github.com/chef-cookbooks/windows/issues/564, but they don't seem interested in looking at it.

lavahot commented 6 years ago

Are you intending to submit a pull request here for this?

darkn3rd commented 5 years ago

I will look at it when I get a chance. Not sure if the author is interested, as this project hasn't been touched for 2+ years.

Perhaps one easy fix is to specify the version, otherwise is uses the latest: https://www.packer.io/docs/provisioners/chef-solo.html#version.