Skip to content

Instantly share code, notes, and snippets.

@iafonov
Created February 6, 2012 15:48
Show Gist options
  • Save iafonov/1752785 to your computer and use it in GitHub Desktop.
Save iafonov/1752785 to your computer and use it in GitHub Desktop.
Depoyer
require 'script/util/ssh_wrapper.rb'
class Deployer
def initialize(query_str)
query = Chef::Search::Query.new
@nodes = query.search(:node, query_str)[0]
@ssh = SshWrapper.new
@ssh.configure_session(@nodes)
end
def deploy
set_action_and_update_nodes('deploy')
end
def rollback
set_action_and_update_nodes('rollback')
end
private
def set_action_and_update_nodes(action)
@nodes.each do |node|
node.set['groupinator']["deploy_action"] = action
node.save
end
@ssh.ssh_command("sudo chef-client")
end
end
require 'script/util/deployer.rb'
abort("usage: knife exec script/deploy QUERY") unless ARGV[2]
Deployer.new(ARGV[2]).deploy
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment