Skip to content

Instantly share code, notes, and snippets.

@cbednarski
Last active December 18, 2015 09:19
Show Gist options
  • Save cbednarski/5760927 to your computer and use it in GitHub Desktop.
Save cbednarski/5760927 to your computer and use it in GitHub Desktop.
Knife bootstrap shell wrapper
#!/bin/bash
set -x
if [ $# == 2 ]; then
echo ">>> Cleaning up existing chef environment"
knife node delete -y $2
knife client delete -y $2
ssh -l root $2 'yum remove -y chef'
ssh -l root $2 'rm -rf /etc/chef'
ssh -l root $2 'rm -rf /opt/chef'
echo ">>> Bootstrapping $1 $2"
knife bootstrap -E $1 -x root $2 -N $2
knife node run_list add $2 "recipe[mysql],recipe[memcache]"
scp ~/.chef/encrypted_data_bag_secret root@$2:/etc/chef/
echo ">>> Running Chef Client"
ssh -l root $2 'chef-client'
exit 0
else
echo "wrong number of parameters"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment