Created
October 14, 2011 20:00
-
-
Save trentonstrong/1288140 to your computer and use it in GitHub Desktop.
Best thing anyone ever built
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'chef/knife' | |
require 'net/ssh' | |
require 'net/ssh/multi' | |
require 'readline' | |
SYMFONY_BIN = "/home/ubuntu/ichange.com/skylight/symfony" | |
def send_ssh(node, command) | |
knife_ssh = Chef::Knife::Ssh.new | |
knife_ssh.config[:identity_file] = "~/ichangekey.pem" | |
knife_ssh.config[:attribute] = "ec2.public_hostname" | |
knife_ssh.config[:ssh_user] = "ubuntu" | |
query = "name:#{node.name}" | |
knife_ssh.name_args = [query, command] | |
knife_ssh.run | |
end | |
search(:node, 'roles:webserver AND chef_environment:staging') do |ws| | |
puts "Updating #{ws.name}" | |
knife_ssh = Chef::Knife::Ssh.new | |
send_ssh(ws, "#{SYMFONY_BIN} project:disable frontend prod") | |
send_ssh(ws, "sudo chef-client") | |
send_ssh(ws, "#{SYMFONY_BIN} project:enable frontend prod") | |
end | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment