Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a apt_update action and improve the yum one a bit

  • Loading branch information...
commit 282d673de32b44986cf23482d970e05185bb147b 1 parent 78bf7ac
@ripienaar ripienaar authored
Showing with 26 additions and 5 deletions.
  1. +13 −0 agent/package/package.ddl
  2. +13 −5 agent/package/puppet-package.rb
View
13 agent/package/package.ddl
@@ -51,4 +51,17 @@ action "yum_clean", :description => "Clean the YUM cache" do
:description => "Output from YUM",
:display_as => "Output"
+ output :exitcode,
+ :description => "The exitcode from the yum command",
+ :display_as => "Exit Code"
+end
+
+action "apt_update", :description => "Updated the apt cache" do
+ output :output,
+ :description => "Output from apt-get",
+ :display_as => "Output"
+
+ output :exitcode,
+ :description => "The exitcode from the apt-get command",
+ :display_as => "Exit Code"
end
View
18 agent/package/puppet-package.rb
@@ -22,11 +22,19 @@ class Package<RPC::Agent
end
action "yum_clean" do
- if File.exist?("/usr/bin/yum")
- reply[:output] = %x[/usr/bin/yum clean all]
- else
- reply.fail "Cannot find yum at /usr/bin/yum"
- end
+ reply.fail! "Cannot find yum at /usr/bin/yum" unless File.exist?("/usr/bin/yum")
+ reply[:output] = %x[/usr/bin/yum clean all]
+ reply[:exitcode] = $?.exitstatus
+
+ reply.fail! "Yum clean failed, exit code was #{reply[:exitcode]}" unless reply[:exitcode] == 0
+ end
+
+ action "apt_update" do
+ reply.fail! "Cannot find apt-get at /usr/bin/apt-get" unless File.exist?("/usr/bin/apt-get")
+ reply[:output] = %x[/usr/bin/apt-get update]
+ reply[:exitcode] = $?.exitstatus
+
+ reply.fail! "apt-get update failed, exit code was #{reply[:exitcode]}" unless reply[:exitcode] == 0
end
private
Please sign in to comment.
Something went wrong with that request. Please try again.