Skip to content

Instantly share code, notes, and snippets.

@ccaum
Created August 19, 2011 21:57
Show Gist options
  • Save ccaum/1158123 to your computer and use it in GitHub Desktop.
Save ccaum/1158123 to your computer and use it in GitHub Desktop.
Git Post Merge Script
#!/usr/bin/env ruby
require 'rubygems'
require 'puppet'
require 'puppet/face'
require 'puppet/cloudpack'
options = {
:image => 'ami-3d76b754',
:type => 'm1.large',
:region => 'us-east-1',
:keypair => 'ccaum_rsa',
:keyfile => '/root/.ec2/ccaum_rsa.pem',
:login => 'ec2-user'
}
#Fire up instance from AMI
=begin
server = Puppet::Face[:node, '0.0.1'].create :image => options[:image],
:type => options[:type],
:region => options[:region],
:keypair => options[:keypair]
Puppet::Face[:certificate, '0.0.1'].sign(certname)
=end
server = 'ec2-107-20-67-187.compute-1.amazonaws.com'
#Run Puppet on Instance
command = String.new
unless options[:login] == 'root'
command << '/usr/bin/sudo '
end
command << 'mkdir /tmp/testme'
exit_code = Puppet::CloudPack.ssh_remote_execute(server, options[:login], command, options[:keyfile])
raise "Failed to run puppet on instance #{server}" unless exit_code == 0
puts "Successfully ran puppet on instance #{server}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment