Skip to content

Instantly share code, notes, and snippets.

@jpadams
Created July 29, 2014 12:48
Show Gist options
  • Save jpadams/a41f034435f6972fb1b0 to your computer and use it in GitHub Desktop.
Save jpadams/a41f034435f6972fb1b0 to your computer and use it in GitHub Desktop.
#!/opt/puppet/bin/ruby
require 'yaml'
require 'base64'
runlist = YAML.load_file(ARGV[0])
runlist.each do |manifest, node|
text = File.read(manifest)
encoded = Base64.strict_encode64(text)
puts "applying #{manifest} on #{node}"
command = "/bin/su - peadmin -c \'mco rpc stageit run manifest=\"#{encoded}\" -I #{node}\'"
result = %x(#{command})
if /Return Value: 1/ =~ result
print result
exit
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment