Install ChefDK on Windows

From Bonus Bits
Jump to: navigation, search

Purpose

This article gives the steps to install ChefDK on Windows 7/8/10. All commands are executed in PowerShell 4.0.


Create Dev Directory

  1. Create **C:\Dev** Folder (Shortens path as a workaround to 260 character limitation) with **chef\cookbooks** Folder for cookbooks. Or a path of your choosing that is short and excluded from anit-virus realtime scanning.
    mkdir C:\Dev\chef\cookbooks
    


Install

  1. Run the chefdk msi file
  2. Select ChefDK Environment Customizations
  3. Set Location to C:\Dev
    1. Select Chef Development Kit | Browse...
    2. Type C:\Dev
      1. Which will create C:\Dev\chefdk


PowerShell Profile

  1. Open PowerShell as administrator.
  2. Set PowerShell execution policy.
    Set-ExecutionPolicy unrestricted
    
  3. Create WindowsPowerShell user directory
    mkdir $env:USERPROFILE\Documents\WindowsPowerShell
    

Option 1 (root directory)

  1. Added Dev Home Path to PowerShell user profile (Optional - but will have to change syntax on rest of commands if you opt to not set this)
    [Environment]::SetEnvironmentVariable("DEV_HOME", "C:\Dev", "Machine")
    
    1. Add this as temporary setting for following environment variable creation or close and re-open Shell
      $ENV:DEV_HOME = "C:\Dev"
      
  2. Added ChefDK Home Path to System Environment variable.
    [Environment]::SetEnvironmentVariable("CHEFDK_HOME", "$ENV:DEV_HOME\.chefdk", "Machine")
    
  3. Added VirtualBox Home Path to System Environment variable.
    [Environment]::SetEnvironmentVariable("VBOX_USER_HOME", "$ENV:DEV_HOME\.VirtualBox", "Machine")
    
  4. Added Vagrant Home Path to System Environment variable.
    [Environment]::SetEnvironmentVariable("VAGRANT_HOME", "$ENV:DEV_HOME\.vagrant.d", "Machine")
    
  5. Added ChefDK init to PowerShell user profile
    Add-Content -Path $PROFILE -Value 'chef shell-init powershell | Invoke-Expression' -ErrorAction Stop
    
  6. Close and Re-Open Shell

Option 2 (userprofile)

If on a system that you don't have permissions to create a directory at a root level or it won't persist such as on a AWS Workspace; then you can direct items to your userprofile. Which usually is the default, but this ensures the setting.

  1. [Environment]::SetEnvironmentVariable("DEV_HOME", "$ENV:USERPROFILE\Dev", "User")
    
    1. Add this as temporary setting for following environment variable creation or close and re-open Shell
      $ENV:DEV_HOME = "$ENV:USERPROFILE\Dev"
      
  2. Added ChefDK Home Path to System Environment variable.
    [Environment]::SetEnvironmentVariable("CHEFDK_HOME", "$ENV:USERPROFILE\.chefdk", "User")
    
  3. Added VirtualBox Home Path to System Environment variable.
    [Environment]::SetEnvironmentVariable("VBOX_USER_HOME", "$ENV:USERPROFILE\.VirtualBox", "User")
    
  4. Added Vagrant Home Path to System Environment variable.
    [Environment]::SetEnvironmentVariable("VAGRANT_HOME", "$ENV:USERPROFILE\.vagrant.d", "User")
    
  5. Added ChefDK init to PowerShell user profile
    Add-Content -Path $PROFILE -Value 'chef shell-init powershell | Invoke-Expression' -ErrorAction Stop
    
  6. Close and Re-Open Shell


Proxy (Optional)

Add the following environment variables if your workstation is behind a Proxy.

  1. Added HTTP Proxy System Environment variable.
    [Environment]::SetEnvironmentVariable("HTTP_PROXY", "http://username:password@proxy.domain.com:8000", "Machine")
    
  2. Added HTTPS Proxy System Environment variable.
    [Environment]::SetEnvironmentVariable("HTTPS_PROXY", "https://username:password@proxy.domain.com:8000", "Machine")
    

OR

  1. Setup Charles Proxy


Sources