git clone http://github.com/wongyouth/chefrails.git
cd chefrails
bundle install
cp data_bags/users/deploy.json.example data_bags/users/deploy.json
# Create your own password for deploy user. I use `deploy` as password in the deploy.json.example.
openssh password -1 "your password"
# open file below to paste created password, ssh_keys
vi data_bags/users/deploy.json
knife solo bootstrap root@your_server
It will take a couple minutes, have a cup of tea and Enjoy!
It's no different between vagrant server or not. The Vagrantfile file is just a basic setup which use precise64 as server. What we need to do with Vagrant is to setup a login username and server info.
Install Vagrant
gem install vagrant
vagrant up
vagrant ssh-config --host chefrails >> ~/.ssh/config
knife solo bootstrap vagrant@chefrails
- Exit with error message: DEBUG: chef_gem[treetop] no installed version found for treetop (>= 1.4)
That because Chef cannot get gem treetop
installed from https://rubygems.org in China.
Workaround is to change gem sources to taobao mirror.
/opt/chef/embedded/bin/gem sources --remove https://rubygems.org/ /opt/chef/embedded/bin/gem sources --add http://ruby.taobao.org/
apt-get update
caused a lot of time to complete.
Change to a mirror in China.
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak sudo sed -e 's/us.archive/cn.archive/' -i /etc/apt/sources.list
- Server hanging while install chef
It's difficult to install chef within China. You can download chef client from chef.io and install directly on your server.
If you use Ubuntu, you can download a debian version of chef client. and install it by
dpkg -i chef_12.4.0-1_amd64.deb