






















Posted by on September 19, 2012
Opscode Chef is a powerful tool for automating the configuration of new servers, and indeed, entire clouds, multi-server architectures etc. We now use it to deploy MyTardis. It’s quite daunting at first, so here’s a quick guide to the setup I use. You’ll probably need to refer to more complete tutorials to cover gaps (eg OpsCode’s Fast Start Guide, the MyTardis chef documentation and this random other one.) We’ll use installing MyTardis as the goal.
cd ~/mytardis git clone https://github.com/mytardis/mytardis-chef
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name "stevage"
client_key "#{current_dir}/stevage.pem"
validation_client_name "versi-validator"
validation_key "#{current_dir}/versi-validator.pem"
chef_server_url "https://api.opscode.com/organizations/versi"
cache_type 'BasicFile'
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
cookbook_path ["#{current_dir}/../mytardis/mytardis-chef/site-cookbooks", "#{current_dir}/../mytardis/mytardis-chef/cookbooks"]
knife cookbook upload -a knife role from file ../mytardis/mytardis-chef/roles/mytardis.json
#!/bin/bash -x # Bootstraps Chef on the remote host, then runs its runlist. source ./settings$1.sh knife bootstrap $CHEF_IP -x $CHEF_ACCOUNT --no-host-key-verify -i nectar.pem --sudo $CHEF_BOOTSTRAP_ARGS
update.sh:
#!/bin/bash -x # Runs Chef-client on the remote host, to run the latest version of any applicable cookbooks. source settingsi$1.sh knife ssh name:$NECTAR_HOST -a ipaddress -x $NECTAR_ACCOUNT -i nectar.pem -o "VerifyHostKeyDNS no" "sudo chef-client"
connect.sh:
#!/bin/bash -x # Opens an SSH session to the remote host. source ./settings$1.sh ssh $CHEF_ACCOUNT@$CHEF_IP -i nectar.pem -o "VerifyHostKeyDNS no"
(We disable host key checking because otherwise SSH baulks every time you allocate a new VM with an IP that it’s seen before.)With these, you can have several “settings…sh” files, each one describing a different remote host. (Or just a single settings.sh). So, create a “settings-mytardisdemo.sh” file, like this:
# Settings for Ubuntu Precise NeCTAR VM running mytardis as a demo export CHEF_HOST=mytardisdemo export CHEF_IP=115.146.94.53 export CHEF_ACCOUNT=ubuntu export CHEF_BOOTSTRAP_ARGS="-d ubuntu12.04-gems -r 'role[mytardis]'"
./bootstrap.sh -mytardisdemo
If all goes well (it won’t), that will churn away for 40 minutes or so, then MyTardis will be up and running.
./update.sh -mytardisdemo
./connect.sh -mytardisdemo
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。