Skip to content

Instantly share code, notes, and snippets.

@ytjohn
Created November 7, 2012 03:22
Show Gist options
  • Save ytjohn/4029404 to your computer and use it in GitHub Desktop.
Save ytjohn/4029404 to your computer and use it in GitHub Desktop.
chef notes

Chef Notes

Fast Start Guide

When doing an amazon node, the hostname is set to an approximation of the IP address. You can specify your node name in client.rb.

node_name "new-name"

If you happened to have already ran chef-client, you can not rename your client but you can delete and recreate it. Do this as early as possible.

knife client delete WRONGNAME
rm /etc/chef/client.pem
# edit ~/chef-repo/client-config/client.rb
# add: node_name NEWNAME
sudo cp ~/chef-repo/client-config/* /etc/chef
chef-client

I got that information from Paul Dowman. He also has a cookbook called "chefonraiils" with a hostname recipe to set your hostname the same as your node name. I don't want the whole rails funcationality, so time to modify and make my first cookbook (sort of)

cd ~
git clone git://github.com/pauldowman/chefonrails.git
cd chef-repo
knife cookbook create sethostname
cd cookbooks/sethostname
cp ~/chefonrails/cookbooks/chefonrails/templates/default/hosts.erb templates/default
cp ~/chefonrails/cookbooks/chefonrails/recipes/hostname.rb recipes/default.rb
cd ~/chef-repo
knife cookbook upload sethostname
knife node run_list add awsubuntu1 'recipe[sethostname]'
# test
sudo chef-client

You can install cookbooks from github directly: stackoverflow.

user's cookbook: http://community.opscode.com/cookbooks/users
note: only applies users in the "sysadmins" group

knife cookbook site install users
knife cookbook upload users
knife data bag create users
export EDITOR=/usr/bin/vim
openssl passwd -1 "password" # gives you the has to put in a password entry
knife data bag edit users ytjohn
knife node run_list add awsubuntu1 'recipe[users::sysadmins]'
sudo chef-client

My amazon instance doesn't have Omnibus ruby and therefore, can't manage the shadow password. This failed silently for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment