Skip to content

Instantly share code, notes, and snippets.

@kudosqujo
Created November 30, 2020 01:58
Show Gist options
  • Save kudosqujo/dce42d10a9d3a50428c6ef9611d4d207 to your computer and use it in GitHub Desktop.
Save kudosqujo/dce42d10a9d3a50428c6ef9611d4d207 to your computer and use it in GitHub Desktop.
[Chef CLI] #chef #cheatsheet #vagrant
sudo chef-client --local-mode --runlist 'recipe[chef-workstation]'
sudo chef-client --help
# /etc/chef/client.rb => manages the execution of the chef client run
emacs setup.rb

setup.rb

# checkout: docs.chef.io/resources.html

type 'name' do
  properties # like version
  actions # like :install, :create, etc.
end
### Step 1: Installation
brew cask install chefdk # install ChefDK
brew cask install virtualbox # install VirtualBox
brew cask install vagrant # install vagrant for spinning up a disposable environment for testing
brew cask install vagrant-manager
# verify installation
chef --version
vagrant --version
vboxmanage --version
### Step 2: Testing
cd . && mkdir chef && cd chef
vagrant box add bento/ubuntu-14.04 # install Ubuntu image
vagrant init bento/ubuntu-14.04 # initialize image
vagrant up # run image
vagrant ssh # ssh into running container
# addition vagrant commands
vagrant status # check status of the VM
vagrant suspend # suspend the VM
vagrant destroy # destroy VM (will need to re-provision things from the ground up
# and re-run all the installation cmds in order to setup the ChefDK again)
### Step 3: Inside Shell, install dependencies
sudo apt-get update # update utilities
sudo apt-get -y curl # install curl
curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk -c stable
# - `Berksfile`: file for managing chef dependencies and can be managed using the `berks` chef utility
# - note: might've been changes since the file no longer gets created by chef generator
# run ruby inside chef
chef exec irb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment