Class: SSP::App::Chef

Inherits:
Thor
  • Object
show all
Defined in:
lib/ssp/application/chef.rb

Instance Method Summary collapse

Instance Method Details

#client(*nodes) ⇒ Object



20
21
22
23
24
# File 'lib/ssp/application/chef.rb', line 20

def client(*nodes)
  chef_config
  command = options[:ssh_user] == "root" ? "chef-client" : "sudo chef-client"
  ssh_run nodes.join(" "), command
end

#deploy(app) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ssp/application/chef.rb', line 29

def deploy(app)
  if options[:ssh_user] == "root"
    raise Thor::Error, "You cannot deploy directly with the root user, use the -u option to specify your user"
  end
  chef_config
  node = "#{options[:production] ? "#{app}-app-01" : "sage"}.sspti.me"
  command = "sudo chef-client -V -l debug -L /tmp/#{app}_deploy_chef_run.#{Time.now.strftime("%Y%m%d%H%M")}.log | grep --line-buffered '\\[[^]]*\\] [A-Z]*:' | grep -v DEBUG:"

  env = options[:production] ? "production" : "staging"
  deploy_action = options[:rollback] ? "rollback" : options[:force] ? "force_deploy" : "deploy"
  with_updated_bag(app, env, :deploy_action => deploy_action, :migrate => options[:migrate]) do
    ssh_run(node, command)
  end
end