Class: Gaptool::DeployCommand

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/gaptool-client.rb

Instance Method Summary collapse

Instance Method Details

#execute ⇒ Object



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/gaptool-client.rb', line 255

def execute
  attrs = split_attrs(attribute_list)
  if instance
    nodes = [$api.getonenode(instance)]
  else
    nodes = $api.getappnodes(app, environment)
  end
  nodes.peach do |node|
    json = {
      'this_server' => "#{node['role']}-#{environment}-#{node['instance']}",
      'role' => node['role'],
      'environment' => environment,
      'app_user' => node['appuser'],
      'run_list' => [ "recipe[deploy]" ],
      'hostname' => node['hostname'],
      'instance' => node['instance'],
      'zone' => node['zone'],
      'itype' => node['itype'],
      'apps' => eval(node['apps']),
      'app_name' => app,
      'app' => app,
      'rollback' => rollback?,
      'branch' => branch || 'master',
      'migrate' => migrate?
    }.merge(attrs).to_json
    commands = [
      "cd ~admin/ops; git pull",
      "echo '#{json}' > ~admin/solo.json",
      "sudo chef-solo -c ~admin/ops/cookbooks/solo.rb -j ~admin/solo.json"
    ]
    sshcmd(node, commands)
  end
end