Skip to content

Instantly share code, notes, and snippets.

@amowu
Last active August 29, 2015 14:00
Show Gist options
  • Save amowu/11394010 to your computer and use it in GitHub Desktop.
Save amowu/11394010 to your computer and use it in GitHub Desktop.
How to use Chef Solo.
$ gem i chef --no-ri --no-rdoc

$ knife configure

$ gem i knife-solo --no-ri --no-rdoc

$ knife solo init chef-repo
$ tree chef-repo/
chef-repo/
├── cookbooks
├── data_bags
├── nodes
├── roles
├── site-cookbooks
└── solo.rb

$ cd chef-repo
$ git init
$ git add .
$ git commit -m 'first commit'

$ vim ~/.chef/knife.rb
client_key  '/Users/tsuchikazu/.chef/username.pem' #この行追加

$ knife cookbook site vendor yum -o cookbooks/

$ gem i berkshelf --no-ri --no-rdoc
$ vim Berksfile

# 以下の3行を書いて保存
site :opscode
cookbook 'yum'
cookbook 'nginx'

$ berks install --path cookbooks

$ knife solo prepare -i ~/KEY.pem  ec2-user@xxx.xxx.compute.amazonaws.com

$ vim nodes/xxx.xxx.compute.amazonaws.com.json

# 実行したいcookbookを指定する。
{
  "run_list":[
    "yum::epel", 
    "nginx", 
    "base"
  ]
}

$ knife solo cook -i ~/KEY.pem ec2-user@xxx.xxx.compute.amazonaws.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment