Created
July 8, 2011 05:34
-
-
Save jeremyd/1071209 to your computer and use it in GitHub Desktop.
chef server bootstrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
puts `gem sources -a http://gems.opscode.com/` | |
puts `gem install chef` | |
solorb = <<EOF | |
file_cache_path "/tmp/chef-solo" | |
cookbook_path "/tmp/chef-solo/cookbooks" | |
recipe_url "http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz" | |
EOF | |
bootstrap = <<BOOT | |
{ | |
"bootstrap": { | |
"chef": { | |
"url_type": "http", | |
"init_style": "runit", | |
"path": "/srv/chef", | |
"serve_path": "/srv/chef", | |
"server_fqdn": "#{ENV['EC2_PUBLIC_HOSTNAME']}", | |
"webui_enabled": true | |
} | |
}, | |
"run_list": [ "recipe[bootstrap::server]" ] | |
} | |
BOOT | |
so="/root/solo.rb" | |
run="/root/chef.json" | |
File.open(so, "w") {|f| f.write(solorb)} | |
File.open(run, "w") {|f| f.write(bootstrap)} | |
orig_hosts = IO.read("/etc/hosts") | |
orig_hosts.gsub!(/127\.0\.0\.1 /, "127.0.0.1 #{ENV['EC2_PUBLIC_HOSTNAME']} ") | |
File.open("/etc/hosts", "w") {|f| f.write(orig_hosts)} | |
puts `chef-solo -c #{so} -j #{run}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment