puppet 0.9.2 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (213) hide show
  1. data/CHANGELOG +58 -0
  2. data/README +21 -18
  3. data/Rakefile +176 -36
  4. data/bin/puppet +34 -48
  5. data/bin/puppetca +41 -28
  6. data/bin/puppetd +87 -65
  7. data/bin/puppetdoc +99 -23
  8. data/bin/puppetmasterd +72 -91
  9. data/conf/redhat/client.init +80 -0
  10. data/conf/redhat/client.sysconfig +11 -0
  11. data/conf/redhat/fileserver.conf +12 -0
  12. data/conf/redhat/puppet.spec +130 -0
  13. data/conf/redhat/server.init +89 -0
  14. data/conf/redhat/server.sysconfig +9 -0
  15. data/examples/code/allatonce +2 -2
  16. data/examples/code/assignments +1 -1
  17. data/examples/code/classing +2 -2
  18. data/examples/code/components +2 -2
  19. data/examples/code/file.bl +5 -5
  20. data/examples/code/filedefaults +2 -2
  21. data/examples/code/fileparsing +1 -1
  22. data/examples/code/filerecursion +1 -1
  23. data/examples/code/functions +1 -1
  24. data/examples/code/groups +1 -1
  25. data/examples/code/importing +1 -1
  26. data/examples/code/nodes +1 -1
  27. data/examples/code/one +1 -1
  28. data/examples/code/relationships +2 -2
  29. data/examples/code/simpletests +5 -5
  30. data/examples/code/snippets/argumentdefaults +2 -2
  31. data/examples/code/snippets/casestatement +16 -8
  32. data/examples/code/snippets/classheirarchy.pp +4 -4
  33. data/examples/code/snippets/classincludes.pp +4 -4
  34. data/examples/code/snippets/classpathtest +2 -2
  35. data/examples/code/snippets/componentmetaparams.pp +11 -0
  36. data/examples/code/snippets/dirchmod +5 -5
  37. data/examples/code/snippets/emptyclass.pp +9 -0
  38. data/examples/code/snippets/failmissingexecpath.pp +1 -1
  39. data/examples/code/snippets/falsevalues.pp +1 -1
  40. data/examples/code/snippets/filecreate +5 -5
  41. data/examples/code/snippets/implicititeration +5 -5
  42. data/examples/code/snippets/multipleinstances +4 -4
  43. data/examples/code/snippets/namevartest +3 -3
  44. data/examples/code/snippets/scopetest +1 -1
  45. data/examples/code/snippets/selectorvalues.pp +3 -3
  46. data/examples/code/snippets/simpledefaults +2 -2
  47. data/examples/code/snippets/simpleselector +5 -5
  48. data/examples/code/snippets/singleary.pp +19 -0
  49. data/examples/root/etc/init.d/sleeper +3 -2
  50. data/ext/emacs/puppet-mode-init.el +6 -0
  51. data/ext/emacs/puppet-mode.el +189 -0
  52. data/ext/ldap/puppet.schema +17 -0
  53. data/ext/{module:puppet → module_puppet} +30 -31
  54. data/ext/vim/filetype.vim +9 -0
  55. data/ext/vim/puppet.vim +87 -0
  56. data/install.rb +63 -30
  57. data/lib/puppet.rb +216 -122
  58. data/lib/puppet/client.rb +51 -416
  59. data/lib/puppet/client/ca.rb +17 -0
  60. data/lib/puppet/client/dipper.rb +78 -0
  61. data/lib/puppet/client/file.rb +20 -0
  62. data/lib/puppet/client/log.rb +17 -0
  63. data/lib/puppet/client/master.rb +246 -0
  64. data/lib/puppet/client/proxy.rb +27 -0
  65. data/lib/puppet/client/status.rb +7 -0
  66. data/lib/puppet/config.rb +563 -13
  67. data/lib/puppet/daemon.rb +50 -22
  68. data/lib/puppet/element.rb +4 -4
  69. data/lib/puppet/event-loop.rb +1 -0
  70. data/lib/puppet/event-loop/better-definers.rb +367 -0
  71. data/lib/puppet/event-loop/event-loop.rb +355 -0
  72. data/lib/puppet/event-loop/signal-system.rb +220 -0
  73. data/lib/puppet/event.rb +9 -11
  74. data/lib/puppet/filetype.rb +195 -0
  75. data/lib/puppet/log.rb +35 -12
  76. data/lib/puppet/metric.rb +2 -2
  77. data/lib/puppet/networkclient.rb +145 -0
  78. data/lib/puppet/parameter.rb +335 -0
  79. data/lib/puppet/parser/ast.rb +42 -1453
  80. data/lib/puppet/parser/ast/astarray.rb +88 -0
  81. data/lib/puppet/parser/ast/branch.rb +47 -0
  82. data/lib/puppet/parser/ast/caseopt.rb +66 -0
  83. data/lib/puppet/parser/ast/casestatement.rb +78 -0
  84. data/lib/puppet/parser/ast/classdef.rb +78 -0
  85. data/lib/puppet/parser/ast/compdef.rb +111 -0
  86. data/lib/puppet/parser/ast/component.rb +105 -0
  87. data/lib/puppet/parser/ast/hostclass.rb +82 -0
  88. data/lib/puppet/parser/ast/leaf.rb +86 -0
  89. data/lib/puppet/parser/ast/node.rb +103 -0
  90. data/lib/puppet/parser/ast/nodedef.rb +68 -0
  91. data/lib/puppet/parser/ast/objectdef.rb +336 -0
  92. data/lib/puppet/parser/ast/objectparam.rb +30 -0
  93. data/lib/puppet/parser/ast/objectref.rb +76 -0
  94. data/lib/puppet/parser/ast/selector.rb +60 -0
  95. data/lib/puppet/parser/ast/typedefaults.rb +45 -0
  96. data/lib/puppet/parser/ast/vardef.rb +44 -0
  97. data/lib/puppet/parser/interpreter.rb +31 -14
  98. data/lib/puppet/parser/lexer.rb +2 -4
  99. data/lib/puppet/parser/parser.rb +332 -242
  100. data/lib/puppet/parser/scope.rb +55 -38
  101. data/lib/puppet/server.rb +43 -44
  102. data/lib/puppet/server/authstore.rb +3 -6
  103. data/lib/puppet/server/ca.rb +5 -2
  104. data/lib/puppet/server/filebucket.rb +2 -4
  105. data/lib/puppet/server/fileserver.rb +28 -12
  106. data/lib/puppet/server/logger.rb +15 -4
  107. data/lib/puppet/server/master.rb +62 -7
  108. data/lib/puppet/sslcertificates.rb +41 -607
  109. data/lib/puppet/sslcertificates/ca.rb +291 -0
  110. data/lib/puppet/sslcertificates/certificate.rb +283 -0
  111. data/lib/puppet/statechange.rb +6 -1
  112. data/lib/puppet/storage.rb +67 -56
  113. data/lib/puppet/transaction.rb +25 -9
  114. data/lib/puppet/transportable.rb +102 -22
  115. data/lib/puppet/type.rb +1096 -315
  116. data/lib/puppet/type/component.rb +30 -21
  117. data/lib/puppet/type/cron.rb +409 -448
  118. data/lib/puppet/type/exec.rb +234 -174
  119. data/lib/puppet/type/group.rb +65 -82
  120. data/lib/puppet/type/nameservice.rb +247 -3
  121. data/lib/puppet/type/nameservice/netinfo.rb +29 -40
  122. data/lib/puppet/type/nameservice/objectadd.rb +52 -66
  123. data/lib/puppet/type/nameservice/posix.rb +6 -194
  124. data/lib/puppet/type/package.rb +447 -295
  125. data/lib/puppet/type/package/apt.rb +51 -50
  126. data/lib/puppet/type/package/bsd.rb +82 -0
  127. data/lib/puppet/type/package/dpkg.rb +85 -88
  128. data/lib/puppet/type/package/rpm.rb +67 -63
  129. data/lib/puppet/type/package/sun.rb +119 -98
  130. data/lib/puppet/type/package/yum.rb +41 -37
  131. data/lib/puppet/type/parsedtype.rb +295 -0
  132. data/lib/puppet/type/parsedtype/host.rb +143 -0
  133. data/lib/puppet/type/parsedtype/port.rb +232 -0
  134. data/lib/puppet/type/parsedtype/sshkey.rb +129 -0
  135. data/lib/puppet/type/pfile.rb +484 -460
  136. data/lib/puppet/type/pfile/checksum.rb +237 -181
  137. data/lib/puppet/type/pfile/content.rb +67 -0
  138. data/lib/puppet/type/pfile/ensure.rb +212 -0
  139. data/lib/puppet/type/pfile/group.rb +106 -105
  140. data/lib/puppet/type/pfile/mode.rb +98 -101
  141. data/lib/puppet/type/pfile/source.rb +228 -209
  142. data/lib/puppet/type/pfile/type.rb +18 -21
  143. data/lib/puppet/type/pfile/uid.rb +127 -130
  144. data/lib/puppet/type/pfilebucket.rb +68 -63
  145. data/lib/puppet/type/schedule.rb +341 -0
  146. data/lib/puppet/type/service.rb +351 -255
  147. data/lib/puppet/type/service/base.rb +9 -14
  148. data/lib/puppet/type/service/debian.rb +32 -38
  149. data/lib/puppet/type/service/init.rb +130 -130
  150. data/lib/puppet/type/service/smf.rb +48 -20
  151. data/lib/puppet/type/state.rb +229 -16
  152. data/lib/puppet/type/symlink.rb +51 -63
  153. data/lib/puppet/type/tidy.rb +105 -102
  154. data/lib/puppet/type/user.rb +118 -180
  155. data/lib/puppet/util.rb +100 -6
  156. data/test/certmgr/certmgr.rb +0 -1
  157. data/test/client/client.rb +4 -4
  158. data/test/executables/puppetbin.rb +7 -14
  159. data/test/executables/puppetca.rb +18 -24
  160. data/test/executables/puppetd.rb +7 -16
  161. data/test/executables/puppetmasterd.rb +7 -9
  162. data/test/executables/puppetmodule.rb +11 -16
  163. data/test/language/ast.rb +11 -7
  164. data/test/language/interpreter.rb +1 -1
  165. data/test/language/scope.rb +2 -0
  166. data/test/language/snippets.rb +30 -5
  167. data/test/language/transportable.rb +77 -0
  168. data/test/other/config.rb +316 -0
  169. data/test/other/events.rb +22 -21
  170. data/test/other/log.rb +14 -14
  171. data/test/other/metrics.rb +4 -8
  172. data/test/other/overrides.rb +5 -5
  173. data/test/other/relationships.rb +4 -2
  174. data/test/other/storage.rb +64 -3
  175. data/test/other/transactions.rb +20 -20
  176. data/test/parser/parser.rb +7 -4
  177. data/test/puppet/conffiles.rb +12 -12
  178. data/test/puppet/defaults.rb +13 -11
  179. data/test/puppet/utiltest.rb +14 -11
  180. data/test/puppettest.rb +156 -48
  181. data/test/server/bucket.rb +2 -2
  182. data/test/server/fileserver.rb +6 -6
  183. data/test/server/logger.rb +19 -11
  184. data/test/server/master.rb +33 -4
  185. data/test/server/server.rb +2 -7
  186. data/test/types/basic.rb +5 -7
  187. data/test/types/component.rb +22 -18
  188. data/test/types/cron.rb +111 -44
  189. data/test/types/exec.rb +116 -59
  190. data/test/types/file.rb +262 -137
  191. data/test/types/filebucket.rb +13 -15
  192. data/test/types/fileignoresource.rb +12 -16
  193. data/test/types/filesources.rb +73 -48
  194. data/test/types/filetype.rb +13 -15
  195. data/test/types/group.rb +15 -13
  196. data/test/types/host.rb +146 -0
  197. data/test/types/package.rb +74 -63
  198. data/test/types/port.rb +139 -0
  199. data/test/types/query.rb +8 -8
  200. data/test/types/schedule.rb +335 -0
  201. data/test/types/service.rb +137 -21
  202. data/test/types/sshkey.rb +140 -0
  203. data/test/types/symlink.rb +3 -5
  204. data/test/types/tidy.rb +5 -14
  205. data/test/types/type.rb +67 -11
  206. data/test/types/user.rb +25 -23
  207. metadata +186 -122
  208. data/lib/puppet/type/pfile/create.rb +0 -108
  209. data/lib/puppet/type/pprocess.rb +0 -97
  210. data/lib/puppet/type/typegen.rb +0 -149
  211. data/lib/puppet/type/typegen/filerecord.rb +0 -243
  212. data/lib/puppet/type/typegen/filetype.rb +0 -316
  213. data/test/other/state.rb +0 -106
@@ -1,17 +1,12 @@
1
- module Puppet
2
- module ServiceTypes
3
- module BaseSvc
4
-
5
- # The command used to start. Generated if the 'binary' argument
6
- # is passed.
7
- def startcmd
8
- if self[:binary]
9
- return self[:binary]
10
- else
11
- raise Puppet::Error,
12
- "Services must specify a start command or a binary"
13
- end
14
- end
1
+ Puppet.type(:service).newsvctype(:base) do
2
+ # The command used to start. Generated if the 'binary' argument
3
+ # is passed.
4
+ def startcmd
5
+ if self[:binary]
6
+ return self[:binary]
7
+ else
8
+ raise Puppet::Error,
9
+ "Services must specify a start command or a binary"
15
10
  end
16
11
  end
17
12
  end
@@ -2,49 +2,43 @@ require 'puppet/type/service/init'
2
2
 
3
3
  # Manage debian services. Start/stop is the same as InitSvc, but enable/disable
4
4
  # is special.
5
- module Puppet
6
- module ServiceTypes
7
- module DebianSvc
8
- include Puppet::ServiceTypes::InitSvc
9
-
10
- # Remove the symlinks
11
- def disable
12
- output = %x{update-rc.d -f #{self.name} remove 2>/dev/null}
5
+ Puppet.type(:service).newsvctype(:debian, :init) do
6
+ # Remove the symlinks
7
+ def disable
8
+ output = %x{update-rc.d -f #{self.name} remove 2>/dev/null}
13
9
 
14
- unless $? == 0
15
- raise Puppet::Error, "Could not disable %s: %s" %
16
- [self.name, output]
17
- end
18
- end
10
+ unless $? == 0
11
+ raise Puppet::Error, "Could not disable %s: %s" %
12
+ [self.name, output]
13
+ end
14
+ end
19
15
 
20
- def enabled?
21
- output = %x{update-rc.d -n -f #{self.name} remove 2>/dev/null}
22
- unless $? == 0
23
- raise Puppet::Error, "Could not check %s: %s" %
24
- [self.name, output]
25
- end
16
+ def enabled?
17
+ output = %x{update-rc.d -n -f #{self.name} remove 2>/dev/null}
18
+ unless $? == 0
19
+ raise Puppet::Error, "Could not check %s: %s" %
20
+ [self.name, output]
21
+ end
26
22
 
27
- # If it's enabled, then it will print output showing removal of
28
- # links.
29
- if output =~ /etc\/rc\d.d/
30
- return true
31
- else
32
- return false
33
- end
34
- end
23
+ # If it's enabled, then it will print output showing removal of
24
+ # links.
25
+ if output =~ /etc\/rc\d.d/
26
+ return true
27
+ else
28
+ return false
29
+ end
30
+ end
35
31
 
36
- def enable(runlevel)
37
- if runlevel
38
- raise Puppet::Error, "Specification of runlevels is not supported"
39
- else
40
- output = %x{update-rc.d #{self.name} defaults 2>/dev/null}
41
- end
32
+ def enable(runlevel)
33
+ if runlevel
34
+ raise Puppet::Error, "Specification of runlevels is not supported"
35
+ else
36
+ output = %x{update-rc.d #{self.name} defaults 2>/dev/null}
37
+ end
42
38
 
43
- unless $? == 0
44
- raise Puppet::Error, "Could not check %s: %s" %
45
- [self.name, output]
46
- end
47
- end
39
+ unless $? == 0
40
+ raise Puppet::Error, "Could not check %s: %s" %
41
+ [self.name, output]
48
42
  end
49
43
  end
50
44
  end
@@ -1,145 +1,145 @@
1
- module Puppet
2
- module ServiceTypes
3
- module InitSvc
4
- # Make sure we've got a search path set up. If they don't
5
- # specify one, try to determine one.
6
- def configchk
7
- unless defined? @searchpaths
8
- @searchpaths = []
9
- end
10
- unless @searchpaths.length > 0
11
- if init = self.defaultinit
12
- self.notice "Adding default init"
13
- @searchpaths << init
14
- else
15
- self.notice "No default init for %s" %
16
- Facter["operatingsystem"].value
17
-
18
- raise Puppet::Error.new(
19
- "You must specify a valid search path for service %s" %
20
- self.name
21
- )
22
- end
23
- end
24
- end
25
-
26
- # Get the default init path.
27
- def defaultinit
28
- unless defined? @defaultinit
29
- case Facter["operatingsystem"].value
30
- when "FreeBSD":
31
- @defaultinit = "/etc/rc.d"
32
- else
33
- @defaultinit = "/etc/init.d"
34
- @defaultrc = "/etc/rc%s.d"
35
- end
36
- end
37
-
38
- return @defaultinit
39
- end
40
-
41
- # Mark that our init script supports 'status' commands.
42
- def hasstatus=(value)
43
- case value
44
- when true, "true": @parameters[:hasstatus] = true
45
- when false, "false": @parameters[:hasstatus] = false
46
- else
47
- raise Puppet::Error, "Invalid 'hasstatus' value %s" %
48
- value.inspect
49
- end
50
- end
51
-
52
- # it'd be nice if i didn't throw the output away...
53
- # this command returns true if the exit code is 0, and returns
54
- # false otherwise
55
- def initcmd(cmd)
56
- script = self.initscript
1
+ # The standard init-based service type. Many other service types are
2
+ # customizations of this module.
3
+ Puppet.type(:service).newsvctype(:init) do
4
+
5
+ # Set the default init directory.
6
+ Puppet.type(:service).attrclass(:path).defaultto do
7
+ case Facter["operatingsystem"].value
8
+ when "FreeBSD":
9
+ "/etc/rc.d"
10
+ else
11
+ #@defaultrc = "/etc/rc%s.d"
12
+ "/etc/init.d"
13
+ end
14
+ end
15
+ # # Make sure we've got a search path set up. If they don't
16
+ # # specify one, try to determine one.
17
+ # def configchk
18
+ # unless defined? @searchpaths
19
+ # Puppet.notice "Initting search paths"
20
+ # @searchpaths = []
21
+ # end
22
+ # unless @searchpaths.length > 0
23
+ # if init = self.defaultinit
24
+ # self.notice "Adding default init"
25
+ # @searchpaths << init
26
+ # else
27
+ # self.notice "No default init for %s" %
28
+ # Facter["operatingsystem"].value
29
+ #
30
+ # raise Puppet::Error.new(
31
+ # "You must specify a valid search path for service %s" %
32
+ # self.name
33
+ # )
34
+ # end
35
+ # end
36
+ # end
37
+ #
38
+ # # Get the default init path.
39
+ # def defaultinit
40
+ # unless defined? @defaultinit
41
+ # case Facter["operatingsystem"].value
42
+ # when "FreeBSD":
43
+ # @defaultinit = "/etc/rc.d"
44
+ # else
45
+ # @defaultinit = "/etc/init.d"
46
+ # @defaultrc = "/etc/rc%s.d"
47
+ # end
48
+ # end
49
+ #
50
+ # return @defaultinit
51
+ # end
52
+
53
+ # Mark that our init script supports 'status' commands.
54
+ def hasstatus=(value)
55
+ case value
56
+ when true, "true": @parameters[:hasstatus] = true
57
+ when false, "false": @parameters[:hasstatus] = false
58
+ else
59
+ raise Puppet::Error, "Invalid 'hasstatus' value %s" %
60
+ value.inspect
61
+ end
62
+ end
57
63
 
58
- self.debug "Executing '%s %s' as initcmd for '%s'" %
59
- [script,cmd,self]
64
+ # it'd be nice if i didn't throw the output away...
65
+ # this command returns true if the exit code is 0, and returns
66
+ # false otherwise
67
+ def initcmd(cmd)
68
+ script = self.initscript
60
69
 
61
- rvalue = Kernel.system("%s %s" %
62
- [script,cmd])
70
+ self.debug "Executing '%s %s' as initcmd for '%s'" %
71
+ [script,cmd,self]
63
72
 
64
- self.debug "'%s' ran with exit status '%s'" %
65
- [cmd,rvalue]
73
+ rvalue = Kernel.system("%s %s" %
74
+ [script,cmd])
66
75
 
76
+ self.debug "'%s' ran with exit status '%s'" %
77
+ [cmd,rvalue]
67
78
 
68
- rvalue
69
- end
70
79
 
71
- # Where is our init script?
72
- def initscript
73
- if defined? @initscript
74
- return @initscript
75
- else
76
- @initscript = self.search(self.name)
77
- end
78
- end
80
+ rvalue
81
+ end
79
82
 
80
- # Store the search path for init scripts. This will generally not
81
- # be called.
82
- def parampath=(ary)
83
- unless ary.is_a?(Array)
84
- ary = [ary]
85
- end
86
- @parameters[:path] = ary
87
- @searchpaths = ary.find_all { |dir|
88
- File.directory?(dir)
89
- }
90
- end
83
+ # Where is our init script?
84
+ def initscript
85
+ if defined? @initscript
86
+ return @initscript
87
+ else
88
+ @initscript = self.search(self.name)
89
+ end
90
+ end
91
91
 
92
- # Enable a service, so it's started at boot time. This basically
93
- # just creates links in the RC directories, which means that, well,
94
- # we need to know where the rc directories are.
95
- # FIXME This should probably be a state or something, and
96
- # it should actually create use Symlink objects...
97
- # At this point, people should just link objects for enabling,
98
- # if they're running on a system that doesn't have a tool to
99
- # manage init script links.
100
- #def enable
101
- #end
102
-
103
- #def disable
104
- #end
105
-
106
- def search(name)
107
- @searchpaths.each { |path|
108
- fqname = File.join(path,name)
109
- begin
110
- stat = File.stat(fqname)
111
- rescue
112
- # should probably rescue specific errors...
113
- self.debug("Could not find %s in %s" % [name,path])
114
- next
115
- end
116
-
117
- # if we've gotten this far, we found a valid script
118
- return fqname
119
- }
120
- raise Puppet::Error, "Could not find init script for '%s'" % name
92
+ # Enable a service, so it's started at boot time. This basically
93
+ # just creates links in the RC directories, which means that, well,
94
+ # we need to know where the rc directories are.
95
+ # FIXME This should probably be a state or something, and
96
+ # it should actually create use Symlink objects...
97
+ # At this point, people should just link objects for enabling,
98
+ # if they're running on a system that doesn't have a tool to
99
+ # manage init script links.
100
+ #def enable
101
+ #end
102
+
103
+ #def disable
104
+ #end
105
+
106
+ def search(name)
107
+ self[:path].each { |path|
108
+ fqname = File.join(path,name)
109
+ begin
110
+ stat = File.stat(fqname)
111
+ rescue
112
+ # should probably rescue specific errors...
113
+ self.debug("Could not find %s in %s" % [name,path])
114
+ next
121
115
  end
122
116
 
123
- # The start command is just the init scriptwith 'start'.
124
- def startcmd
125
- self.initscript + " start"
126
- end
117
+ # if we've gotten this far, we found a valid script
118
+ return fqname
119
+ }
120
+ raise Puppet::Error, "Could not find init script for '%s'" % name
121
+ end
127
122
 
128
- # If it was specified that the init script has a 'status' command, then
129
- # we just return that; otherwise, we return false, which causes it to
130
- # fallback to other mechanisms.
131
- def statuscmd
132
- if self[:hasstatus]
133
- return self.initscript + " status"
134
- else
135
- return false
136
- end
137
- end
123
+ # The start command is just the init scriptwith 'start'.
124
+ def startcmd
125
+ self.initscript + " start"
126
+ end
138
127
 
139
- # The stop command is just the init script with 'stop'.
140
- def stopcmd
141
- self.initscript + " stop"
142
- end
128
+ # If it was specified that the init script has a 'status' command, then
129
+ # we just return that; otherwise, we return false, which causes it to
130
+ # fallback to other mechanisms.
131
+ def statuscmd
132
+ if self[:hasstatus]
133
+ return self.initscript + " status"
134
+ else
135
+ return false
143
136
  end
144
137
  end
138
+
139
+ # The stop command is just the init script with 'stop'.
140
+ def stopcmd
141
+ self.initscript + " stop"
142
+ end
145
143
  end
144
+
145
+ # $Id: init.rb 796 2006-01-10 14:38:39Z luke $
@@ -1,29 +1,57 @@
1
- module Puppet
2
- module ServiceTypes
3
- module SMFSvc
4
- def restartcmd
5
- end
1
+ # Solaris 10 SMF-style services. This is not yet implemented, which is probably
2
+ # somewhat obvious.
3
+ Puppet.type(:service).newsvctype(:smf) do
4
+ def restartcmd
5
+ "svcadm restart %s" % self.name
6
+ end
6
7
 
7
- # The start command is just the init scriptwith 'start'.
8
- def startcmd
9
- self.initscript + " start"
10
- end
8
+ def startcmd
9
+ "svcadm enable %s" % self.name
10
+ end
11
11
 
12
- # If it was specified that the init script has a 'status' command, then
13
- # we just return that; otherwise, we return false, which causes it to
14
- # fallback to other mechanisms.
15
- def statuscmd
16
- if self[:hasstatus]
17
- return self.initscript + " status"
12
+ def status
13
+ if self[:status]
14
+ super
15
+ return
16
+ end
17
+ %x{/usr/bin/svcs -l #{self.name} 2>/dev/null}.split("\n").each { |line|
18
+ var = nil
19
+ value = nil
20
+ if line =~ /^(\w+)\s+(.+)/
21
+ var = $1
22
+ value = $2
23
+ else
24
+ Puppet.err "Could not match %s" % line.inspect
25
+ end
26
+ case var
27
+ when "state":
28
+ case value
29
+ when "online":
30
+ #self.warning "matched running %s" % line.inspect
31
+ return :running
32
+ when "offline", "disabled":
33
+ #self.warning "matched stopped %s" % line.inspect
34
+ return :stopped
35
+ when "legacy_run":
36
+ raise Puppet::Error,
37
+ "Cannot manage legacy services through SMF"
18
38
  else
19
- return false
39
+ raise Puppet::Error,
40
+ "Unmanageable state %s on service %s" %
41
+ [value, self.name]
20
42
  end
21
43
  end
44
+ }
22
45
 
23
- # The stop command is just the init script with 'stop'.
24
- def stopcmd
25
- self.initscript + " stop"
26
- end
46
+ if $? != 0
47
+ raise Puppet::Error,
48
+ "Could not get status on service %s" % self.name
27
49
  end
28
50
  end
51
+
52
+ def stopcmd
53
+ "svcadm disable %s" % self.name
54
+ end
29
55
  end
56
+
57
+ # $Id: smf.rb 809 2006-01-12 07:08:19Z luke $