Skip to content

Instantly share code, notes, and snippets.

@phwelo
Created April 26, 2018 07:50
Show Gist options
  • Save phwelo/8be564fc6d5aa3b12560b70df381a2e9 to your computer and use it in GitHub Desktop.
Save phwelo/8be564fc6d5aa3b12560b70df381a2e9 to your computer and use it in GitHub Desktop.
Workstation Bootstrap
#!/bin/bash -xev
# Do some package manager pre-work
sudo apt update
sudo apt upgrade -y
# Do some chef pre-work
/bin/mkdir -p /etc/chef
/bin/mkdir -p /var/lib/chef
/bin/mkdir -p /var/log/chef
/bin/mkdir -p ~/.chef
cd /etc/chef/
# Install chef
curl -L https://omnitruck.chef.io/install.sh | bash || error_exit 'could not install chef'
sudo apt install berkshelf -y
NODE_NAME=node-$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 4 | head -n 1)
# Clone down cookbooks
sudo apt install git -y
git config --global user.email "[email protected]"
git config --global user.name "Daniel Agans"
# This is going to go interactive, would like to fix that
git clone https://github.com/phwelo/ws_bs.git ~/chef/cookbooks
# Create client.rb
/bin/echo 'log_location STDOUT' >> /etc/chef/client.rb
/bin/echo -e "node_name \"${NODE_NAME}\"" >> /etc/chef/client.rb
/bin/echo -e "local_mode true" >> /etc/chef/client.rb
/bin/echo -e "chef_zero.enabled true" >> /etc/chef/client.rb
/bin/echo -e "chef_repo_path \"~/chef\"" >> /etc/chef/client.rb
/bin/echo -e "add_formatter \"nyan-cat\"" >> /etc/chef/client.rb
/bin/echo -e "cookbook_path \"~/chef/cookbooks\"" >> /etc/chef/client.rb
# Create knife.rb
/bin/echo 'chef_zero.enabled true' >> ~/.chef/knife.rb
/bin/echo -e "cookbook_path [" >> ~/.chef/knife.rb
/bin/echo -e "'~/chef/cookbooks'" >> ~/.chef/knife.rb
/bin/echo -e "]" >> ~/.chef/knife.rb
/bin/echo -e "local_mode true" >> ~/.chef/knife.rb
# run the thing
sudo chef-client -z -o 'recipe[dagans-ws::default]'%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment