puppet 2.7.11 → 2.7.12

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 (220) hide show
  1. data/CHANGELOG +188 -0
  2. data/conf/osx/createpackage.sh +1 -0
  3. data/conf/redhat/puppet.spec +12 -9
  4. data/conf/suse/puppet.spec +4 -1
  5. data/install.rb +9 -22
  6. data/lib/puppet.rb +1 -31
  7. data/lib/puppet/agent.rb +3 -5
  8. data/lib/puppet/agent/locker.rb +15 -1
  9. data/lib/puppet/application.rb +7 -4
  10. data/lib/puppet/application/agent.rb +4 -25
  11. data/lib/puppet/application/apply.rb +3 -3
  12. data/lib/puppet/application/device.rb +2 -16
  13. data/lib/puppet/application/doc.rb +2 -2
  14. data/lib/puppet/application/face_base.rb +22 -5
  15. data/lib/puppet/application/filebucket.rb +2 -0
  16. data/lib/puppet/application/inspect.rb +2 -1
  17. data/lib/puppet/application/kick.rb +25 -9
  18. data/lib/puppet/application/queue.rb +0 -23
  19. data/lib/puppet/configurer.rb +1 -0
  20. data/lib/puppet/configurer/downloader.rb +7 -3
  21. data/lib/puppet/defaults.rb +34 -29
  22. data/lib/puppet/face/ca.rb +1 -1
  23. data/lib/puppet/face/catalog.rb +1 -0
  24. data/lib/puppet/face/file/store.rb +1 -1
  25. data/lib/puppet/face/module/list.rb +23 -3
  26. data/lib/puppet/face/module/search.rb +21 -32
  27. data/lib/puppet/face/module/uninstall.rb +56 -15
  28. data/lib/puppet/file_bucket/dipper.rb +2 -2
  29. data/lib/puppet/file_serving/base.rb +6 -5
  30. data/lib/puppet/file_serving/configuration/parser.rb +1 -1
  31. data/lib/puppet/file_serving/content.rb +1 -1
  32. data/lib/puppet/forge.rb +153 -0
  33. data/lib/puppet/{module_tool → forge}/cache.rb +1 -2
  34. data/lib/puppet/{module_tool → forge}/repository.rb +46 -4
  35. data/lib/puppet/indirector/exec.rb +1 -1
  36. data/lib/puppet/indirector/file_bucket_file/file.rb +3 -3
  37. data/lib/puppet/interface/action.rb +6 -2
  38. data/lib/puppet/module.rb +70 -10
  39. data/lib/puppet/module_tool.rb +2 -38
  40. data/lib/puppet/module_tool/applications.rb +15 -11
  41. data/lib/puppet/module_tool/applications/application.rb +2 -5
  42. data/lib/puppet/module_tool/applications/cleaner.rb +1 -1
  43. data/lib/puppet/module_tool/applications/installer.rb +10 -45
  44. data/lib/puppet/module_tool/applications/searcher.rb +2 -26
  45. data/lib/puppet/module_tool/applications/uninstaller.rb +39 -13
  46. data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
  47. data/lib/puppet/module_tool/dependency.rb +1 -1
  48. data/lib/puppet/network/authconfig.rb +1 -1
  49. data/lib/puppet/network/handler/fileserver.rb +1 -1
  50. data/lib/puppet/network/http/handler.rb +4 -1
  51. data/lib/puppet/network/http/webrick.rb +4 -2
  52. data/lib/puppet/node/environment.rb +32 -6
  53. data/lib/puppet/parameter/path.rb +0 -4
  54. data/lib/puppet/parser/ast/relationship.rb +3 -16
  55. data/lib/puppet/parser/collector.rb +5 -3
  56. data/lib/puppet/parser/compiler.rb +2 -1
  57. data/lib/puppet/parser/functions/file.rb +1 -1
  58. data/lib/puppet/parser/functions/generate.rb +8 -2
  59. data/lib/puppet/parser/grammar.ra +16 -15
  60. data/lib/puppet/parser/parser.rb +959 -881
  61. data/lib/puppet/parser/relationship.rb +32 -15
  62. data/lib/puppet/parser/resource.rb +0 -1
  63. data/lib/puppet/parser/type_loader.rb +1 -2
  64. data/lib/puppet/provider/augeas/augeas.rb +17 -29
  65. data/lib/puppet/provider/exec/windows.rb +25 -3
  66. data/lib/puppet/provider/file/posix.rb +1 -1
  67. data/lib/puppet/provider/file/windows.rb +1 -1
  68. data/lib/puppet/provider/group/windows_adsi.rb +1 -1
  69. data/lib/puppet/provider/package/aix.rb +1 -1
  70. data/lib/puppet/provider/package/appdmg.rb +1 -1
  71. data/lib/puppet/provider/package/dpkg.rb +1 -1
  72. data/lib/puppet/provider/package/gem.rb +21 -23
  73. data/lib/puppet/provider/package/macports.rb +1 -1
  74. data/lib/puppet/provider/package/msi.rb +7 -1
  75. data/lib/puppet/provider/package/openbsd.rb +13 -16
  76. data/lib/puppet/provider/package/pacman.rb +1 -1
  77. data/lib/puppet/provider/package/pip.rb +3 -0
  78. data/lib/puppet/provider/package/pkg.rb +1 -1
  79. data/lib/puppet/provider/package/pkgdmg.rb +1 -1
  80. data/lib/puppet/provider/package/pkgutil.rb +1 -1
  81. data/lib/puppet/provider/package/portage.rb +2 -2
  82. data/lib/puppet/provider/package/rpm.rb +1 -1
  83. data/lib/puppet/provider/package/sun.rb +1 -1
  84. data/lib/puppet/provider/package/zypper.rb +35 -3
  85. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +6 -2
  86. data/lib/puppet/provider/selmodule/semodule.rb +2 -2
  87. data/lib/puppet/provider/service/base.rb +1 -1
  88. data/lib/puppet/provider/service/launchd.rb +4 -0
  89. data/lib/puppet/provider/service/src.rb +2 -2
  90. data/lib/puppet/provider/service/upstart.rb +1 -1
  91. data/lib/puppet/provider/service/windows.rb +5 -4
  92. data/lib/puppet/provider/user/aix.rb +3 -3
  93. data/lib/puppet/provider/user/pw.rb +6 -0
  94. data/lib/puppet/provider/user/windows_adsi.rb +1 -1
  95. data/lib/puppet/resource/catalog.rb +6 -6
  96. data/lib/puppet/resource/type.rb +2 -0
  97. data/lib/puppet/ssl/certificate_request.rb +0 -70
  98. data/lib/puppet/transaction.rb +1 -1
  99. data/lib/puppet/transaction/report.rb +3 -2
  100. data/lib/puppet/type.rb +1 -1
  101. data/lib/puppet/type/cron.rb +5 -2
  102. data/lib/puppet/type/exec.rb +8 -0
  103. data/lib/puppet/type/file.rb +27 -18
  104. data/lib/puppet/type/file/checksum.rb +2 -2
  105. data/lib/puppet/type/file/content.rb +14 -9
  106. data/lib/puppet/type/file/ensure.rb +5 -4
  107. data/lib/puppet/type/file/group.rb +10 -2
  108. data/lib/puppet/type/file/mode.rb +46 -18
  109. data/lib/puppet/type/file/owner.rb +10 -2
  110. data/lib/puppet/type/file/source.rb +27 -40
  111. data/lib/puppet/type/file/target.rb +6 -6
  112. data/lib/puppet/type/group.rb +13 -9
  113. data/lib/puppet/type/k5login.rb +1 -1
  114. data/lib/puppet/type/package.rb +24 -8
  115. data/lib/puppet/type/scheduled_task.rb +77 -131
  116. data/lib/puppet/type/service.rb +22 -8
  117. data/lib/puppet/type/user.rb +29 -9
  118. data/lib/puppet/util.rb +24 -33
  119. data/lib/puppet/util/colors.rb +98 -0
  120. data/lib/puppet/util/diff.rb +3 -1
  121. data/lib/puppet/util/log.rb +5 -1
  122. data/lib/puppet/util/log/destinations.rb +37 -44
  123. data/lib/puppet/util/monkey_patches.rb +32 -0
  124. data/lib/puppet/util/pidlock.rb +70 -21
  125. data/lib/puppet/util/rdoc/parser.rb +4 -2
  126. data/lib/puppet/util/selinux.rb +1 -1
  127. data/lib/puppet/util/suidmanager.rb +2 -12
  128. data/lib/puppet/util/windows.rb +2 -0
  129. data/lib/puppet/util/windows/process.rb +33 -0
  130. data/lib/puppet/util/windows/security.rb +6 -4
  131. data/lib/puppet/util/windows/user.rb +44 -0
  132. data/lib/semver.rb +55 -4
  133. data/spec/fixtures/unit/provider/package/openbsd/pkginfo.detail +19 -0
  134. data/spec/fixtures/unit/provider/package/openbsd/pkginfo.list +10 -0
  135. data/spec/fixtures/unit/provider/package/openbsd/pkginfo.query +1 -0
  136. data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-SLES11sp1.out +369 -0
  137. data/spec/integration/defaults_spec.rb +10 -0
  138. data/spec/integration/indirector/direct_file_server_spec.rb +1 -1
  139. data/spec/integration/module_tool_spec.rb +10 -12
  140. data/spec/integration/parser/compiler_spec.rb +147 -0
  141. data/spec/integration/type/file_spec.rb +1 -1
  142. data/spec/integration/util/windows/user_spec.rb +59 -0
  143. data/spec/lib/puppet/face/basetest.rb +5 -0
  144. data/spec/lib/puppet_spec/modules.rb +26 -0
  145. data/spec/spec_helper.rb +25 -0
  146. data/spec/unit/agent/locker_spec.rb +12 -0
  147. data/spec/unit/agent_backward_compatibility_spec.rb +152 -0
  148. data/spec/unit/agent_spec.rb +28 -8
  149. data/spec/unit/application/agent_spec.rb +4 -36
  150. data/spec/unit/application/device_spec.rb +55 -10
  151. data/spec/unit/application/face_base_spec.rb +32 -10
  152. data/spec/unit/application/filebucket_spec.rb +5 -0
  153. data/spec/unit/application/kick_spec.rb +6 -0
  154. data/spec/unit/application_spec.rb +8 -1
  155. data/spec/unit/configurer/downloader_spec.rb +4 -5
  156. data/spec/unit/face/ca_spec.rb +15 -4
  157. data/spec/unit/file_bucket/dipper_spec.rb +1 -1
  158. data/spec/unit/file_serving/base_spec.rb +60 -42
  159. data/spec/unit/file_serving/configuration/parser_spec.rb +5 -3
  160. data/spec/unit/file_serving/content_spec.rb +26 -27
  161. data/spec/unit/file_serving/metadata_spec.rb +22 -21
  162. data/spec/unit/forge/repository_spec.rb +86 -0
  163. data/spec/unit/forge_spec.rb +114 -0
  164. data/spec/unit/indirector/exec_spec.rb +8 -6
  165. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +0 -1
  166. data/spec/unit/indirector/file_bucket_file/file_spec.rb +1 -1
  167. data/spec/unit/indirector/node/exec_spec.rb +1 -1
  168. data/spec/unit/indirector/resource/active_record_spec.rb +0 -4
  169. data/spec/unit/interface/action_builder_spec.rb +7 -5
  170. data/spec/unit/module_spec.rb +228 -9
  171. data/spec/unit/module_tool/application_spec.rb +3 -3
  172. data/spec/unit/module_tool/uninstaller_spec.rb +107 -27
  173. data/spec/unit/module_tool_spec.rb +0 -33
  174. data/spec/unit/network/authconfig_spec.rb +22 -21
  175. data/spec/unit/network/http/webrick_spec.rb +13 -9
  176. data/spec/unit/node/environment_spec.rb +159 -66
  177. data/spec/unit/parser/collector_spec.rb +16 -8
  178. data/spec/unit/parser/functions/generate_spec.rb +60 -18
  179. data/spec/unit/parser/resource_spec.rb +44 -0
  180. data/spec/unit/provider/augeas/augeas_spec.rb +160 -179
  181. data/spec/unit/provider/confine/feature_spec.rb +3 -5
  182. data/spec/unit/provider/package/dpkg_spec.rb +4 -2
  183. data/spec/unit/provider/package/gem_spec.rb +59 -43
  184. data/spec/unit/provider/package/openbsd_spec.rb +114 -0
  185. data/spec/unit/provider/package/pacman_spec.rb +1 -1
  186. data/spec/unit/provider/package/pip_spec.rb +10 -4
  187. data/spec/unit/provider/package/zypper_spec.rb +56 -14
  188. data/spec/unit/provider/selmodule_spec.rb +3 -3
  189. data/spec/unit/provider/service/launchd_spec.rb +22 -21
  190. data/spec/unit/provider/service/{upstart.rb → upstart_spec.rb} +7 -3
  191. data/spec/unit/provider/user/pw_spec.rb +19 -0
  192. data/spec/unit/resource/catalog_spec.rb +3 -3
  193. data/spec/unit/semver_spec.rb +117 -24
  194. data/spec/unit/transaction/report_spec.rb +11 -1
  195. data/spec/unit/type/cron_spec.rb +200 -213
  196. data/spec/unit/type/exec_spec.rb +7 -0
  197. data/spec/unit/type/file/content_spec.rb +2 -2
  198. data/spec/unit/type/file_spec.rb +12 -9
  199. data/spec/unit/type/package_spec.rb +25 -0
  200. data/spec/unit/type/schedule_spec.rb +31 -31
  201. data/spec/unit/util/diff_spec.rb +30 -0
  202. data/spec/unit/util/execution_stub_spec.rb +1 -2
  203. data/spec/unit/util/log/destinations_spec.rb +51 -0
  204. data/spec/unit/util/log_spec.rb +17 -1
  205. data/spec/unit/util/monkey_patches_spec.rb +119 -0
  206. data/spec/unit/util/rdoc/parser_spec.rb +25 -1
  207. data/spec/unit/util/selinux_spec.rb +2 -2
  208. data/spec/unit/util/suidmanager_spec.rb +6 -51
  209. data/spec/unit/util_spec.rb +82 -24
  210. data/test/lib/puppettest/certificates.rb +16 -0
  211. data/test/lib/puppettest/servertest.rb +4 -0
  212. data/test/util/pidlock.rb +125 -0
  213. metadata +23 -14
  214. data/ext/puppetstoredconfigclean.rb +0 -103
  215. data/lib/puppet/agent/disabler.rb +0 -27
  216. data/lib/puppet/util/anonymous_filelock.rb +0 -36
  217. data/spec/unit/agent/disabler_spec.rb +0 -60
  218. data/spec/unit/module_tool/repository_spec.rb +0 -52
  219. data/spec/unit/util/anonymous_filelock_spec.rb +0 -78
  220. data/spec/unit/util/pidlock_spec.rb +0 -208
@@ -19,7 +19,7 @@ Puppet::Type.newtype(:k5login) do
19
19
  desc "The path to the `.k5login` file to manage. Must be fully qualified."
20
20
 
21
21
  validate do |value|
22
- unless value =~ /^#{File::SEPARATOR}/
22
+ unless absolute_path?(value)
23
23
  raise Puppet::Error, "File paths must be fully qualified."
24
24
  end
25
25
  end
@@ -115,7 +115,6 @@ module Puppet
115
115
  # Override the parent method, because we've got all kinds of
116
116
  # funky definitions of 'in sync'.
117
117
  def insync?(is)
118
- @latest ||= nil
119
118
  @lateststamp ||= (Time.now.to_i - 1000)
120
119
  # Iterate across all of the should values, and see how they
121
120
  # turn out.
@@ -156,7 +155,9 @@ module Puppet
156
155
  return true if is == :absent or is == :purged
157
156
  when :purged
158
157
  return true if is == :purged
159
- when is
158
+ # this handles version number matches and
159
+ # supports providers that can have multiple versions installed
160
+ when *Array(is)
160
161
  return true
161
162
  end
162
163
  }
@@ -301,8 +302,25 @@ module Puppet
301
302
  end
302
303
 
303
304
  newparam(:install_options, :required_features => :install_options) do
304
- desc "A hash of options to be handled by the provider when
305
- installing a package."
305
+ desc <<-EOT
306
+ A hash of additional options to pass when installing a package. These
307
+ options are package-specific, and should be documented by the software
308
+ vendor. The most commonly implemented option is `INSTALLDIR`:
309
+
310
+ package { 'mysql':
311
+ ensure => installed,
312
+ provider => 'msi',
313
+ source => 'N:/packages/mysql-5.5.16-winx64.msi',
314
+ install_options => { 'INSTALLDIR' => 'C:\\mysql-5.5' },
315
+ }
316
+
317
+ Since these options are passed verbatim to `msiexec`, any file paths
318
+ specified in `install_options` should use a backslash as the separator
319
+ character rather than a forward slash. This is the **only** place in Puppet
320
+ where backslash separators should be used. Note that backslashes in
321
+ double-quoted strings _must_ be double-escaped and backslashes
322
+ in single-quoted strings _may_ be double-escaped.
323
+ EOT
306
324
  end
307
325
 
308
326
  autorequire(:file) do
@@ -313,10 +331,8 @@ module Puppet
313
331
  end
314
332
  }
315
333
 
316
- if source = self[:source]
317
- if source =~ /^#{File::SEPARATOR}/
318
- autos << source
319
- end
334
+ if source = self[:source] and absolute_path?(source)
335
+ autos << source
320
336
  end
321
337
  autos
322
338
  end
@@ -3,98 +3,16 @@ require 'puppet/util'
3
3
  Puppet::Type.newtype(:scheduled_task) do
4
4
  include Puppet::Util
5
5
 
6
- @doc = "Installs and manages Windows Scheduled Tasks. All fields
7
- except the name, command, and start_time are optional; specifying
8
- no repetition parameters will result in a task that runs once on
9
- the start date.
10
-
11
- Examples:
12
-
13
- # Create a task that will fire on August 31st, 2011 at 8am in
14
- # the system's time-zone.
15
- scheduled_task { 'One-shot task':
16
- ensure => present,
17
- enabled => true,
18
- command => 'C:\path\to\command.exe',
19
- arguments => '/flags /to /pass',
20
- trigger => {
21
- schedule => once,
22
- start_date => '2011-08-31', # Defaults to 'today'
23
- start_time => '08:00', # Must be specified
24
- }
25
- }
26
-
27
- # Create a task that will fire every other day at 8am in the
28
- # system's time-zone, starting August 31st, 2011.
29
- scheduled_task { 'Daily task':
30
- ensure => present,
31
- enabled => true,
32
- command => 'C:\path\to\command.exe',
33
- arguments => '/flags /to /pass',
34
- trigger => {
35
- schedule => daily,
36
- every => 2 # Defaults to 1
37
- start_date => '2011-08-31', # Defaults to 'today'
38
- start_time => '08:00', # Must be specified
39
- }
40
- }
41
-
42
- # Create a task that will fire at 8am Monday every third week,
43
- # starting after August 31st, 2011.
44
- scheduled_task { 'Weekly task':
45
- ensure => present,
46
- enabled => true,
47
- command => 'C:\path\to\command.exe',
48
- arguments => '/flags /to /pass',
49
- trigger => {
50
- schedule => weekly,
51
- every => 3, # Defaults to 1
52
- start_date => '2011-08-31' # Defaults to 'today'
53
- start_time => '08:00', # Must be specified
54
- day_of_week => [mon], # Defaults to all
55
- }
56
- }
57
-
58
- # Create a task that will fire at 8am on the 1st, 15th, and last
59
- # day of the month in January, March, May, July, September, and
60
- # November starting August 31st, 2011.
61
- scheduled_task { 'Monthly date task':
62
- ensure => present,
63
- enabled => true,
64
- command => 'C:\path\to\command.exe',
65
- arguments => '/flags /to /pass',
66
- trigger => {
67
- schedule => monthly,
68
- start_date => '2011-08-31', # Defaults to 'today'
69
- start_time => '08:00', # Must be specified
70
- months => [1,3,5,7,9,11], # Defaults to all
71
- on => [1, 15, last], # Must be specified
72
- }
73
- }
74
-
75
- # Create a task that will fire at 8am on the first Monday of the
76
- # month for January, March, and May, after August 31st, 2011.
77
- scheduled_task { 'Monthly day of week task':
78
- enabled => true,
79
- ensure => present,
80
- command => 'C:\path\to\command.exe',
81
- arguments => '/flags /to /pass',
82
- trigger => {
83
- schedule => monthly,
84
- start_date => '2011-08-31', # Defaults to 'today'
85
- start_time => '08:00', # Must be specified
86
- months => [1,3,5], # Defaults to all
87
- which_occurrence => first, # Must be specified
88
- day_of_week => [mon], # Must be specified
89
- }
90
- }"
6
+ @doc = "Installs and manages Windows Scheduled Tasks. All attributes
7
+ except `name`, `command`, and `trigger` are optional; see the description
8
+ of the `trigger` attribute for details on setting schedules."
91
9
 
