Skip to content

Instantly share code, notes, and snippets.

@m01

m01/script.sh Secret

Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m01/674153f2da5272bc10c3 to your computer and use it in GitHub Desktop.
Save m01/674153f2da5272bc10c3 to your computer and use it in GitHub Desktop.
Django webapp chef repo setup copy/paste cheatsheet
# copy/paste cheatsheet for setting up a chef repo for deploying a Django webapp
# prerequisites: git config user.name, user.email done
sudo apt-get update && sudo apt-get install git
export EDITOR=sensible-editor
git config --global user.name "ubuntu"
git config --global user.email "ubuntu@example.com"
# create chef repo from scratch
cd ~
git clone git://github.com/opscode/chef-repo.git
cd chef-repo
# avoid accidents
git remote rm origin
# install dependency cookbooks
cd cookbooks
knife cookbook site install -z application_python
knife cookbook site install -z application_nginx
knife cookbook site install -z application 3.0.0
knife cookbook site install -z database
# Add django_tutorial cookbook, or create your own
git clone https://github.com/m01/chef-django_tutorial django_tutorial
# done with cookbooks.
cd ..
# create role for application server
knife role create -z django_tutorial_application_server
# add to run_list:
"recipe[django_tutorial]"
# run on the current node
sudo chef-client --local-mode -o "role[django_tutorial_application_server]"
# -- deploying on a new node --
# use 'echo PASSWORD | sudo -S' to get around sudo password prompt.
# 1. install chef
ssh $YOURDESTINY -- "echo $PASSWORD | sudo -S echo 'sudo ok' && curl -L https://www.opscode.com/chef/install.sh | sudo bash"
# 2. scp over a tarball with everything chef cares about
scp chef-repo.tar.gz $YOURDESTINY:
# 3. Extract tarball, cd into chef-repo and run the chef-client
ssh $YOURDESTINY -- "echo $PASSWORD | sudo -S echo "sudo ok" && tar xzf chef-repo.tar.gz && cd chef-repo && sudo chef-client --local-mode -o 'role[django_tutorial_application_server]'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment