Skip to content

Instantly share code, notes, and snippets.

@yuyalush
Last active December 16, 2015 05:09
Show Gist options
  • Save yuyalush/5382134 to your computer and use it in GitHub Desktop.
Save yuyalush/5382134 to your computer and use it in GitHub Desktop.
knife-soloを使わないでやってみた
execute "apt-get update" do
command "apt-get update"
ignore_failure true
end
%w[zsh git build-essential zlib1g-dev libssl-dev libreadline-dev libxml2-dev libxslt-dev libsqlite3-dev g++ sqlite3].each do |pkg|
package pkg do
action :install
end
end
script "install_ruby" do
interpreter "bash"
user "root"
cwd "/tmp"
code <<-EOH
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
tar -zxf ruby-2.0.0-p0.tar.gz
cd ruby-2.0.0-p0
./configure
make -j
make install
EOH
end
script "install_rails" do
interpreter "bash"
user "root"
cwd "/tmp"
code <<-EOH
echo "install: --no-ri --no-rdoc" > ~/.gemrc
echo "update: --no-ri --no-rdoc" > ~/.gemrc
gem i bundle
bundle init
echo 'gem "rails"' >> Gemfile
bundle install
EOH
end
script "create_testapp_1" do
interpreter "bash"
user "root"
cwd "/tmp"
code <<-EOH
rails new testapp --skip-bundle
EOH
end
cookbook_file "/tmp/testapp/Gemfile" do
source "Gemfile"
end
script "create_testapp_2" do
interpreter "bash"
user "root"
cwd "/tmp"
code <<-EOH
cd testapp
bundle install
rails g scaffold Book title:string price:integer
rake db:migrate
bundle exec unicorn_rails -D
ufw allow 8080
EOH
end
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'unicorn'
log_level :info
log_location STDOUT
node_name 'root'
client_key '/root/.chef/root.pem'
validation_client_name 'chef-validator'
validation_key '/etc/chef/validation.pem'
chef_server_url 'http://ubuntu:4000'
syntax_check_cache_path '/root/.chef/syntax_check_cache'
{
"run_list" : ["recipe[pakue_base]"]
}
curl -L http://www.opscode.com/chef/install.sh | sudo bash
mkdir ~/.chef
curl -L https://gist.github.com/yuyalush/5382134/raw/87c33ded20eb4111071e057022ba63c255776b18/knife.rb >> ~/.chef/knife.rb
knife cookbook create pakue_base -o cookbooks
cd cookbooks/pakue_base
curl -L https://gist.github.com/yuyalush/5382134/raw/773712c8703602c93004f6f58a24b1d84dfca3fb/Gemfile >> files/default/Gemfile
curl -L https://gist.github.com/yuyalush/5382134/raw/95c25a454a94a5c0d451c849936251e29248cbb8/default.rb >> recipes/default.rb
curl -L https://gist.github.com/yuyalush/5382134/raw/64d2431cf7fa015cdb4c099f2e45e6491b7d4f12/localhost.js >> localhost.json
curl -L https://gist.github.com/yuyalush/5382134/raw/82e191ea599fed998d54116ab61a6c92b56eec88/solo.rb >> solo.rb
chef-solo -c solo.rb -j ./localhost.json
file_cache_path "/tmp/chef-solo"
cookbook_path ["/root/cookbooks"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment