Permalink
Browse files

Add a apt_update action and improve the yum one a bit

  • Loading branch information...
1 parent 78bf7ac commit 282d673de32b44986cf23482d970e05185bb147b @ripienaar ripienaar committed Sep 18, 2010
Showing with 26 additions and 5 deletions.
  1. +13 −0 agent/package/package.ddl
  2. +13 −5 agent/package/puppet-package.rb
View
@@ -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
@@ -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

0 comments on commit 282d673

Please sign in to comment.