forked from deanwilson/puppet-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpuppet-pkg
More file actions
executable file
·33 lines (29 loc) · 749 Bytes
/
puppet-pkg
File metadata and controls
executable file
·33 lines (29 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/ruby
require 'puppet'
# simple example of using a puppet type and providers
# to hide implementation details.
# This script isn't that robust.
pkg_action = ARGV.shift
pkg_name = ARGV.shift
# ppp = instance of the puppet package provider
ppp = Puppet::Type.type(:package).new(:name => pkg_name).provider
case pkg_action
when "remove", "delete", "uninstall"
ppp.purge
when "install"
ppp.install
when "update", "upgrade"
ppp.update
when "status"
if ppp.properties[:ensure] == :absent
puts "Failed to find #{pkg_name}"
else
puts pkg_name
ppp.properties.each_pair do |k,v|
puts " - #{k} => #{v}"
end
end
else
puts "Don't know how to '#{pkg_action}'"
exit 1
end