Skip to content

Instantly share code, notes, and snippets.

@ericcalabretta
Last active July 20, 2020 16:44
Show Gist options
  • Save ericcalabretta/5994ef1297c88d6238ccd46f9d5de15c to your computer and use it in GitHub Desktop.
Save ericcalabretta/5994ef1297c88d6238ccd46f9d5de15c to your computer and use it in GitHub Desktop.
Using chef zero with policyfile archive

Using chef zero with policyfile archive

Prep Steps:

  1. Create the archive to share. This includes all the cookbooks, dependencies and config needed to run Chef-Client in a local mode. It's also versioned so you can track what exactly you ran.
git clone the desired cookbook 
move into directory
chef install
chef export -a path_to_cookbook_destination

You'll see something like this wherever you decided to place the archive.

cis-windows-ms-2016-095c057fb12a326b19dda0522785f4133eacb17c8265a79187d380ef4e7fd45d.tgz

Place the archive somewhere it's accessible to everyone that needs to use it like Artifactory

Using Chef-Client in local mode to build a complant packer template:

  1. download chef client from downloads.chef or from internal artifactory server https://downloads.chef.io/chef#windows

  2. Install chef-client MSI on the host

  3. Chef Infra Client must have two entries added to the PATH environment variable:

C:\opscode\chef\bin
C:\opscode\chef\embedded\bin
$env:Path += ";C:\opscode\chef\bin"
$env:Path += ";C:\opscode\chef\embedded\bin"
  1. Download the archive to disk

  2. Uncompress the archive

mkdir my_cookbook_name
tar -xvf .\cis-windows-ms-2016-095c057fb12a326b19dda0522785f4133eacb17c8265a79187d380ef4e7fd45d.tgz -C my_cookbook_name
  1. Move into the my_cookbook_name directory and run chef
cd my_cookbook
chef-client -z 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment