Chef notes and usage scenarios using chefdk on windows

install chef on windows via winrm to (ssl over winrm 5986)

knife bootstrap windows winrm ncsqldr.cloudapp.net --winrm-user --winrm-password '<password>'--node-name ncsqldr --winrm-transport ssl --winrm-port 5986

install chef on windows via winrm. currently there is an issue with verifying ssl certs that were created for the domain you are registered to ( typically if you create a vm in azure or aws) so we are going to use use the non ssl

knife bootstrap windows winrm <Windows Address> --winrm-user <username> --winrm-password '<password>' --node-name ncsqldr --winrm-port 5985 -r "role[<orgname>-windows]"

install chef on linuux via ssh

knife bootstrap <linuxaddress> --ssh-password '<password>'--ssh-user <username>--node-name cortexnodeapp --run-list "role[<orgname>-cortex]" --use-sudo-password  --ssh-port 6022 --sudo

install chef on linuux via ssh using public key

knife bootstrap <linux address> -i "C:\Users\Mak Sanda\OneDrive\mak_linux" --ssh-user <username>--node-name cortexpythonapp --run-list "role[<orgname>-cortex]" --use-sudo-password  --ssh-port 7022 --sudo

https://supermarket.chef.io/ - to get new publicly availble recipes

Upload users via knife to server

knife data_bag from file users data_bags\users\

upload admins via knife to server

knife data_bag from file admins data_bags\admins\

Create Databag for users

mkdir data_bags/users
knife data bag create users
Create your <username>.json files

Admin

mkdir data_bags/admins
knife data bag create admins

Use knife to encrypt passwords in a role

knife encrypt password --search "role:web_server" --username "install" -- password "password" --admins "install, mak"

Create a cookbook

cd ~/chef-repo
knife cookbook create <cookbook_name>

upload cookbooks

cd to directory
knife cookbook upload --all

To upload a specific cookbook

cd to cookbooks
knife cookbook upload <cookbookname>

upload roles

cd to roles directory
knife role from file .\<nameofrole>.rb

to list all roles on servers

knife role list

Change into the chef-cookbooks directory on your Workstation:

cd ~/chef-cookbooks

git checkout the master branch:

git checkout master

Pull the latest code:

git pull

git checkout the v4.2.1 tag:

git checkout v4.2.1

Initialize your local configuration file:

git submodule init

Sync the submodules:

git submodule sync

Fetch all data from the submodules:

git submodule update

This is optional, but to ensure only the latest cookbooks are used, delete all of the current cookbooks (only perform this on a Chef Server dedicated to Rackspace Private Cloud):

knife cookbook bulk delete .

This is optional, but to ensure only the latest roles are used, delete all of the current roles (only perform this on a Chef Server dedicated to Rackspace Private Cloud):

knife role bulk delete .

Upload cookbooks to the Chef Server:

knife cookbook upload -a -o cookbooks

Upload roles to the Chef Server:

knife role from file roles/*.rb