Last active
August 29, 2015 14:02
-
-
Save jpadams/8e9fa4c6134a990dabad to your computer and use it in GitHub Desktop.
Stageit
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
1) Put these files on the master and the staging server which has PE installed (2 files on 2 servers) | |
2) `service pe-mcollective restart` on the master and staging server | |
3) try it! mco rpc stageit run manifest="ZmlsZSB7ICcvdG1wL2Zvbyc6CiAgZW5zdXJlID0+IGRpcmVjdG9yeSwKfQoK" -I centos65a | |
# /opt/puppet/libexec/mcollective/mcollective/agent/stageit.rb on Linux | |
module MCollective | |
module Agent | |
class Stageit<RPC::Agent | |
activate_when do | |
Facts["kernel"] != "windows" | |
end | |
action "run" do | |
require 'tempfile' | |
file = Tempfile.new('stageit') | |
path = file.path | |
file.close | |
command = "/opt/puppet/bin/puppet apply #{path} --detailed-exitcodes" | |
create_manifest = "echo " + request[:manifest] + " | base64 -d > " + path | |
`#{create_manifest}` | |
reply[:status] = run(command,:stdout => :out, :stderr => :err, :chomp => true) | |
file.unlink | |
reply | |
end | |
end | |
end | |
end | |
# /opt/puppet/libexec/mcollective/mcollective/agent/stageit.ddl | |
metadata :name => 'stageit', | |
:description => 'Runs puppet apply on a Base64 encoded manifest on Linux agents', | |
:author => 'jeremy@puppetlabs.com', | |
:license => 'Apache v2 - No warranty', | |
:version => '1.0', | |
:url => 'http://www.puppetlabs.com', | |
:timeout => 15 | |
action "run", :description => 'Runs puppet apply on a Base64 encoded manifest on Linux agents' do | |
display :always | |
input :manifest, | |
:prompt => "manifest", | |
:description => "base64 of a puppet manifest", | |
:type => :string, | |
:validation => :shellsafe, | |
:optional => false, | |
:maxlength => 900 | |
output :status, | |
:description => "The exit code of the script", | |
:display_as => "Return Value" | |
output :out, | |
:description => "The output of the script on stdout", | |
:display_as => "Output Channel" | |
output :err, | |
:description => "The output of the script on stderr", | |
:display_as => "Error Channel" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment