http://docs.chef.io/server/install_server.html#standalone does not mention how to configure knife.rb which is described on https://docs.chef.io/config_rb_knife.html . There is a outstanding difference of knife.rb for Chef Server 11 and 12:

In Chef Server 11:  chef_server_url 'http://localhost:4000/
In Chef Server 12:  chef_server_url 'http://localhost:4000/organizations/ORG_NAME

And the admin user in Chef Server 12 is named pivotal.  You only need to create a new user and a new ORG owned by this new user.

Here is a full install guide https://www.digitalocean.com/community/tutorials/how-to-set-up-a-chef-12-configuration-management-system-on-ubuntu-14-04-servers

Known issue : https://github.com/chef/chef-server/issues/50 Impossible to upload cookbooks if non-standard port is used

find then xargs

I like the find + xargs combinaiton so much.

On Mac OS X:

1. sed in several files:

find . -name filename-regex | xargs -I {} sed -i ” ‘s|abc|xyz|’ {}

2. remove several files:

find . -name filename-regex | xargs -I {} rm -rf {}

The VMware vSphere Big Data Extension product (aka Project Serengeti) needs to ensure the bootstrap order when deploying a hadoop cluster in which the slave nodes must wait for the master node.  BDE uses the native Chef way to implement it.

For example, hadoop datanode service should be started only after hadoop namenode service is started. In the chef recipe, we use this code to do this wait:

in namenode recipe github.com/vmwa…amenode.rb#L127 :

service ‘hadoop-namenode’ do

 action [:start]




in datanode recipe github.com/vmwa…datanode.rb#L29 :


service ‘hadoop-datanode’ do

 action [:start]


provide_service and wait_for_service are functions defined in the chef cookbook cluster_server_discovery.

The elastic_search and etcd or other service discovery solution can also be used in Chef cookbook.

sed -n ‘s/^.*\(<regex_pattern>\).*$/\1/p’ filename

This sed means substitute the whole line with the ‘\1’ (i.e. the matched pattern) and print the line. So it will print the text (not the whole line) which matches <regex_pattern>.

Googled 1 more hours to figure it out…

e.g.   sed -i ‘N; s/line1\n  line2/line1/’ /path/to/file

“N;” means multiline sed and “\n” means a NEW_LINE_CHAR

More example on http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-multi-line-file-operation-with-6-practical-examples/

SSH login without password (ref: http://t.cn/zOJ0itN)


1) ssh-keygen -t rsa (don’t set passphrase to avoid input passphrase everytime; also you can use keychain tool to automatically input passphrase)

2) create a file /usr/bin/myssh with mode 755 and content “cat ~/.ssh/id_rsa.pub | ssh $1 ‘mkdir -p ~/.ssh ; chmod 700 ~/.ssh; cat >> ~/.ssh/authorized_keys; chmod 640 ~/.ssh/authorized_keys’ ; ssh $1 “

3) myssh user@remotehost

Typical Usage of Git

# get the sources for the first time
git clone git_repo_url

# check out branch
git checkout master ( or your own branch)

# write code
git commit -a -m “try best to make your comments meaningful”

# pull latest changes to avoid massup due to auto merge
git pull –rebase

# Post code review to the reviewboard
post-review –guess-summary –guess-description
post-review –guess-summary –guess-description –revision-range HEAD~3:HEAD

# If code change needed per review comments

## if only commit message change needed
git commit –amend

## if both code and commit message change needed
git reset –soft HEAD~1
modify code
git add /path/to/new_modified_files
git commit -c ORIG_HEAD

# Post another review based on the previous one
post-review -r the_previous_review_num

# Ready to push
git pull –rebase (merge with changes made by others)
git push