92
10
  ensurable
93
11
 
94
12
  newproperty(:enabled) do
95
- desc "Whether the triggers for this task are enabled. This only
96
- supports enabling or disabling all of the triggers for a task,
97
- not enabling or disabling them on an individual basis."
13
+ desc "Whether the triggers for this task should be enabled. This attribute
14
+ affects every trigger for the task; triggers cannot be enabled or
15
+ disabled individually."
98
16
 
99
17
  newvalue(:true, :event => :task_enabled)
100
18
  newvalue(:false, :event => :task_disabled)
@@ -110,8 +28,7 @@ Puppet::Type.newtype(:scheduled_task) do
110
28
  end
111
29
 
112
30
  newproperty(:command) do
113
- desc "The full path to the application to be run, without any
114
- arguments."
31
+ desc "The full path to the application to run, without any arguments."
115
32
 
116
33
  validate do |value|
117
34
  raise Puppet::Error.new('Must be specified using an absolute path.') unless absolute_path?(value)
@@ -119,8 +36,7 @@ Puppet::Type.newtype(:scheduled_task) do
119
36
  end
120
37
 
121
38
  newproperty(:working_dir) do
122
- desc "The full path of the directory in which to start the
123
- command"
39
+ desc "The full path of the directory in which to start the command."
124
40
 
125
41
  validate do |value|
126
42
  raise Puppet::Error.new('Must be specified using an absolute path.') unless absolute_path?(value)
@@ -128,7 +44,8 @@ Puppet::Type.newtype(:scheduled_task) do
128
44
  end
129
45
 
130
46
  newproperty(:arguments, :array_matching => :all) do
131
- desc "The optional arguments to pass to the command."
47
+ desc "Any arguments or flags that should be passed to the command. Multiple arguments
48
+ can be specified as an array or as a space-separated string."
132
49
  end
133
50
 
134
51
  newproperty(:user) do
@@ -149,7 +66,7 @@ Puppet::Type.newtype(:scheduled_task) do
149
66
  end
150
67
 
151
68
  newparam(:password) do
152
- desc "The password for the user specified in the 'user' property.
69
+ desc "The password for the user specified in the 'user' attribute.
153
70
  This is only used if specifying a user other than 'SYSTEM'.
154
71
  Since there is no way to retrieve the password used to set the
155
72
  account information for a task, this parameter will not be used
@@ -157,43 +74,72 @@ Puppet::Type.newtype(:scheduled_task) do
157
74
  end
158
75
 
159
76
  newproperty(:trigger, :array_matching => :all) do
160
- desc "This is a hash defining the properties of the trigger used
161
- to fire the scheduled task. The one key that is always required
162
- is 'schedule', which can be one of 'daily', 'weekly', or
163
- 'monthly'. The other valid & required keys depend on the value
164
- of schedule.
165
-
166
- When schedule is 'daily', you can specify a value for 'every'
167
- which specifies that the task will trigger every N days. If
168
- 'every' is not specified, it defaults to 1 (running every day).
169
-
170
- When schedule is 'weekly', you can specify values for 'every',
171
- and 'day_of_week'. 'every' has similar behavior as when
172
- specified for 'daily', though it repeats every N weeks, instead
173
- of every N days. 'day_of_week' is used to specify on which days
174
- of the week the task should be run. This can be specified as an
175
- array where the possible values are 'mon', 'tues', 'wed',
176
- 'thurs', 'fri', 'sat', and 'sun', or as the string 'all'. The
177
- default is 'all'.
178
-
179
- When schedule is 'monthly', the syntax depends on whether you
180
- wish to specify the trigger using absolute, or relative dates.
181
- In either case, you can specify which months this trigger
182
- applies to using 'months', and specifying an array of integer
183
- months. 'months' defaults to all months.
184
-
185
- When specifying a monthly schedule with absolute dates, 'on'
186
- must be provided as an array of days (1-31, or the special value
187
- 'last' which will always be the last day of the month).
188
-
189
- When specifying a monthly schedule with relative dates,
190
- 'which_occurrence', and 'day_of_week' must be specified. The
191
- possible values for 'which_occurrence' are 'first', 'second',
192
- 'third', 'fourth', 'fifth', and 'last'. 'day_of_week' is an
193
- array where the possible values are 'mon', 'tues', 'wed',
194
- 'thurs', 'fri', 'sat', and 'sun'. These combine to be able to
195
- specify things like: The task should run on the first Monday of
196
- the specified month(s)."
77
+ desc <<-EOT
78
+ One or more triggers defining when the task should run. A single trigger is
79
+ represented as a hash, and multiple triggers can be specified with an array of
80
+ hashes.
81
+
82
+ A trigger can contain the following keys:
83
+
84
+ * For all triggers:
85
+ * `schedule` **(Required)** --- The schedule type. Valid values are
86
+ `daily`, `weekly`, `monthly`, or `once`.
87
+ * `start_time` **(Required)** --- The time of day when the trigger should
88
+ first become active. Several time formats will work, but we
89
+ suggest 24-hour time formatted as HH:MM.
90
+ * `start_date` --- The date when the trigger should first become active.
91
+ Defaults to "today." Several date formats will work, including
92
+ special dates like "today," but we suggest formatting dates as
93
+ YYYY-MM-DD.
94
+ * For daily triggers:
95
+ * `every` --- How often the task should run, as a number of days. Defaults
96
+ to 1. ("2" means every other day, "3" means every three days, etc.)
97
+ * For weekly triggers:
98
+ * `every` --- How often the task should run, as a number of weeks. Defaults
99
+ to 1. ("2" means every other week, "3" means every three weeks, etc.)
100
+ * `day_of_week` --- Which days of the week the task should run, as an array.
101
+ Defaults to all days. Each day must be one of `mon`, `tues`,
102
+ `wed`, `thurs`, `fri`, `sat`, `sun`, or `all`.
103
+ * For monthly-by-date triggers:
104
+ * `months` --- Which months the task should run, as an array. Defaults to
105
+ all months. Each month must be an integer between 1 and 12.
106
+ * `on` **(Required)** --- Which days of the month the task should run,
107
+ as an array. Each day must beeither an integer between 1 and 31,
108
+ or the special value `last,` which is always the last day of the month.
109
+ * For monthly-by-weekday triggers:
110
+ * `months` --- Which months the task should run, as an array. Defaults to
111
+ all months. Each month must be an integer between 1 and 12.
112
+ * `day_of_week` **(Required)** --- Which day of the week the task should
113
+ run, as an array with only one element. Each day must be one of `mon`,
114
+ `tues`, `wed`, `thurs`, `fri`, `sat`, `sun`, or `all`.
115
+ * `which_occurrence` **(Required)** --- The occurrence of the chosen weekday
116
+ when the task should run. Must be one of `first`, `second`, `third`,
117
+ `fourth`, `fifth`, or `last`.
118
+
119
+ Examples:
120
+
121
+ # Run at 8am on the 1st, 15th, and last day of the month in January, March,
122
+ # May, July, September, and November, starting after August 31st, 2011.
123
+ trigger => {
124
+ schedule => monthly,
125
+ start_date => '2011-08-31', # Defaults to 'today'
126
+ start_time => '08:00', # Must be specified
127
+ months => [1,3,5,7,9,11], # Defaults to all
128
+ on => [1, 15, last], # Must be specified
129
+ }
130
+
131
+ # Run at 8am on the first Monday of the month for January, March, and May,
132
+ # starting after August 31st, 2011.
133
+ trigger => {
134
+ schedule => monthly,
135
+ start_date => '2011-08-31', # Defaults to 'today'
136
+ start_time => '08:00', # Must be specified
137
+ months => [1,3,5], # Defaults to all
138
+ which_occurrence => first, # Must be specified
139
+ day_of_week => [mon], # Must be specified
140
+ }
141
+
142
+ EOT
197
143
 
198
144
  validate do |value|
199
145
  provider.validate_trigger(value)
@@ -105,6 +105,12 @@ module Puppet
105
105
  command; defaults to `true`. This attribute's default value changed in
106
106
  Puppet 2.7.0.
107
107
 
108
+ The init script's status command must return 0 if the service is
109
+ running and a nonzero value otherwise. Ideally, these exit codes
110
+ should conform to [the LSB's specification][lsb-exit-codes] for init
111
+ script status actions, but Puppet only considers the difference
112
+ between 0 and nonzero to be relevant.
113
+
108
114
  If a service's init script does not support any kind of status command,
109
115
  you should set `hasstatus` to false and either provide a specific
110
116
  command using the `status` attribute or expect that Puppet will look for
@@ -118,8 +124,14 @@ module Puppet
118
124
  defaultto :true
119
125
  end
120
126
  newparam(:name) do
121
- desc "The name of the service to run. This name is used to find
122
- the service in whatever service subsystem it is in."
127
+ desc <<-EOT
128
+ The name of the service to run.
129
+
130
+ This name is used to find the service; on platforms where services
131
+ have short system names and long display names, this should be the
132
+ short name. (To take an example from Windows, you would use "wuauserv"
133
+ rather than "Automatic Updates.")
134
+ EOT
123
135
  isnamevar
124
136
  end
125
137
 
@@ -160,14 +172,16 @@ module Puppet
160
172
  newparam(:status) do
161
173
  desc "Specify a *status* command manually. This command must
162
174
  return 0 if the service is running and a nonzero value otherwise.
163
- Ideally, these return codes should conform to
164
- [the LSB's specification for init script status actions](http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html),
165
- but Puppet only considers the difference between 0 and nonzero
166
- to be relevant.
175
+ Ideally, these exit codes should conform to [the LSB's
176
+ specification][lsb-exit-codes] for init script status actions, but
177
+ Puppet only considers the difference between 0 and nonzero to be
178
+ relevant.
167
179
 
168
- If left unspecified, the status method will be determined
180
+ If left unspecified, the status of the service will be determined
169
181
  automatically, usually by looking for the service in the process
170
- table."
182
+ table.
183
+
184
+ [lsb-exit-codes]: http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html"
171
185
  end
172
186
 
173
187
  newparam(:stop) do
@@ -113,8 +113,10 @@ module Puppet
113
113
  end
114
114
 
115
115
  newproperty(:gid) do
116
- desc "The user's primary group. Can be specified numerically or
117
- by name."
116
+ desc "The user's primary group. Can be specified numerically or by name.
117
+
118
+ Note that users on Windows systems do not have a primary group; manage groups
119
+ with the `groups` attribute instead."
118
120
 
119
121
  munge do |value|
120
122
  if value.is_a?(String) and value =~ /^[-0-9]+$/
@@ -156,14 +158,28 @@ module Puppet
156
158
 
157
159
  newproperty(:shell) do
158
160
  desc "The user's login shell. The shell must exist and be
159
- executable."
161
+ executable.
162
+
163
+ This attribute cannot be managed on Windows systems."
160
164
  end
161
165
 
162
166
  newproperty(:password, :required_features => :manages_passwords) do
163
167
  desc %q{The user's password, in whatever encrypted format the local
164
- machine requires. Be sure to enclose any value that includes a dollar
165
- sign ($) in single quotes (') to avoid accidental variable
166
- interpolation.}
168
+ system requires.
169
+
170
+ * Most modern Unix-like systems use salted SHA1 password hashes. You can use
171
+ Puppet's built-in `sha1` function to generate a hash from a password.
172
+ * Mac OS X 10.5 and 10.6 also use salted SHA1 hashes.
173
+ * Mac OS X 10.7 (Lion) uses salted SHA512 hashes. The Puppet Labs [stdlib][]
174
+ module contains a `str2saltedsha512` function which can generate password
175
+ hashes for Lion.
176
+ * Windows passwords can only be managed in cleartext, as there is no Windows API
177
+ for setting the password hash.
178
+
179
+ [stdlib]: https://github.com/puppetlabs/puppetlabs-stdlib/
180
+
181
+ Be sure to enclose any value that includes a dollar sign ($) in single
182
+ quotes (') to avoid accidental variable interpolation.}
167
183
 
168
184
  validate do |value|
169
185
  raise ArgumentError, "Passwords cannot include ':'" if value.is_a?(String) and value.include?(":")
@@ -240,7 +256,11 @@ module Puppet
240
256
  newparam(:name) do
241
257
  desc "The user name. While naming limitations vary by operating system,
242
258
  it is advisable to restrict names to the lowest common denominator,
243
- which is a maximum of 8 characters beginning with a letter."
259
+ which is a maximum of 8 characters beginning with a letter.
260
+
261
+ Note that Puppet considers user names to be case-sensitive, regardless
262
+ of the platform's own rules; be sure to always use the same case when
263
+ referring to a given user."
244
264
  isnamevar
245
265
  end
246
266
 
@@ -450,7 +470,7 @@ module Puppet
450
470
  end
451
471
 
452
472
  validate do |value|
453
- raise ArgumentError, "Key/value pairs must be seperated by an =" unless value.include?("=")
473
+ raise ArgumentError, "Key/value pairs must be separated by an =" unless value.include?("=")
454
474
  end
455
475
  end
456
476
 
@@ -484,7 +504,7 @@ module Puppet
484
504
  end
485
505
 
486
506
  validate do |value|
487
- raise ArgumentError, "Attributes value pairs must be seperated by an =" unless value.include?("=")
507
+ raise ArgumentError, "Attributes value pairs must be separated by an =" unless value.include?("=")
488
508
  end
489
509
  end
490
510
 
@@ -120,28 +120,6 @@ module Util
120
120
  end
121
121
  end
122
122
 
123
- # XXX this should all be done using puppet objects, not using
124
- # normal mkdir
125
- def self.recmkdir(dir,mode = 0755)
126
- if FileTest.exist?(dir)
127
- return false
128
- else
129
- tmp = dir.sub(/^\//,'')
130
- path = [File::SEPARATOR]
131
- tmp.split(File::SEPARATOR).each { |dir|
132
- path.push dir
133
- if ! FileTest.exist?(File.join(path))
134
- Dir.mkdir(File.join(path), mode)
135
- elsif FileTest.directory?(File.join(path))
136
- next
137
- else FileTest.exist?(File.join(path))
138
- raise "Cannot create #{dir}: basedir #{File.join(path)} is a file"
139
- end
140
- }
141
- return true
142
- end
143
- end
144
-
145
123
  # Execute a given chunk of code with a new umask.
146
124
  def self.withumask(mask)
147
125
  cur = File.umask(mask)
@@ -270,7 +248,14 @@ module Util
270
248
  end
271
249
  module_function :uri_to_path
272
250
 
273
- # Execute the provided command in a pipe, yielding the pipe object.
251
+ # Execute the provided command with STDIN connected to a pipe, yielding the
252
+ # pipe object. That allows data to be fed to that subprocess.
253
+ #
254
+ # The command can be a simple string, which is executed as-is, or an Array,
255
+ # which is treated as a set of command arguments to pass through.#
256
+ #
257
+ # In all cases this is passed directly to the shell, and STDOUT and STDERR
258
+ # are connected together during execution.
274
259
  def execpipe(command, failonfail = true)
275
260
  if respond_to? :debug
276
261
  debug "Executing '#{command}'"
@@ -278,7 +263,14 @@ module Util
278
263
  Puppet.debug "Executing '#{command}'"
279
264
  end
280
265
 
281
- command_str = command.respond_to?(:join) ? command.join('') : command
266
+ # Paste together an array with spaces. We used to paste directly
267
+ # together, no spaces, which made for odd invocations; the user had to
268
+ # include whitespace between arguments.
269
+ #
270
+ # Having two spaces is really not a big drama, since this passes to the
271
+ # shell anyhow, while no spaces makes for a small developer cost every
272
+ # time this is invoked. --daniel 2012-02-13
273
+ command_str = command.respond_to?(:join) ? command.join(' ') : command
282
274
  output = open("| #{command_str} 2>&1") do |pipe|
283
275
  yield pipe
284
276
  end
@@ -333,8 +325,7 @@ module Util
333
325
  part.include?(' ') ? %Q["#{part.gsub(/"/, '\"')}"] : part
334
326
  end.join(" ") if command.is_a?(Array)
335
327
 
336
- process_info = Process.create( :command_line => command, :startup_info => {:stdin => stdin, :stdout => stdout, :stderr => stderr} )
337
- process_info.process_id
328
+ Puppet::Util::Windows::Process.execute(command, arguments, stdin, stdout, stderr)
338
329
  end
339
330
  module_function :execute_windows
340
331
 
@@ -371,13 +362,13 @@ module Util
371
362
  child_pid = execute_posix(*exec_args)
372
363
  exit_status = Process.waitpid2(child_pid).last.exitstatus
373
364
  elsif Puppet.features.microsoft_windows?
374
- child_pid = execute_windows(*exec_args)
375
- exit_status = Process.waitpid2(child_pid).last
376
- # $CHILD_STATUS is not set when calling win32/process Process.create
377
- # and since it's read-only, we can't set it. But we can execute a
378
- # a shell that simply returns the desired exit status, which has the
379
- # desired effect.
380
- %x{#{ENV['COMSPEC']} /c exit #{exit_status}}
365
+ process_info = execute_windows(*exec_args)
366
+ begin
367
+ exit_status = Puppet::Util::Windows::Process.wait_process(process_info.process_handle)
368
+ ensure
369
+ Process.CloseHandle(process_info.process_handle)
370
+ Process.CloseHandle(process_info.thread_handle)
371
+ end
381
372
  end
382
373
 
383
374
  [stdin, stdout, stderr].each {|io| io.close rescue nil}