puppet 5.5.8 → 5.5.10

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 (117) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +14 -14
  3. data/Rakefile +3 -1
  4. data/ext/solaris/smf/svc-puppetd +8 -1
  5. data/ext/solaris/smf/svc-puppetmasterd +8 -1
  6. data/lib/puppet/application/device.rb +45 -29
  7. data/lib/puppet/face/config.rb +1 -1
  8. data/lib/puppet/forge.rb +4 -1
  9. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +3 -1
  10. data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
  11. data/lib/puppet/pops/types/string_converter.rb +11 -2
  12. data/lib/puppet/provider/cron/crontab.rb +1 -1
  13. data/lib/puppet/provider/package/windows/exe_package.rb +13 -0
  14. data/lib/puppet/provider/package/windows/msi_package.rb +8 -0
  15. data/lib/puppet/provider/package/windows/package.rb +9 -1
  16. data/lib/puppet/provider/parsedfile.rb +25 -4
  17. data/lib/puppet/provider/service/smf.rb +54 -0
  18. data/lib/puppet/transaction.rb +4 -1
  19. data/lib/puppet/transaction/event_manager.rb +13 -1
  20. data/lib/puppet/transaction/resource_harness.rb +3 -1
  21. data/lib/puppet/util/command_line.rb +2 -3
  22. data/lib/puppet/util/filetype.rb +36 -4
  23. data/lib/puppet/util/selinux.rb +1 -1
  24. data/lib/puppet/util/windows/api_types.rb +1 -1
  25. data/lib/puppet/util/windows/registry.rb +29 -5
  26. data/lib/puppet/util/windows/service.rb +106 -99
  27. data/lib/puppet/version.rb +1 -1
  28. data/locales/puppet.pot +97 -69
  29. data/man/man5/puppet.conf.5 +2 -2
  30. data/man/man8/puppet-agent.8 +1 -1
  31. data/man/man8/puppet-apply.8 +1 -1
  32. data/man/man8/puppet-ca.8 +1 -1
  33. data/man/man8/puppet-catalog.8 +1 -1
  34. data/man/man8/puppet-cert.8 +1 -1
  35. data/man/man8/puppet-certificate.8 +1 -1
  36. data/man/man8/puppet-certificate_request.8 +1 -1
  37. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  38. data/man/man8/puppet-config.8 +2 -2
  39. data/man/man8/puppet-describe.8 +1 -1
  40. data/man/man8/puppet-device.8 +23 -19
  41. data/man/man8/puppet-doc.8 +1 -1
  42. data/man/man8/puppet-epp.8 +1 -1
  43. data/man/man8/puppet-facts.8 +1 -1
  44. data/man/man8/puppet-filebucket.8 +1 -1
  45. data/man/man8/puppet-generate.8 +1 -1
  46. data/man/man8/puppet-help.8 +1 -1
  47. data/man/man8/puppet-key.8 +1 -1
  48. data/man/man8/puppet-lookup.8 +1 -1
  49. data/man/man8/puppet-man.8 +1 -1
  50. data/man/man8/puppet-master.8 +1 -1
  51. data/man/man8/puppet-module.8 +1 -1
  52. data/man/man8/puppet-node.8 +1 -1
  53. data/man/man8/puppet-parser.8 +1 -1
  54. data/man/man8/puppet-plugin.8 +1 -1
  55. data/man/man8/puppet-report.8 +1 -1
  56. data/man/man8/puppet-resource.8 +1 -1
  57. data/man/man8/puppet-script.8 +1 -1
  58. data/man/man8/puppet-status.8 +1 -1
  59. data/man/man8/puppet.8 +2 -2
  60. data/spec/fixtures/unit/provider/service/smf/svcs_fmri.out +6 -0
  61. data/spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out +13 -0
  62. data/spec/integration/ssl/key_spec.rb +0 -4
  63. data/spec/integration/transaction_spec.rb +1 -1
  64. data/spec/integration/util/windows/registry_spec.rb +39 -0
  65. data/spec/unit/application/device_spec.rb +4 -1
  66. data/spec/unit/application/lookup_spec.rb +10 -9
  67. data/spec/unit/forge/forge_spec.rb +4 -2
  68. data/spec/unit/indirector/yaml_spec.rb +1 -1
  69. data/spec/unit/pops/loaders/loader_spec.rb +6 -7
  70. data/spec/unit/pops/types/p_timespan_type_spec.rb +22 -0
  71. data/spec/unit/pops/types/p_timestamp_type_spec.rb +19 -0
  72. data/spec/unit/pops/types/string_converter_spec.rb +20 -0
  73. data/spec/unit/provider/cron/parsed_spec.rb +4 -3
  74. data/spec/unit/provider/group/ldap_spec.rb +22 -25
  75. data/spec/unit/provider/group/pw_spec.rb +7 -10
  76. data/spec/unit/provider/host/parsed_spec.rb +3 -17
  77. data/spec/unit/provider/nameservice/directoryservice_spec.rb +97 -103
  78. data/spec/unit/provider/package/aix_spec.rb +5 -8
  79. data/spec/unit/provider/package/apt_spec.rb +3 -6
  80. data/spec/unit/provider/package/dnf_spec.rb +29 -31
  81. data/spec/unit/provider/package/dpkg_spec.rb +18 -21
  82. data/spec/unit/provider/package/freebsd_spec.rb +4 -7
  83. data/spec/unit/provider/package/gem_spec.rb +41 -41
  84. data/spec/unit/provider/package/hpux_spec.rb +7 -10
  85. data/spec/unit/provider/package/macports_spec.rb +13 -15
  86. data/spec/unit/provider/package/nim_spec.rb +3 -10
  87. data/spec/unit/provider/package/openbsd_spec.rb +14 -17
  88. data/spec/unit/provider/package/pip3_spec.rb +3 -6
  89. data/spec/unit/provider/package/pip_spec.rb +44 -72
  90. data/spec/unit/provider/package/pkgin_spec.rb +13 -18
  91. data/spec/unit/provider/package/pkgng_spec.rb +21 -24
  92. data/spec/unit/provider/package/puppet_gem_spec.rb +6 -9
  93. data/spec/unit/provider/package/tdnf_spec.rb +9 -12
  94. data/spec/unit/provider/package/yum_spec.rb +29 -15
  95. data/spec/unit/provider/package/zypper_spec.rb +17 -19
  96. data/spec/unit/provider/service/bsd_spec.rb +8 -12
  97. data/spec/unit/provider/service/daemontools_spec.rb +12 -20
  98. data/spec/unit/provider/service/debian_spec.rb +8 -16
  99. data/spec/unit/provider/service/freebsd_spec.rb +2 -5
  100. data/spec/unit/provider/service/openbsd_spec.rb +12 -18
  101. data/spec/unit/provider/service/rcng_spec.rb +3 -7
  102. data/spec/unit/provider/service/redhat_spec.rb +21 -23
  103. data/spec/unit/provider/service/runit_spec.rb +9 -19
  104. data/spec/unit/provider/service/smf_spec.rb +82 -21
  105. data/spec/unit/provider/service/src_spec.rb +14 -23
  106. data/spec/unit/provider/user/hpux_spec.rb +2 -5
  107. data/spec/unit/provider/user/ldap_spec.rb +29 -32
  108. data/spec/unit/provider/user/pw_spec.rb +10 -13
  109. data/spec/unit/ssl/key_spec.rb +2 -4
  110. data/spec/unit/transaction/event_manager_spec.rb +12 -1
  111. data/spec/unit/transaction/resource_harness_spec.rb +18 -0
  112. data/spec/unit/transaction_spec.rb +25 -0
  113. data/spec/unit/util/filetype_spec.rb +13 -5
  114. data/spec/unit/util/logging_spec.rb +0 -41
  115. data/spec/unit/util/monkey_patches_spec.rb +18 -5
  116. data/spec/unit/util/selinux_spec.rb +4 -0
  117. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32bd704ec12c9b090ed9beb7ad4e5bf6892224adebee36578a43d84a6fc5a378
4
- data.tar.gz: 300d5a99b06571c6fb8739ba1a111a868f0224bec29bbea22be8802bf202c6e2
3
+ metadata.gz: c5ffb8dc939e0e88b86df276d2041a548f2a012c4f2ae2f55908e853160edd48
4
+ data.tar.gz: defb8a5850d26e0978d1a9f5e7b59e1387fb1cf994afe0ef73d68d573ca6d55b
5
5
  SHA512:
6
- metadata.gz: 02df788b21ae421cd532aa0183e54a463dbad017fc849a427d77abce6800a2aedd6d0ffa36d06d83ca1a63ff2159ac33a9dbe36601694a489780425561fe42a9
7
- data.tar.gz: 19175679dfb8d0199b157cf3919dcba6506e0cbb9bacd6c2eb71640d34e9b9054382155859b49c140476e717ffa0fcb71d99022ac9816b178f6d7b8c581e4e9a
6
+ metadata.gz: 8d175aa43077faaede083b6ec75fb7b2a6e38a4a9bd83e23629bc746791f9a87ae118815c126a1b7b919e140271b009c4bd25f6abe3064a9d4315a7aee431c77
7
+ data.tar.gz: 26107cd0641e0873c60882bbb527b7f5c78116f8e64355cf288dc1a38b21763d414216b9509b576838aab44d290c85143a0baf48b4dd5ab12c1f3df77f42f5fc
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- puppet (5.5.8)
4
+ puppet (5.5.10)
5
5
  CFPropertyList (~> 2.2)
6
- facter (>= 2.0.1, < 4)
6
+ facter (>= 2.4.0, < 4)
7
7
  fast_gettext (~> 1.1.2)
8
8
  hiera (>= 3.2.1, < 4)
9
9
  hocon (~> 1.0)
@@ -32,8 +32,8 @@ GEM
32
32
  fast_gettext (~> 1.1.0)
33
33
  gettext (>= 3.0.2)
34
34
  locale
35
- hashdiff (0.3.7)
36
- hiera (3.4.5.13)
35
+ hashdiff (0.3.8)
36
+ hiera (3.5.0)
37
37
  hiera-eyaml (2.1.0)
38
38
  highline (~> 1.6.19)
39
39
  trollop (~> 2.0)
@@ -45,21 +45,21 @@ GEM
45
45
  locale (2.1.2)
46
46
  memory_profiler (0.9.12)
47
47
  metaclass (0.0.4)
48
- method_source (0.9.0)
48
+ method_source (0.9.2)
49
49
  mocha (0.10.5)
50
50
  metaclass (~> 0.0.1)
51
- msgpack (1.2.4)
51
+ msgpack (1.2.6)
52
52
  multi_json (1.13.1)
53
53
  mustache (1.1.0)
54
54
  net-ssh (4.2.0)
55
- packaging (0.99.16)
56
- artifactory
55
+ packaging (0.99.21)
56
+ artifactory (~> 2)
57
57
  rake (~> 12.3)
58
58
  parallel (1.12.1)
59
- parser (2.5.1.2)
59
+ parser (2.5.3.0)
60
60
  ast (~> 2.4.0)
61
61
  powerpack (0.1.2)
62
- pry (0.11.3)
62
+ pry (0.12.2)
63
63
  coderay (~> 1.1.0)
64
64
  method_source (~> 0.9.0)
65
65
  puppet-lint (2.3.6)
@@ -72,9 +72,9 @@ GEM
72
72
  rake
73
73
  rspec-puppet
74
74
  racc (1.4.9)
75
- rack (1.6.10)
75
+ rack (1.6.11)
76
76
  rainbow (2.1.0)
77
- rake (12.3.1)
77
+ rake (12.3.2)
78
78
  rdiscount (2.2.0.1)
79
79
  rdoc (4.3.0)
80
80
  redcarpet (2.3.0)
@@ -101,7 +101,7 @@ GEM
101
101
  rspec-mocks (3.8.0)
102
102
  diff-lcs (>= 1.2.0, < 2.0)
103
103
  rspec-support (~> 3.8.0)
104
- rspec-puppet (2.7.1)
104
+ rspec-puppet (2.7.2)
105
105
  rspec
106
106
  rspec-support (3.8.0)
107
107
  rubocop (0.49.1)
@@ -118,7 +118,7 @@ GEM
118
118
  safe_yaml (1.0.4)
119
119
  text (1.3.1)
120
120
  trollop (2.9.9)
121
- unicode-display_width (1.4.0)
121
+ unicode-display_width (1.4.1)
122
122
  vcr (2.9.3)
123
123
  webmock (1.24.6)
124
124
  addressable (>= 2.3.6)
data/Rakefile CHANGED
@@ -103,7 +103,9 @@ task(:warnings) do
103
103
  puts "Checking modified files #{commit_range}"
104
104
  %x{git diff --diff-filter=ACM --name-only #{commit_range}}.each_line do |modified_file|
105
105
  modified_file.chomp!
106
- next unless File.extname(modified_file) == '.rb'
106
+ # Skip racc generated file as it can have many warnings that cannot be manually fixed
107
+ next if modified_file.end_with?("pops/parser/eparser.rb")
108
+ next if modified_file.start_with?('spec/fixtures/', 'acceptance/fixtures/') || File.extname(modified_file) != '.rb'
107
109
  puts modified_file
108
110
 
109
111
  stdout, stderr, _ = Open3.capture3("ruby -wc \"#{modified_file}\"")
@@ -12,7 +12,13 @@ exec_prefix=/opt/csw
12
12
  sysconfdir=/opt/csw/etc
13
13
  sbindir=/opt/csw/sbin
14
14
 
15
- pidfile=/var/run/puppetlabs/agent.pid
15
+ if [ -z $SMF_SYSVOL_FS ]; then
16
+ piddir=/var/run/puppetlabs
17
+ else
18
+ piddir=$SMF_SYSVOL_FS/puppetlabs
19
+ fi;
20
+
21
+ pidfile=$piddir/agent.pid
16
22
 
17
23
  case "$1" in
18
24
  start)
@@ -20,6 +26,7 @@ start)
20
26
  # Start daemons.
21
27
 
22
28
  printf "Starting Puppet client services:"
29
+ mkdir -p $piddir
23
30
 
24
31
  /opt/csw/sbin/puppetd
25
32
 
@@ -8,7 +8,13 @@ exec_prefix=/opt/csw
8
8
  sysconfdir=/opt/csw/etc
9
9
  sbindir=/opt/csw/sbin
10
10
 
11
- pidfile=/var/run/puppetlabs/master.pid
11
+ if [ -z $SMF_SYSVOL_FS ]; then
12
+ piddir=/var/run/puppetlabs
13
+ else
14
+ piddir=$SMF_SYSVOL_FS/puppetlabs
15
+ fi;
16
+
17
+ pidfile=$piddir/master.pid
12
18
 
13
19
  case "$1" in
14
20
  start)
@@ -16,6 +22,7 @@ start)
16
22
  # Start daemons.
17
23
 
18
24
  printf "Starting Puppet server services:"
25
+ mkdir -p $piddir
19
26
 
20
27
  /opt/csw/sbin/puppetmasterd
21
28
 
@@ -1,4 +1,5 @@
1
1
  require 'puppet/application'
2
+ require 'puppet/configurer'
2
3
  require 'puppet/util/network_device'
3
4
 
4
5
  class Puppet::Application::Device < Puppet::Application
@@ -53,6 +54,10 @@ class Puppet::Application::Device < Puppet::Application
53
54
  options[:detailed_exitcodes] = true
54
55
  end
55
56
 
57
+ option("--libdir LIBDIR") do |arg|
58
+ options[:libdir] = arg
59
+ end
60
+
56
61
  option("--apply MANIFEST") do |arg|
57
62
  options[:apply] = arg.to_s
58
63
  end
@@ -93,10 +98,11 @@ a scheduled task, or a similar tool.
93
98
 
94
99
  USAGE
95
100
  -----
96
- puppet device [-d|--debug] [--detailed-exitcodes] [--deviceconfig <file>]
97
- [-h|--help] [-l|--logdest syslog|<file>|console]
98
- [-v|--verbose] [-w|--waitforcert <seconds>] [-f|--facts]
99
- [-a|--apply <file>] [-r|--resource <type> [name]]
101
+ puppet device [-h|--help] [-v|--verbose] [-d|--debug]
102
+ [-l|--logdest syslog|<file>|console] [--detailed-exitcodes]
103
+ [--deviceconfig <file>] [-w|--waitforcert <seconds>]
104
+ [--libdir <directory>]
105
+ [-a|--apply <file>] [-f|--facts] [-r|--resource <type> [name]]
100
106
  [-t|--target <device>] [--user=<user>] [-V|--version]
101
107
 
102
108
 
@@ -135,9 +141,25 @@ Note that any setting that's valid in the configuration file is also a valid
135
141
  long argument. For example, 'server' is a valid configuration parameter, so
136
142
  you can specify '--server <servername>' as an argument.
137
143
 
138
- * --debug:
144
+ * --help, -h:
145
+ Print this help message
146
+
147
+ * --verbose, -v:
148
+ Turn on verbose reporting.
149
+
150
+ * --debug, -d:
139
151
  Enable full debugging.
140
152
 
153
+ * --logdest, -l:
154
+ Where to send log messages. Choose between 'syslog' (the POSIX syslog
155
+ service), 'console', or the path to a log file. If debugging or verbosity is
156
+ enabled, this defaults to 'console'. Otherwise, it defaults to 'syslog'.
157
+
158
+ A path ending with '.json' will receive structured output in JSON format. The
159
+ log file will not have an ending ']' automatically written to it due to the
160
+ appending nature of logging. It must be appended manually to make the content
161
+ valid JSON.
162
+
141
163
  * --detailed-exitcodes:
142
164
  Provide transaction information via exit codes. If this is enabled, an exit
143
165
  code of '1' means at least one device had a compile failure, an exit code of
@@ -149,18 +171,16 @@ you can specify '--server <servername>' as an argument.
149
171
  Path to the device config file for puppet device.
150
172
  Default: $confdir/device.conf
151
173
 
152
- * --help:
153
- Print this help message
174
+ * --waitforcert, -w:
175
+ This option only matters for targets that do not yet have certificates
176
+ and it is enabled by default, with a value of 120 (seconds). This causes
177
+ +puppet device+ to poll the server every 2 minutes and ask it to sign a
178
+ certificate request. This is useful for the initial setup of a target.
179
+ You can turn off waiting for certificates by specifying a time of 0.
154
180
 
155
- * --logdest:
156
- Where to send log messages. Choose between 'syslog' (the POSIX syslog
157
- service), 'console', or the path to a log file. If debugging or verbosity is
158
- enabled, this defaults to 'console'. Otherwise, it defaults to 'syslog'.
159
-
160
- A path ending with '.json' will receive structured output in JSON format. The
161
- log file will not have an ending ']' automatically written to it due to the
162
- appending nature of logging. It must be appended manually to make the content
163
- valid JSON.
181
+ * --libdir:
182
+ Override the per-device libdir with a local directory. Specifying a libdir also
183
+ disables pluginsync. This is useful for testing.
164
184
 
165
185
  * --apply:
166
186
  Apply a manifest against a remote target. Target must be specified.
@@ -183,16 +203,6 @@ you can specify '--server <servername>' as an argument.
183
203
  * --user:
184
204
  The user to run as.
185
205
 
186
- * --verbose:
187
- Turn on verbose reporting.
188
-
189
- * --waitforcert:
190
- This option only matters for daemons that do not yet have certificates
191
- and it is enabled by default, with a value of 120 (seconds). This causes
192
- +puppet agent+ to connect to the server every 2 minutes and ask it to sign a
193
- certificate request. This is useful for the initial setup of a puppet
194
- client. You can turn off waiting for certificates by specifying a time of 0.
195
-
196
206
 
197
207
  EXAMPLE
198
208
  -------
@@ -205,7 +215,7 @@ Brice Figureau
205
215
 
206
216
  COPYRIGHT
207
217
  ---------
208
- Copyright (c) 2011 Puppet Inc., LLC
218
+ Copyright (c) 2011-2018 Puppet Inc., LLC
209
219
  Licensed under the Apache 2.0 License
210
220
  HELP
211
221
  end
@@ -222,11 +232,12 @@ Licensed under the Apache 2.0 License
222
232
  raise _("missing argument: --target is required when using --apply") if options[:target].nil?
223
233
  raise _("%{file} does not exist, cannot apply") % { file: options[:apply] } unless File.file?(options[:apply])
224
234
  end
235
+ libdir = Puppet[:libdir]
225
236
  vardir = Puppet[:vardir]
226
237
  confdir = Puppet[:confdir]
227
238
  certname = Puppet[:certname]
228
239
 
229
- env = Puppet.lookup(:environments).get(Puppet[:environment])
240
+ env = Puppet::Node::Environment.remote(Puppet[:environment])
230
241
  returns = Puppet.override(:current_environment => env, :loaders => Puppet::Pops::Loaders.new(env)) do
231
242
  # find device list
232
243
  require 'puppet/util/network_device/config'
@@ -251,9 +262,13 @@ Licensed under the Apache 2.0 License
251
262
 
252
263
  # override local $vardir and $certname
253
264
  Puppet[:confdir] = ::File.join(Puppet[:devicedir], device.name)
265
+ Puppet[:libdir] = options[:libdir] || ::File.join(Puppet[:devicedir], device.name, 'lib')
254
266
  Puppet[:vardir] = ::File.join(Puppet[:devicedir], device.name)
255
267
  Puppet[:certname] = device.name
256
268
 
269
+ unless options[:resource] || options[:facts] || options[:apply] || options[:libdir]
270
+ Puppet::Configurer::PluginHandler.new.download_plugins(env)
271
+ end
257
272
  # this init the device singleton, so that the facts terminus
258
273
  # and the various network_device provider can use it
259
274
  Puppet::Util::NetworkDevice.init(device)
@@ -309,13 +324,14 @@ Licensed under the Apache 2.0 License
309
324
 
310
325
  require 'puppet/configurer'
311
326
  configurer = Puppet::Configurer.new
312
- configurer.run(:network_device => true, :pluginsync => Puppet::Configurer.should_pluginsync?)
327
+ configurer.run(:network_device => true, :pluginsync => Puppet::Configurer.should_pluginsync? && !options[:libdir])
313
328
  end
314
329
  rescue => detail
315
330
  Puppet.log_exception(detail)
316
331
  # If we rescued an error, then we return 1 as the exit code
317
332
  1
318
333
  ensure
334
+ Puppet[:libdir] = libdir
319
335
  Puppet[:vardir] = vardir
320
336
  Puppet[:confdir] = confdir
321
337
  Puppet[:certname] = certname
@@ -35,7 +35,7 @@ Puppet::Face.define(:config, '0.0.1') do
35
35
 
36
36
  action(:print) do
37
37
  summary _("Examine Puppet's current settings.")
38
- arguments _("(all | <setting> [<setting> ...]")
38
+ arguments _("all | <setting> [<setting> ...]")
39
39
  description <<-'EOT'
40
40
  Prints the value of a single setting or a list of settings.
41
41
 
@@ -17,6 +17,9 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
17
17
 
18
18
  USER_AGENT = "PMT/1.1.1 (v3; Net::HTTP)".freeze
19
19
 
20
+ # From https://forgeapi.puppet.com/#!/release/getReleases
21
+ MODULE_RELEASE_EXCLUSIONS=%w[readme changelog license uri module tags supported file_size downloads created_at updated_at deleted_at].join(',').freeze
22
+
20
23
  attr_reader :host, :repository
21
24
 
22
25
  def initialize(host = Puppet[:module_repository], strict_semver = true)
@@ -90,7 +93,7 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
90
93
  # @see SemanticPuppet::Dependency::Source#fetch
91
94
  def fetch(input)
92
95
  name = input.tr('/', '-')
93
- uri = "/v3/releases?module=#{name}&sort_by=version"
96
+ uri = "/v3/releases?module=#{name}&sort_by=version&exclude_fields=#{MODULE_RELEASE_EXCLUSIONS}"
94
97
  if Puppet[:module_groups]
95
98
  uri += "&module_groups=#{Puppet[:module_groups].gsub('+', ' ')}"
96
99
  end
@@ -51,7 +51,9 @@ class Puppet::Pops::Evaluator::Collectors::AbstractCollector
51
51
 
52
52
  objects.each do |res|
53
53
  unless @collected.include?(res.ref)
54
- newres = Puppet::Parser::Resource.new(res.type, res.title, @overrides)
54
+ t = res.type
55
+ t = Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type(scope, t)
56
+ newres = Puppet::Parser::Resource.new(t, res.title, @overrides)
55
57
  scope.compiler.add_override(newres)
56
58
  end
57
59
  end
@@ -65,9 +65,9 @@ module Types
65
65
  when String
66
66
  impl_class.parse(arg)
67
67
  when Integer
68
- arg == impl_class.new(arg * Time::NSECS_PER_SEC)
68
+ impl_class.new(arg * Time::NSECS_PER_SEC)
69
69
  when Float
70
- arg == (min ? -Float::INFINITY : Float::INFINITY) ? arg : impl_class.new(arg * Time::NSECS_PER_SEC)
70
+ impl_class.new(arg * Time::NSECS_PER_SEC)
71
71
  else
72
72
  raise ArgumentError, "Unable to create a #{impl_class.name} from a #{arg.class.name}" unless arg.nil? || arg == :default
73
73
  nil
@@ -484,8 +484,17 @@ class StringConverter
484
484
 
485
485
  value_type = TypeCalculator.infer_set(value)
486
486
  if string_formats.is_a?(String)
487
- # add the format given for the exact type
488
- string_formats = { value_type => string_formats }
487
+ # For Array and Hash, the format is given as a Hash where 'format' key is the format for the collection itself
488
+ if Puppet::Pops::Types::PArrayType::DEFAULT.assignable?(value_type)
489
+ # add the format given for the exact type
490
+ string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => {'format' => string_formats }}
491
+ elsif Puppet::Pops::Types::PHashType::DEFAULT.assignable?(value_type)
492
+ # add the format given for the exact type
493
+ string_formats = { Puppet::Pops::Types::PHashType::DEFAULT => {'format' => string_formats }}
494
+ else
495
+ # add the format given for the exact type
496
+ string_formats = { value_type => string_formats }
497
+ end
489
498
  end
490
499
 
491
500
  case string_formats
@@ -1,6 +1,6 @@
1
1
  require 'puppet/provider/parsedfile'
2
2
 
3
- Puppet::Type.type(:cron).provide(:crontab, :parent => Puppet::Provider::ParsedFile, :default_target => ENV["USER"] || "root") do
3
+ Puppet::Type.type(:cron).provide(:crontab, :parent => Puppet::Provider::ParsedFile, :default_target => ENV["USER"] || "root", :raise_prefetch_errors => true) do
4
4
  commands :crontab => "crontab"
5
5
 
6
6
  text_line :comment, :match => %r{^\s*#}, :post_parse => proc { |record|
@@ -4,6 +4,19 @@ class Puppet::Provider::Package::Windows
4
4
  class ExePackage < Puppet::Provider::Package::Windows::Package
5
5
  attr_reader :uninstall_string
6
6
 
7
+ # registry values to load under each product entry in
8
+ # HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
9
+ # for this provider
10
+ REG_VALUE_NAMES = [
11
+ 'DisplayVersion',
12
+ 'UninstallString',
13
+ 'ParentKeyName',
14
+ 'Security Update',
15
+ 'Update Rollup',
16
+ 'Hotfix',
17
+ 'WindowsInstaller',
18
+ ]
19
+
7
20
  # Return an instance of the package from the registry, or nil
8
21
  def self.from_registry(name, values)
9
22
  if valid?(name, values)
@@ -8,6 +8,14 @@ class Puppet::Provider::Package::Windows
8
8
  INSTALLSTATE_DEFAULT = 5 # product is installed for the current user
9
9
  INSTALLUILEVEL_NONE = 2 # completely silent installation
10
10
 
11
+ # registry values to load under each product entry in
12
+ # HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
13
+ # for this provider
14
+ REG_VALUE_NAMES = [
15
+ 'DisplayVersion',
16
+ 'WindowsInstaller'
17
+ ]
18
+
11
19
  # Get the COM installer object, it's in a separate method for testing
12
20
  def self.installer
13
21
  # REMIND: when does the COM release happen?
@@ -11,6 +11,14 @@ class Puppet::Provider::Package::Windows
11
11
 
12
12
  attr_reader :name, :version
13
13
 
14
+ REG_DISPLAY_VALUE_NAMES = [ 'DisplayName', 'QuietDisplayName' ]
15
+
16
+ def self.reg_value_names_to_load
17
+ REG_DISPLAY_VALUE_NAMES |
18
+ MsiPackage::REG_VALUE_NAMES |
19
+ ExePackage::REG_VALUE_NAMES
20
+ end
21
+
14
22
  # Enumerate each package. The appropriate package subclass
15
23
  # will be yielded.
16
24
  def self.each(&block)
@@ -37,7 +45,7 @@ class Puppet::Provider::Package::Windows
37
45
  open(hive, 'Software\Microsoft\Windows\CurrentVersion\Uninstall', mode) do |uninstall|
38
46
  each_key(uninstall) do |name, wtime|
39
47
  open(hive, "#{uninstall.keyname}\\#{name}", mode) do |key|
40
- yield key, values(key)
48
+ yield key, values_by_name(key, reg_value_names_to_load)
41
49
  end
42
50
  end
43
51
  end
@@ -10,11 +10,17 @@ require 'puppet/util/fileparsing'
10
10
  #
11
11
  # Once the provider prefetches the data, it's the resource's job to copy
12
12
  # that data over to the @is variables.
13
+ #
14
+ # NOTE: The prefetch method swallows FileReadErrors by treating the
15
+ # corresponding target as an empty file. If you would like to turn this
16
+ # behavior off, then set the raise_prefetch_errors class variable to
17
+ # true. Doing so will error all resources associated with the failed
18
+ # target.
13
19
  class Puppet::Provider::ParsedFile < Puppet::Provider
14
20
  extend Puppet::Util::FileParsing
15
21
 
16
22
  class << self
17
- attr_accessor :default_target, :target
23
+ attr_accessor :default_target, :target, :raise_prefetch_errors
18
24
  end
19
25
 
20
26
  attr_accessor :property_hash
@@ -89,6 +95,10 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
89
95
 
90
96
  # Flush all of the records relating to a specific target.
91
97
  def self.flush_target(target)
98
+ if @raise_prefetch_errors && @failed_prefetch_targets.key?(target)
99
+ raise Puppet::Error, _("Failed to read %{target}'s records when prefetching them. Reason: %{detail}") % { target: target, detail: @failed_prefetch_targets[target] }
100
+ end
101
+
92
102
  backup_target(target)
93
103
 
94
104
  records = target_records(target).reject { |r|
@@ -142,6 +152,10 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
142
152
  @records = []
143
153
  @target_objects = {}
144
154
 
155
+ # Hash of <target> => <failure reason>.
156
+ @failed_prefetch_targets = {}
157
+ @raise_prefetch_errors = false
158
+
145
159
  @target = nil
146
160
 
147
161
  # Default to flat files
@@ -260,12 +274,19 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
260
274
 
261
275
  # Prefetch an individual target.
262
276
  def self.prefetch_target(target)
263
-
264
277
  begin
265
278
  target_records = retrieve(target)
266
279
  rescue Puppet::Util::FileType::FileReadError => detail
267
- puts detail.backtrace if Puppet[:trace]
268
- Puppet.err _("Could not prefetch %{resource} provider '%{name}' target '%{target}': %{detail}. Treating as empty") % { resource: self.resource_type.name, name: self.name, target: target, detail: detail }
280
+ if @raise_prefetch_errors
281
+ # We will raise an error later in flush_target. This way,
282
+ # only the resources linked to our target will fail
283
+ # evaluation.
284
+ @failed_prefetch_targets[target] = detail.to_s
285
+ else
286
+ puts detail.backtrace if Puppet[:trace]
287
+ Puppet.err _("Could not prefetch %{resource} provider '%{name}' target '%{target}': %{detail}. Treating as empty") % { resource: self.resource_type.name, name: self.name, target: target, detail: detail }
288
+ end
289
+
269
290
  target_records = []
270
291
  end
271
292