Chef scripts for standalone Sitecore provisioning as side-effects of Sitecore-Packer

It’s been a few months since I’ve published Packer templates for Sitecore. Their main purpose is to create Virtual Box images with a fully configured Sitecore instance. So far I have both updates for Sitecore 9.0 CMS and Sitecore Commerce 9.0.1 scripted there.

Recently one of my colleagues was tasked with a configuration of standalone commerce server in private cloud. ARM templates weren’t really useful there and we are too lazy to install everything manually. So we found an interesting side effect of Packer.


As a part of a build process, it creates …\build\w16s-xc901\virtualbox-core\provisioners\chef\upload folder and attached it as a floppy drive (A: and B: are reserved for them historically) to a virtual machine. In this folder, you can find an archive with all chef cookbooks used in the repository and two files prepare.ps1 and cleanup.ps1.

Packer runs berks command from chef to gather cookbooks you can run it manually as well.

berks package -b d:\packer\build\w16s-xc901\virtualbox-core\provisioners\chef\Berksfile d:\tmp\cookbooks.tar.gz

Assuming that you have chocolatey installed on the machine, running prepare.ps1 will install chef-solo and unpack your cookbooks. This is where you can run chef manually and it will configure your machine 🙂

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString(''))

mkdir C:\packer-chef -ErrorAction Continue
mkdir C:\tmp -ErrorAction Continue
mkdir C:\tmp\packer-chef-solo -ErrorAction Continue
mkdir C:\tmp\packer-chef-solo\cache -ErrorAction Continue

Write-Host "Installing Chef Client"
choco install chef-client -y --version 13.4.24

Write-Host "Installing 7zip"
choco install 7zip.portable -y

Write-Host "Extracting cookbooks"
7z x C:\packer-chef\cookbooks.tar.gz -o"C:\packer-chef" -aoa
7z x C:\packer-chef\cookbooks.tar -o"C:\packer-chef" -aoa

Running chef-solo

In order to run chef, you will need to execute the following command:

c:/opscode/chef/bin/chef-solo.bat --no-color -c /tmp/packer-chef-solo/solo.rb -j /tmp/packer-chef-solo/node.json

It required two files, solo.rb with the following content:

file_cache_path 'C:/tmp/packer-chef-solo/cache'
solo true
cookbook_path ['C:/packer-chef/cookbooks']

And node.json with the following content:

  "run_list": [

Once this run finished (IIS, MS SQL, and SOLR will be installed), replace the content of node.json with following and run once again. Otherwise, SQL extensions won’t be registered and related Powershell tasks will fail. This will install Sitecore.

  "run_list": [

Once all scripts, executed you will have Sitecore CMS and Commerce installed on a machine.


I won’t lie, we spent at least a day extracting chef scripts from Packer, but it was much more fun the following installations checklists. And now we have standalone provisioning script that doesn’t require more than a creation of a few folders and copying a few files.

Where to find?

You could find the source code of Sitecore-Packer repository on GitHub:

Follow me on twitter @true_shoorik. Would be glad to discuss ideas above in comments.

Chef scripts for standalone Sitecore provisioning as side-effects of Sitecore-Packer

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s