Skip to content

Instantly share code, notes, and snippets.

@simonmorley
Last active December 21, 2015 08:59
Show Gist options
  • Save simonmorley/6281738 to your computer and use it in GitHub Desktop.
Save simonmorley/6281738 to your computer and use it in GitHub Desktop.
My Chef shortcuts and command reminders
** Node Operations **
knife node list
knife node delete name_of_server
knife node bulk delete name_of_server
knife node run_list add name_of_server 'recipe[nginx]'
knife node run_list remove name_of_server 'role[iptables]'
** Deploy **
knife ssh 'name:name_of_server*' 'sudo chef-client' -i private.pem -x ubuntu
knife ssh 'role:role_of_server*' 'sudo chef-client' -i private.pem -x ubuntu
** Cookbooks **
knife cookbook upload -a
knife cookbook upload iptables
knife cookbook bulk delete freeradius
knife cookbook site install nodejs
** Roles **
knife role from file roles/webserver.rb
** Knife EC2 create server **
knife ec2 server create -G default -I ami-3d160149 -f t1.micro \
-S name_of_key -i private.pem -x ubuntu -d ubuntu10.04-gems-qs \
-r 'role[webserver],role[iptables]' \
--region eu-west-1
** Knife EC2 bootstrap **
knife bootstrap ec2-79-125-70-51.eu-west-1.compute.amazonaws.com \
--ssh-user ubuntu \
-i private.pem \
--ssh-port 22 \
-r 'role[webserver]' \
--sudo \
--node-name "radius_1"
** Create VPC Instance **
knife ec2 server create \
-g sg-xxxf \
-s subnet-xxx \
-I ami-xxx -f m1.small \
-i private.pem \
-x ubuntu \
--server-connect-attribute private_ip_address \
--ssh-gateway [email protected] \
-S sec_group \
-r 'role[load_balancer]' \
--region eu-west-1 \
-E production
** Run chef on remote VPC **
knife ssh 'role:elastic*' 'sudo chef-client' -G [email protected] -x ubuntu -i private.pem --attribute ipaddress
** Knife Server Start Stop **
knife ec2 server start -i instance-id,instance-id -t tag=pattern*,tag=value
knife ec2 server stop -i instance-id,instance-id -t tag=pattern*,tag=value
** SSH Problems **
WARNING: Failed to connect to -- Net::SSH::Disconnect: connection closed by remote host
Generally fixed with:
ss-add private_key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment