lib/gaptool-client.rb in gaptool-client-0.6.1 vs lib/gaptool-client.rb in gaptool-client-0.6.2
- old
+ new
@@ -208,10 +208,11 @@
class ChefrunCommand < Clamp::Command
option ["-r", "--role"], "ROLE", "Role name to ssh to", :required => true
option ["-e", "--environment"], "ENVIRONMENT", "Which environment, e.g. production", :required => true
option ["-i", "--instance"], "INSTANCE", "Instance ID, e.g. i-12345678", :required => false
option ["-A", "--attribute"], "ATTRIBUTE", "Pass one or more parameters to the deploy recipe in recipe.attr=value format", :multivalued => true
+ option ["-b", "--chef-branch"], "BRANCH", "branch of the chef repository to use (defaults to master)", :default => 'master'
def execute
attrs = split_attrs(attribute_list)
if !instance.nil?
nodes = [$api.getonenode(instance)]
@@ -227,13 +228,14 @@
'run_list' => [ "recipe[main]" ],
'hostname' => node['hostname'],
'instance' => node['instance'],
'zone' => node['zone'],
'itype' => node['itype'],
- 'apps' => eval(node['apps'])
+ 'apps' => eval(node['apps']),
+ 'chefbranch' => chef_branch
}.merge(attrs).to_json
commands = [
- "cd ~admin/ops; git pull",
+ "cd ~admin/ops; git checkout -f #{chef_branch}; git fetch --all; git reset --hard origin/#{chef_branch}",
"echo '#{json}' > ~admin/solo.json",
"sudo chef-solo -c ~admin/ops/cookbooks/solo.rb -j ~admin/solo.json"
]
sshcmd(node, commands)
end