Useful Chef development prerequisites

The PowerShell commands below are some main steps needed to configure Chef on a development machine; still, they are not the only needed steps, there are others, like adding the SSH key to GitLab, downloading PEM key from Chef server, maybe Azure configuration, etc.

# Installing packages with Chocolatey
choco install atom -y
choco install git -y
choco install poshgit -y
choco install chefdk -y
choco install virtualbox -y
choco install virtualbox.extensionpack -y
choco install vagrant -y
choco install vagrant-winrm-config -y

# Restart required after packages installation
Restart-Computer

# Install gems for Pester and chef-vault, if used for tests
chef gem install kitchen-pester
chef gem install chef-vault-testfixtures

# Environment variables configuration
$home_folder = “d:\home”
$chef_user = “”
$chef_repo = “d:\repos”
$chef_module = “your-chef-module”
if (!(Test-Path $home_folder)) {
  mkdir $home_folder
}
[Environment]::SetEnvironmentVariable(“Path”, $env:Path + “;C:\Program Files\Git\usr\bin”, “Machine”)
[Environment]::SetEnvironmentVariable(“HOME”, “$home_folder”, “User”)
[Environment]::SetEnvironmentVariable(“CHEF_ORG”, “your-organization”, “User”)
[Environment]::SetEnvironmentVariable(“CHEF_USER”, $chef_user, “User”)
[Environment]::SetEnvironmentVariable(“Path”, $env:Path + “;C:\HashiCorp\Vagrant\bin”, “Machine”)
[Environment]::SetEnvironmentVariable(“VAGRANT_HOME”, “$env:HOME\vagrant.d”, “User”)

# Git configuration
git config –global user.name “”
git config –global user.email “”
git config –global push.default simple

# SSH key generation
ssh-keygen -t rsa -b 4096 -C “”

# Handle Git repository locally
cd $chef_repo
git clone git@gitlab.com:cookbooks-parent-folder/$chef_module.git
cd $chef_module
git submodule update –init –remote

# Handle knife settings
Copy-Item “$chef_repo\$chef_module\chef\.chef\knife.rb” “$env:HOME\.chef\knife.rb”

# Install vagrant plugin for WinRM
vagrant plugin install vagrant-winrm

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: