puppet 6.4.5-x64-mingw32 → 6.5.0-x64-mingw32

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 (329) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +10 -10
  3. data/Gemfile +6 -6
  4. data/Gemfile.lock +46 -52
  5. data/ext/build_defaults.yaml +0 -1
  6. data/ext/project_data.yaml +3 -3
  7. data/ext/regexp_nodes/regexp_nodes.rb +4 -4
  8. data/ext/solaris/smf/puppet.xml +0 -2
  9. data/ext/windows/eventlog/Rakefile +32 -0
  10. data/ext/windows/eventlog/puppetres.dll +0 -0
  11. data/ext/windows/eventlog/puppetres.mc +18 -0
  12. data/ext/windows/service/daemon.rb +8 -38
  13. data/install.rb +24 -6
  14. data/lib/puppet.rb +3 -1
  15. data/lib/puppet/application.rb +1 -1
  16. data/lib/puppet/application/agent.rb +11 -34
  17. data/lib/puppet/application/apply.rb +6 -6
  18. data/lib/puppet/application/describe.rb +9 -3
  19. data/lib/puppet/application/device.rb +4 -14
  20. data/lib/puppet/application/doc.rb +1 -1
  21. data/lib/puppet/application/lookup.rb +2 -2
  22. data/lib/puppet/application/resource.rb +4 -4
  23. data/lib/puppet/application/script.rb +2 -2
  24. data/lib/puppet/application/ssl.rb +10 -9
  25. data/lib/puppet/configurer.rb +30 -86
  26. data/lib/puppet/configurer/downloader.rb +6 -2
  27. data/lib/puppet/defaults.rb +50 -44
  28. data/lib/puppet/error.rb +14 -9
  29. data/lib/puppet/face/catalog.rb +20 -1
  30. data/lib/puppet/face/config.rb +48 -10
  31. data/lib/puppet/face/facts.rb +1 -1
  32. data/lib/puppet/face/help.rb +1 -1
  33. data/lib/puppet/face/module/list.rb +5 -5
  34. data/lib/puppet/face/module/search.rb +1 -1
  35. data/lib/puppet/face/module/uninstall.rb +1 -1
  36. data/lib/puppet/face/module/upgrade.rb +1 -1
  37. data/lib/puppet/face/parser.rb +48 -9
  38. data/lib/puppet/face/plugin.rb +2 -9
  39. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  40. data/lib/puppet/file_system.rb +12 -2
  41. data/lib/puppet/file_system/file_impl.rb +6 -3
  42. data/lib/puppet/file_system/memory_file.rb +1 -1
  43. data/lib/puppet/file_system/posix.rb +2 -3
  44. data/lib/puppet/forge.rb +3 -3
  45. data/lib/puppet/functions.rb +2 -1
  46. data/lib/puppet/functions/camelcase.rb +2 -2
  47. data/lib/puppet/functions/epp.rb +4 -4
  48. data/lib/puppet/functions/find_file.rb +9 -9
  49. data/lib/puppet/functions/inline_epp.rb +5 -5
  50. data/lib/puppet/functions/regsubst.rb +6 -8
  51. data/lib/puppet/gettext/module_translations.rb +1 -1
  52. data/lib/puppet/graph/rb_tree_map.rb +2 -2
  53. data/lib/puppet/graph/simple_graph.rb +3 -4
  54. data/lib/puppet/indirector/catalog/compiler.rb +5 -11
  55. data/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
  56. data/lib/puppet/indirector/hiera.rb +0 -2
  57. data/lib/puppet/indirector/resource/ral.rb +3 -1
  58. data/lib/puppet/indirector/resource/validator.rb +1 -1
  59. data/lib/puppet/interface.rb +1 -2
  60. data/lib/puppet/loaders.rb +1 -0
  61. data/lib/puppet/metatype/manager.rb +1 -1
  62. data/lib/puppet/module.rb +1 -1
  63. data/lib/puppet/module/task.rb +4 -20
  64. data/lib/puppet/module_tool/applications/installer.rb +1 -1
  65. data/lib/puppet/module_tool/applications/uninstaller.rb +3 -3
  66. data/lib/puppet/module_tool/metadata.rb +1 -1
  67. data/lib/puppet/module_tool/shared_behaviors.rb +4 -4
  68. data/lib/puppet/module_tool/tar/mini.rb +2 -12
  69. data/lib/puppet/network/http/api/indirected_routes.rb +11 -12
  70. data/lib/puppet/network/http/connection.rb +12 -10
  71. data/lib/puppet/network/http/factory.rb +11 -1
  72. data/lib/puppet/network/http/pool.rb +0 -2
  73. data/lib/puppet/network/http/site.rb +1 -1
  74. data/lib/puppet/network/resolver.rb +2 -2
  75. data/lib/puppet/node/environment.rb +2 -4
  76. data/lib/puppet/pal/pal_impl.rb +2 -2
  77. data/lib/puppet/parser/ast.rb +1 -1
  78. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  79. data/lib/puppet/parser/functions.rb +1 -1
  80. data/lib/puppet/parser/functions/epp.rb +3 -3
  81. data/lib/puppet/parser/functions/fail.rb +8 -1
  82. data/lib/puppet/parser/functions/inline_epp.rb +5 -5
  83. data/lib/puppet/parser/scope.rb +7 -8
  84. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +1 -1
  85. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
  86. data/lib/puppet/pops/evaluator/external_syntax_support.rb +2 -3
  87. data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
  88. data/lib/puppet/pops/loader/null_loader.rb +60 -0
  89. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +6 -4
  90. data/lib/puppet/pops/loader/task_instantiator.rb +0 -4
  91. data/lib/puppet/pops/loaders.rb +1 -1
  92. data/lib/puppet/pops/lookup/hiera_config.rb +0 -1
  93. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  94. data/lib/puppet/pops/merge_strategy.rb +18 -22
  95. data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  96. data/lib/puppet/pops/parser/interpolation_support.rb +4 -4
  97. data/lib/puppet/pops/parser/locator.rb +1 -1
  98. data/lib/puppet/pops/parser/pn_parser.rb +16 -17
  99. data/lib/puppet/pops/puppet_stack.rb +49 -51
  100. data/lib/puppet/pops/types/p_sensitive_type.rb +1 -1
  101. data/lib/puppet/pops/types/string_converter.rb +10 -10
  102. data/lib/puppet/pops/types/types.rb +6 -5
  103. data/lib/puppet/property.rb +1 -1
  104. data/lib/puppet/property/ensure.rb +1 -1
  105. data/lib/puppet/provider/exec.rb +2 -6
  106. data/lib/puppet/provider/file/posix.rb +0 -5
  107. data/lib/puppet/provider/nameservice.rb +3 -10
  108. data/lib/puppet/provider/nameservice/directoryservice.rb +1 -1
  109. data/lib/puppet/provider/nameservice/pw.rb +2 -2
  110. data/lib/puppet/provider/package.rb +0 -2
  111. data/lib/puppet/provider/package/apt.rb +1 -5
  112. data/lib/puppet/provider/package/dnf.rb +1 -1
  113. data/lib/puppet/provider/package/dpkg.rb +18 -34
  114. data/lib/puppet/provider/package/openbsd.rb +1 -1
  115. data/lib/puppet/provider/package/pip.rb +13 -37
  116. data/lib/puppet/provider/package/portage.rb +4 -4
  117. data/lib/puppet/provider/package/puppet_gem.rb +1 -1
  118. data/lib/puppet/provider/package/rpm.rb +18 -56
  119. data/lib/puppet/provider/package/windows/package.rb +1 -1
  120. data/lib/puppet/provider/package/yum.rb +5 -9
  121. data/lib/puppet/provider/package_targetable.rb +4 -7
  122. data/lib/puppet/provider/parsedfile.rb +1 -1
  123. data/lib/puppet/provider/service/daemontools.rb +9 -9
  124. data/lib/puppet/provider/service/launchd.rb +5 -20
  125. data/lib/puppet/provider/service/openbsd.rb +1 -1
  126. data/lib/puppet/provider/service/rcng.rb +2 -2
  127. data/lib/puppet/provider/service/runit.rb +8 -2
  128. data/lib/puppet/provider/service/systemd.rb +19 -14
  129. data/lib/puppet/provider/service/windows.rb +0 -8
  130. data/lib/puppet/provider/user/directoryservice.rb +1 -1
  131. data/lib/puppet/provider/user/hpux.rb +1 -1
  132. data/lib/puppet/provider/user/pw.rb +3 -12
  133. data/lib/puppet/provider/user/user_role_add.rb +1 -5
  134. data/lib/puppet/provider/user/useradd.rb +20 -45
  135. data/lib/puppet/provider/user/windows_adsi.rb +5 -4
  136. data/lib/puppet/reference/configuration.rb +3 -3
  137. data/lib/puppet/reference/indirection.rb +2 -2
  138. data/lib/puppet/reference/metaparameter.rb +3 -1
  139. data/lib/puppet/reference/providers.rb +3 -1
  140. data/lib/puppet/reference/type.rb +9 -3
  141. data/lib/puppet/reports.rb +1 -1
  142. data/lib/puppet/resource.rb +1 -18
  143. data/lib/puppet/resource/catalog.rb +1 -1
  144. data/lib/puppet/rest/routes.rb +30 -17
  145. data/lib/puppet/settings.rb +3 -43
  146. data/lib/puppet/settings/environment_conf.rb +0 -1
  147. data/lib/puppet/ssl/certificate_request.rb +12 -2
  148. data/lib/puppet/ssl/host.rb +2 -2
  149. data/lib/puppet/ssl/oids.rb +1 -1
  150. data/lib/puppet/ssl/ssl_provider.rb +11 -5
  151. data/lib/puppet/ssl/state_machine.rb +102 -98
  152. data/lib/puppet/test/test_helper.rb +1 -0
  153. data/lib/puppet/transaction.rb +11 -33
  154. data/lib/puppet/transaction/report.rb +1 -1
  155. data/lib/puppet/type.rb +4 -2
  156. data/lib/puppet/type/exec.rb +17 -23
  157. data/lib/puppet/type/file.rb +39 -11
  158. data/lib/puppet/type/file/data_sync.rb +1 -5
  159. data/lib/puppet/type/group.rb +2 -4
  160. data/lib/puppet/type/notify.rb +3 -4
  161. data/lib/puppet/type/package.rb +3 -20
  162. data/lib/puppet/type/schedule.rb +1 -1
  163. data/lib/puppet/type/service.rb +3 -8
  164. data/lib/puppet/type/user.rb +2 -4
  165. data/lib/puppet/util.rb +29 -39
  166. data/lib/puppet/util/command_line/trollop.rb +1 -1
  167. data/lib/puppet/util/execution.rb +3 -4
  168. data/lib/puppet/util/http_proxy.rb +19 -27
  169. data/lib/puppet/util/log.rb +2 -2
  170. data/lib/puppet/util/log/destinations.rb +2 -2
  171. data/lib/puppet/util/logging.rb +20 -32
  172. data/lib/puppet/util/metric.rb +2 -2
  173. data/lib/puppet/util/monkey_patches.rb +33 -0
  174. data/lib/puppet/util/pidlock.rb +2 -3
  175. data/lib/puppet/util/provider_features.rb +4 -2
  176. data/lib/puppet/util/rdoc.rb +1 -1
  177. data/lib/puppet/util/reference.rb +1 -1
  178. data/lib/puppet/util/resource_template.rb +1 -1
  179. data/lib/puppet/util/selinux.rb +2 -8
  180. data/lib/puppet/util/skip_tags.rb +4 -0
  181. data/lib/puppet/util/windows/adsi.rb +18 -48
  182. data/lib/puppet/util/windows/process.rb +8 -8
  183. data/lib/puppet/util/windows/registry.rb +5 -7
  184. data/lib/puppet/util/windows/security.rb +0 -2
  185. data/lib/puppet/util/windows/service.rb +4 -149
  186. data/lib/puppet/util/windows/sid.rb +0 -1
  187. data/lib/puppet/vendor.rb +1 -1
  188. data/lib/puppet/version.rb +1 -1
  189. data/lib/puppet/x509/cert_provider.rb +81 -24
  190. data/locales/puppet.pot +462 -482
  191. data/man/man5/puppet.conf.5 +43 -44
  192. data/man/man8/puppet-agent.8 +1 -1
  193. data/man/man8/puppet-apply.8 +3 -3
  194. data/man/man8/puppet-catalog.8 +31 -3
  195. data/man/man8/puppet-config.8 +1 -1
  196. data/man/man8/puppet-describe.8 +1 -1
  197. data/man/man8/puppet-device.8 +1 -1
  198. data/man/man8/puppet-doc.8 +1 -1
  199. data/man/man8/puppet-epp.8 +1 -1
  200. data/man/man8/puppet-facts.8 +1 -1
  201. data/man/man8/puppet-filebucket.8 +1 -1
  202. data/man/man8/puppet-generate.8 +1 -1
  203. data/man/man8/puppet-help.8 +1 -1
  204. data/man/man8/puppet-key.8 +1 -1
  205. data/man/man8/puppet-lookup.8 +1 -1
  206. data/man/man8/puppet-man.8 +1 -1
  207. data/man/man8/puppet-module.8 +1 -1
  208. data/man/man8/puppet-node.8 +1 -1
  209. data/man/man8/puppet-parser.8 +1 -1
  210. data/man/man8/puppet-plugin.8 +1 -1
  211. data/man/man8/puppet-report.8 +1 -1
  212. data/man/man8/puppet-resource.8 +1 -1
  213. data/man/man8/puppet-script.8 +1 -1
  214. data/man/man8/puppet-ssl.8 +1 -1
  215. data/man/man8/puppet-status.8 +1 -1
  216. data/man/man8/puppet.8 +3 -3
  217. data/spec/fixtures/ssl/127.0.0.1-key.pem +56 -56
  218. data/spec/fixtures/ssl/127.0.0.1.pem +27 -27
  219. data/spec/fixtures/ssl/bad-basic-constraints.pem +32 -32
  220. data/spec/fixtures/ssl/bad-int-basic-constraints.pem +30 -30
  221. data/spec/fixtures/ssl/ca.pem +30 -30
  222. data/spec/fixtures/ssl/crl.pem +15 -15
  223. data/spec/fixtures/ssl/ec-key.pem +18 -0
  224. data/spec/fixtures/ssl/ec.pem +40 -0
  225. data/spec/fixtures/ssl/encrypted-ec-key.pem +21 -0
  226. data/spec/fixtures/ssl/encrypted-key.pem +57 -57
  227. data/spec/fixtures/ssl/intermediate-agent-crl.pem +16 -16
  228. data/spec/fixtures/ssl/intermediate-agent.pem +33 -33
  229. data/spec/fixtures/ssl/intermediate-crl.pem +17 -17
  230. data/spec/fixtures/ssl/intermediate.pem +31 -31
  231. data/spec/fixtures/ssl/pluto-key.pem +56 -56
  232. data/spec/fixtures/ssl/pluto.pem +28 -28
  233. data/spec/fixtures/ssl/request-key.pem +56 -56
  234. data/spec/fixtures/ssl/request.pem +24 -24
  235. data/spec/fixtures/ssl/revoked-key.pem +56 -56
  236. data/spec/fixtures/ssl/revoked.pem +25 -25
  237. data/spec/fixtures/ssl/signed-key.pem +56 -56
  238. data/spec/fixtures/ssl/signed.pem +25 -25
  239. data/spec/fixtures/ssl/tampered-cert.pem +27 -27
  240. data/spec/fixtures/ssl/tampered-csr.pem +24 -24
  241. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/func_with_syntax_error.rb +9 -0
  242. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
  243. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
  244. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
  245. data/spec/integration/configurer_spec.rb +0 -52
  246. data/spec/integration/provider/service/init_spec.rb +1 -0
  247. data/spec/integration/provider/service/systemd_spec.rb +5 -8
  248. data/spec/integration/type/file_spec.rb +38 -28
  249. data/spec/integration/util/execution_spec.rb +0 -27
  250. data/spec/lib/puppet/certificate_factory.rb +2 -2
  251. data/spec/lib/puppet/test_ca.rb +17 -4
  252. data/spec/lib/puppet_spec/fixtures.rb +4 -0
  253. data/spec/spec_helper.rb +0 -28
  254. data/spec/unit/application/agent_spec.rb +34 -67
  255. data/spec/unit/application/device_spec.rb +1 -27
  256. data/spec/unit/application/ssl_spec.rb +60 -35
  257. data/spec/unit/configurer_spec.rb +399 -395
  258. data/spec/unit/defaults_spec.rb +4 -4
  259. data/spec/unit/face/facts_spec.rb +0 -9
  260. data/spec/unit/face/parser_spec.rb +69 -22
  261. data/spec/unit/face/plugin_spec.rb +0 -8
  262. data/spec/unit/file_system_spec.rb +30 -1
  263. data/spec/unit/forge/forge_spec.rb +3 -1
  264. data/spec/unit/forge/repository_spec.rb +3 -1
  265. data/spec/unit/indirector/catalog/compiler_spec.rb +5 -62
  266. data/spec/unit/indirector/resource/ral_spec.rb +4 -4
  267. data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
  268. data/spec/unit/network/http/api/indirected_routes_spec.rb +10 -25
  269. data/spec/unit/network/http/connection_spec.rb +145 -119
  270. data/spec/unit/network/http/factory_spec.rb +5 -27
  271. data/spec/unit/parser/scope_spec.rb +0 -10
  272. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +3 -8
  273. data/spec/unit/pops/loaders/loaders_spec.rb +4 -0
  274. data/spec/unit/pops/loaders/module_loaders_spec.rb +0 -37
  275. data/spec/unit/pops/types/types_spec.rb +27 -0
  276. data/spec/unit/provider/exec_spec.rb +0 -209
  277. data/spec/unit/provider/package/aptrpm_spec.rb +1 -1
  278. data/spec/unit/provider/package/dnf_spec.rb +0 -7
  279. data/spec/unit/provider/package/dpkg_spec.rb +80 -240
  280. data/spec/unit/provider/package/pip_spec.rb +8 -61
  281. data/spec/unit/provider/package/portage_spec.rb +4 -4
  282. data/spec/unit/provider/package/rpm_spec.rb +16 -150
  283. data/spec/unit/provider/package/yum_spec.rb +0 -7
  284. data/spec/unit/provider/service/daemontools_spec.rb +0 -24
  285. data/spec/unit/provider/service/launchd_spec.rb +0 -28
  286. data/spec/unit/provider/service/runit_spec.rb +0 -24
  287. data/spec/unit/provider/service/systemd_spec.rb +25 -39
  288. data/spec/unit/provider/service/windows_spec.rb +0 -20
  289. data/spec/unit/provider/user/hpux_spec.rb +2 -2
  290. data/spec/unit/provider/user/pw_spec.rb +0 -37
  291. data/spec/unit/provider/user/useradd_spec.rb +0 -88
  292. data/spec/unit/resource_spec.rb +1 -26
  293. data/spec/unit/ssl/host_spec.rb +5 -0
  294. data/spec/unit/ssl/ssl_provider_spec.rb +36 -11
  295. data/spec/unit/ssl/state_machine_spec.rb +233 -158
  296. data/spec/unit/transaction_spec.rb +0 -64
  297. data/spec/unit/type/exec_spec.rb +12 -15
  298. data/spec/unit/type/file/content_spec.rb +3 -9
  299. data/spec/unit/type/file/source_spec.rb +4 -4
  300. data/spec/unit/type/file_spec.rb +15 -11
  301. data/spec/unit/type/package_spec.rb +0 -5
  302. data/spec/unit/type/schedule_spec.rb +1 -3
  303. data/spec/unit/type/service_spec.rb +0 -16
  304. data/spec/unit/util/execution_spec.rb +0 -16
  305. data/spec/unit/util/http_proxy_spec.rb +21 -151
  306. data/spec/unit/util/ldap/manager_spec.rb +0 -15
  307. data/spec/unit/util/log/destinations_spec.rb +3 -7
  308. data/spec/unit/util/log_spec.rb +138 -0
  309. data/spec/unit/util/logging_spec.rb +0 -200
  310. data/spec/unit/util/pidlock_spec.rb +0 -26
  311. data/spec/unit/util/skip_tags_spec.rb +14 -0
  312. data/spec/unit/util/windows/adsi_spec.rb +0 -51
  313. data/spec/unit/util/windows/service_spec.rb +0 -9
  314. data/spec/unit/util_spec.rb +10 -0
  315. data/spec/unit/x509/cert_provider_spec.rb +82 -43
  316. data/tasks/generate_cert_fixtures.rake +13 -1
  317. data/tasks/manpages.rake +0 -1
  318. metadata +28 -22
  319. data/ext/cert_inspector +0 -140
  320. data/ext/envpuppet +0 -139
  321. data/ext/envpuppet.bat +0 -14
  322. data/ext/puppet-test +0 -476
  323. data/ext/pure_ruby_dsl/dsl_test.rb +0 -7
  324. data/ext/upload_facts.rb +0 -119
  325. data/lib/puppet/provider/package/dnfmodule.rb +0 -87
  326. data/spec/fixtures/unit/provider/package/dnfmodule/dnf-module-list-installed.txt +0 -11
  327. data/spec/integration/type/notify_spec.rb +0 -46
  328. data/spec/unit/provider/package/dnfmodule_spec.rb +0 -186
  329. data/spec/unit/provider/package_targetable_spec.rb +0 -60
@@ -340,7 +340,7 @@ class PAnyType < TypedModelObject
340
340
  # @raises ArgumentError
341
341
  #
342
342
  def self.new_function(type)
343
- raise ArgumentError.new("Creation of new instance of type '#{type}' is not supported")
343
+ raise ArgumentError.new("Creation of new instance of type '#{type.to_s}' is not supported")
344
344
  end
345
345
 
346
346
  # Answers the question if instances of this type can represent themselves as a string that
@@ -1268,7 +1268,7 @@ class PFloatType < PNumericType
1268
1268
  else
1269
1269
  begin
1270
1270
  # support a binary as float
1271
- if from[0] == '0' && from[1].casecmp('b').zero?
1271
+ if from[0] == '0' && from[1].downcase == 'b'
1272
1272
  from = Integer(from)
1273
1273
  end
1274
1274
  Float(from)
@@ -1686,10 +1686,11 @@ class PRegexpType < PScalarType
1686
1686
  @new_function ||= Puppet::Functions.create_loaded_function(:new_float, type.loader) do
1687
1687
  dispatch :from_string do
1688
1688
  param 'String', :pattern
1689
+ optional_param 'Boolean', :escape
1689
1690
  end
1690
1691
 
1691
- def from_string(pattern)
1692
- Regexp.new(pattern)
1692
+ def from_string(pattern, escape = false)
1693
+ Regexp.new(escape ? Regexp.escape(pattern) : pattern)
1693
1694
  end
1694
1695
  end
1695
1696
  end
@@ -1699,7 +1700,7 @@ class PRegexpType < PScalarType
1699
1700
  # @param regexp [Regexp] the regular expression
1700
1701
  # @return [String] the Regexp as a slash delimited string with slashes escaped
1701
1702
  def self.regexp_to_s_with_delimiters(regexp)
1702
- regexp.options == 0 ? regexp.inspect : "/#{regexp}/"
1703
+ regexp.options == 0 ? regexp.inspect : "/#{regexp.to_s}/"
1703
1704
  end
1704
1705
 
1705
1706
  # @param regexp [Regexp] the regular expression
@@ -209,7 +209,7 @@ class Puppet::Property < Puppet::Parameter
209
209
  else
210
210
  return "#{name} changed #{is_to_s(current_value)} to #{should_to_s(newvalue)}"
211
211
  end
212
- rescue Puppet::Error
212
+ rescue Puppet::Error, Puppet::DevError
213
213
  raise
214
214
  rescue => detail
215
215
  message = _("Could not convert change '%{name}' to string: %{detail}") % { name: name, detail: detail }
@@ -56,7 +56,7 @@ class Puppet::Property::Ensure < Puppet::Property
56
56
  else
57
57
  return _('%{name} changed %{is} to %{should}') % { name: name, is: is_to_s(currentvalue), should: should_to_s(newvalue) }
58
58
  end
59
- rescue Puppet::Error
59
+ rescue Puppet::Error, Puppet::DevError
60
60
  raise
61
61
  rescue => detail
62
62
  raise Puppet::DevError, _("Could not convert change %{name} to string: %{detail}") % { name: self.name, detail: detail }, detail.backtrace
@@ -52,11 +52,7 @@ class Puppet::Provider::Exec < Puppet::Provider
52
52
  # This is backwards compatible all the way to Ruby 1.8.7.
53
53
  Timeout::timeout(resource[:timeout], Timeout::Error) do
54
54
  cwd = resource[:cwd]
55
- # It's ok if cwd is nil. In that case Puppet::Util::Execution.execute() simply will not attempt to
56
- # change the working directory, which is exactly the right behavior when no cwd parameter is
57
- # expressed on the resource. Moreover, attempting to change to the directory that is already
58
- # the working directory can fail under some circumstances, so avoiding the directory change attempt
59
- # is preferable to defaulting cwd to that directory.
55
+ cwd ||= Dir.pwd
60
56
 
61
57
  # note that we are passing "false" for the "override_locale" parameter, which ensures that the user's
62
58
  # default/system locale will be respected. Callers may override this behavior by setting locale-related
@@ -97,6 +93,6 @@ class Puppet::Provider::Exec < Puppet::Provider
97
93
  def validatecmd(command)
98
94
  exe = extractexe(command)
99
95
  # if we're not fully qualified, require a path
100
- self.fail _("'%{exe}' is not qualified and no path was specified. Please qualify the command or specify a path.") % { exe: exe } if !absolute_path?(exe) and resource[:path].nil?
96
+ self.fail _("'%{command}' is not qualified and no path was specified. Please qualify the command or specify a path.") % { command: command } if !absolute_path?(exe) and resource[:path].nil?
101
97
  end
102
98
  end
@@ -8,11 +8,6 @@ Puppet::Type.type(:file).provide :posix do
8
8
  include Puppet::Util::Warnings
9
9
 
10
10
  require 'etc'
11
- require 'puppet/util/selinux'
12
-
13
- def self.post_resource_eval
14
- Selinux.matchpathcon_fini if Puppet::Util::SELinux.selinux_support?
15
- end
16
11
 
17
12
  def uid2name(id)
18
13
  return id.to_s if id.is_a?(Symbol) or id.is_a?(String)
@@ -172,10 +172,9 @@ class Puppet::Provider::NameService < Puppet::Provider
172
172
  end
173
173
 
174
174
  begin
175
- sensitive = has_sensitive_data?
176
- execute(self.addcmd, {:failonfail => true, :combine => true, :custom_environment => @custom_environment, :sensitive => sensitive})
175
+ execute(self.addcmd, {:failonfail => true, :combine => true, :custom_environment => @custom_environment})
177
176
  if feature?(:manages_password_age) && (cmd = passcmd)
178
- execute(cmd, {:failonfail => true, :combine => true, :custom_environment => @custom_environment, :sensitive => sensitive})
177
+ execute(cmd, {:failonfail => true, :combine => true, :custom_environment => @custom_environment})
179
178
  end
180
179
  rescue Puppet::ExecutionFailure => detail
181
180
  raise Puppet::Error, _("Could not create %{resource} %{name}: %{detail}") % { resource: @resource.class.name, name: @resource.name, detail: detail }, detail.backtrace
@@ -277,19 +276,13 @@ class Puppet::Provider::NameService < Puppet::Provider
277
276
  self.class.validate(param, value)
278
277
  cmd = modifycmd(param, munge(param, value))
279
278
  raise Puppet::DevError, _("Nameservice command must be an array") unless cmd.is_a?(Array)
280
- sensitive = has_sensitive_data?(param)
281
279
  begin
282
- execute(cmd, {:failonfail => true, :combine => true, :custom_environment => @custom_environment, :sensitive => sensitive})
280
+ execute(cmd, {:failonfail => true, :combine => true, :custom_environment => @custom_environment})
283
281
  rescue Puppet::ExecutionFailure => detail
284
282
  raise Puppet::Error, _("Could not set %{param} on %{resource}[%{name}]: %{detail}") % { param: param, resource: @resource.class.name, name: @resource.name, detail: detail }, detail.backtrace
285
283
  end
286
284
  end
287
285
 
288
- #Derived classes can override to declare sensitive data so a flag can be passed to execute
289
- def has_sensitive_data?(property = nil)
290
- false
291
- end
292
-
293
286
  # From overriding Puppet::Property#insync? Ruby Etc::getpwnam < 2.1.0 always
294
287
  # returns a struct with binary encoded string values, and >= 2.1.0 will return
295
288
  # binary encoded strings for values incompatible with current locale charset,
@@ -289,7 +289,7 @@ class Puppet::Provider::NameService::DirectoryService < Puppet::Provider::NameSe
289
289
  end
290
290
  dscl_out = dscl(dscl_args)
291
291
  # We're ok with throwing away negative uids here.
292
- ids = dscl_out.split.compact.collect { |l| l.to_i if l =~ /^\d+$/ }
292
+ ids = dscl_out.split.compact.collect { |l| l.to_i if l.match(/^\d+$/) }
293
293
  ids.compact!.sort! { |a,b| a.to_f <=> b.to_f }
294
294
  # We're just looking for an unused id in our sorted array.
295
295
  ids.each_index do |i|
@@ -3,13 +3,13 @@ require 'puppet/provider/nameservice/objectadd'
3
3
  class Puppet::Provider::NameService
4
4
  class PW < ObjectAdd
5
5
  def deletecmd
6
- [command(:pw), "#{@resource.class.name}del", @resource[:name]]
6
+ [command(:pw), "#{@resource.class.name.to_s}del", @resource[:name]]
7
7
  end
8
8
 
9
9
  def modifycmd(param, value)
10
10
  cmd = [
11
11
  command(:pw),
12
- "#{@resource.class.name}mod",
12
+ "#{@resource.class.name.to_s}mod",
13
13
  @resource[:name],
14
14
  flag(param),
15
15
  munge(param, value)
@@ -1,5 +1,3 @@
1
- require 'puppet/provider'
2
-
3
1
  class Puppet::Provider::Package < Puppet::Provider
4
2
  # Prefetch our package list, yo.
5
3
  def self.prefetch(packages)
@@ -8,7 +8,7 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do
8
8
  These options should be specified as an array where each element is either a
9
9
  string or a hash."
10
10
 
11
- has_feature :versionable, :install_options, :virtual_packages
11
+ has_feature :versionable, :install_options
12
12
 
13
13
  commands :aptget => "/usr/bin/apt-get"
14
14
  commands :aptcache => "/usr/bin/apt-cache"
@@ -22,10 +22,6 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do
22
22
  ENV['APT_LISTBUGS_FRONTEND'] = "none"
23
23
  ENV['APT_LISTCHANGES_FRONTEND'] = "none"
24
24
 
25
- def self.defaultto_allow_virtual
26
- false
27
- end
28
-
29
25
  # A derivative of DPKG; this is how most people actually manage
30
26
  # Debian boxes, and the only thing that differs is that it can
31
27
  # install packages from remote sites.
@@ -9,7 +9,7 @@ Puppet::Type.type(:package).provide :dnf, :parent => :yum do
9
9
  These options should be specified as an array where each element is either
10
10
  a string or a hash."
11
11
 
12
- has_feature :install_options, :versionable, :virtual_packages, :install_only
12
+ has_feature :install_options, :versionable, :virtual_packages
13
13
 
14
14
  commands :cmd => "dnf", :rpm => "rpm"
15
15
 
@@ -5,7 +5,8 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
5
5
  and not `apt`, you must specify the source of any packages you want
6
6
  to manage."
7
7
 
8
- has_feature :holdable, :virtual_packages
8
+ has_feature :holdable
9
+
9
10
  commands :dpkg => "/usr/bin/dpkg"
10
11
  commands :dpkg_deb => "/usr/bin/dpkg-deb"
11
12
  commands :dpkgquery => "/usr/bin/dpkg-query"
@@ -43,23 +44,16 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
43
44
  # Note: self:: is required here to keep these constants in the context of what will
44
45
  # eventually become this Puppet::Type::Package::ProviderDpkg class.
45
46
  self::DPKG_QUERY_FORMAT_STRING = %Q{'${Status} ${Package} ${Version}\\n'}
46
- self::DPKG_QUERY_PROVIDES_FORMAT_STRING = %Q{'${Status} ${Package} ${Version} [${Provides}]\\n'}
47
47
  self::FIELDS_REGEX = %r{^(\S+) +(\S+) +(\S+) (\S+) (\S*)$}
48
- self::FIELDS_REGEX_WITH_PROVIDES = %r{^(\S+) +(\S+) +(\S+) (\S+) (\S*) \[.*\]$}
49
48
  self::FIELDS= [:desired, :error, :status, :name, :ensure]
50
49
 
51
- def self.defaultto_allow_virtual
52
- false
53
- end
54
-
55
50
  # @param line [String] one line of dpkg-query output
56
51
  # @return [Hash,nil] a hash of FIELDS or nil if we failed to match
57
52
  # @api private
58
- def self.parse_line(line, regex=self::FIELDS_REGEX)
53
+ def self.parse_line(line)
59
54
  hash = nil
60
55
 
61
- match = regex.match(line)
62
- if match
56
+ if match = self::FIELDS_REGEX.match(line)
63
57
  hash = {}
64
58
 
65
59
  self::FIELDS.zip(match.captures) do |field,value|
@@ -84,8 +78,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
84
78
  public
85
79
 
86
80
  def install
87
- file = @resource[:source]
88
- unless file
81
+ unless file = @resource[:source]
89
82
  raise ArgumentError, _("You cannot install dpkg packages without a source")
90
83
  end
91
84
  args = []
@@ -109,11 +102,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
109
102
 
110
103
  # Return the version from the package.
111
104
  def latest
112
- source = @resource[:source]
113
- unless source
114
- @resource.fail _("Could not update: You cannot install dpkg packages without a source")
115
- end
116
- output = dpkg_deb "--show", source
105
+ output = dpkg_deb "--show", @resource[:source]
117
106
  matches = /^(\S+)\t(\S+)$/.match(output).captures
118
107
  warning _("source doesn't contain named package, but %{name}") % { name: matches[0] } unless matches[0].match( Regexp.escape(@resource[:name]) )
119
108
  matches[1]
@@ -124,20 +113,6 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
124
113
 
125
114
  # list out our specific package
126
115
  begin
127
- if @resource.allow_virtual?
128
- output = dpkgquery(
129
- "-W",
130
- "--showformat",
131
- self.class::DPKG_QUERY_PROVIDES_FORMAT_STRING
132
- #the regex searches for the resource[:name] in the dpkquery result in which the Provides field is also available
133
- #it will search for the packages only in the brackets ex: [rubygems]
134
- ).lines.find {|package| package.match(/[\[ ](#{Regexp.escape(@resource[:name])})[\],]/)}
135
- if output
136
- hash = self.class.parse_line(output,self.class::FIELDS_REGEX_WITH_PROVIDES)
137
- Puppet.info("Package #{@resource[:name]} is virtual, defaulting to #{hash[:name]}")
138
- @resource[:name] = hash[:name]
139
- end
140
- end
141
116
  output = dpkgquery(
142
117
  "-W",
143
118
  "--showformat",
@@ -170,7 +145,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
170
145
  end
171
146
 
172
147
  def hold
173
- if package_not_installed?
148
+ if package_not_installed?(@resource[:name])
174
149
  self.install
175
150
  end
176
151
  Tempfile.open('puppet_dpkg_set_selection') do |tmpfile|
@@ -188,7 +163,16 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
188
163
  end
189
164
  end
190
165
 
191
- def package_not_installed?
192
- query[:status] != "installed"
166
+ def package_not_installed?(name)
167
+ if !name.nil? && !name.empty?
168
+ begin
169
+ dpkgquery("-W", "--showformat", self.class::DPKG_QUERY_FORMAT_STRING, name)
170
+ rescue Puppet::ExecutionFailure
171
+ # return true if exception is generated because package is not found
172
+ return true
173
+ end
174
+ return false
175
+ end
176
+ raise ArgumentError.new("Package name is nil or empty")
193
177
  end
194
178
  end
@@ -180,7 +180,7 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
180
180
  # If :ensure contains a version, use that instead of looking it up.
181
181
  # This allows for installing packages with the same stem, but multiple
182
182
  # version such as openldap-server.
183
- if @resource[:ensure].to_s =~ /(\d[^-]*)$/
183
+ if /(\d[^-]*)$/.match(@resource[:ensure].to_s)
184
184
  use_version = @resource[:ensure]
185
185
  else
186
186
  use_version = get_version
@@ -1,6 +1,7 @@
1
1
  # Puppet package provider for Python's `pip` package management frontend.
2
2
  # <http://pip.pypa.io/>
3
3
 
4
+ require 'puppet/provider/package'
4
5
  require 'puppet/provider/package_targetable'
5
6
  require 'puppet/util/http_proxy'
6
7
 
@@ -35,25 +36,16 @@ Puppet::Type.type(:package).provide :pip, :parent => ::Puppet::Provider::Package
35
36
  if Puppet::Util::Platform.windows?
36
37
  ["pip.exe"]
37
38
  else
38
- ["pip", "pip-python", "pip2", "pip-2"]
39
+ ["pip", "pip-python"]
39
40
  end
40
41
  end
41
42
 
42
43
  def self.pip_version(command)
43
- version = nil
44
- execpipe [quote(command), '--version'] do |process|
44
+ execpipe [command, '--version'] do |process|
45
45
  process.collect do |line|
46
- md = line.strip.match(/^pip (\d+\.\d+\.?\d*).*$/)
47
- if md
48
- version = md[1]
49
- break
50
- end
46
+ return line.strip.match(/^pip (\d+\.\d+\.?\d*).*$/)[1]
51
47
  end
52
48
  end
53
-
54
- raise Puppet::Error, _("Cannot resolve pip version") unless version
55
-
56
- version
57
49
  end
58
50
 
59
51
  # Return an array of structured information about every installed package
@@ -95,9 +87,9 @@ Puppet::Type.type(:package).provide :pip, :parent => ::Puppet::Provider::Package
95
87
  end
96
88
 
97
89
  # Parse lines of output from `pip freeze`, which are structured as:
98
- # _package_==_version_ or _package_===_version_
90
+ # _package_==_version_
99
91
  def self.parse(line)
100
- if line.chomp =~ /^([^=]+)===?([^=]+)$/
92
+ if line.chomp =~ /^([^=]+)==([^=]+)$/
101
93
  {:ensure => $2, :name => $1, :provider => name}
102
94
  end
103
95
  end
@@ -110,7 +102,7 @@ Puppet::Type.type(:package).provide :pip, :parent => ::Puppet::Provider::Package
110
102
  self.class.validate_command(command)
111
103
 
112
104
  self.class.instances(command).each do |pkg|
113
- return pkg.properties if @resource[:name].casecmp(pkg.name).zero?
105
+ return pkg.properties if @resource[:name].downcase == pkg.name.downcase
114
106
  end
115
107
  return nil
116
108
  end
@@ -122,7 +114,7 @@ Puppet::Type.type(:package).provide :pip, :parent => ::Puppet::Provider::Package
122
114
  command = resource_or_provider_command
123
115
  self.class.validate_command(command)
124
116
 
125
- command_version = self.class.pip_version(command)
117
+ command_version = self.pip_version(command)
126
118
  if Puppet::Util::Package.versioncmp(command_version, '1.5.4') == -1
127
119
  latest_with_old_pip
128
120
  else
@@ -130,17 +122,14 @@ Puppet::Type.type(:package).provide :pip, :parent => ::Puppet::Provider::Package
130
122
  end
131
123
  end
132
124
 
133
- # Less resource-intensive approach for pip version 1.5.4 and newer.
134
-
135
125
  def latest_with_new_pip
136
126
  command = resource_or_provider_command
137
127
  self.class.validate_command(command)
138
128
 
139
- command_and_options = [command, 'install', "#{@resource[:name]}==versionplease"]
140
- command_and_options << install_options if @resource[:install_options]
141
- execpipe command_and_options do |process|
129
+ # Less resource intensive approach for pip version 1.5.4 and above
130
+ execpipe [command, "install", "#{@resource[:name]}==versionplease"] do |process|
142
131
  process.collect do |line|
143
- # PIP OUTPUT: Could not find a version that satisfies the requirement example==versionplease (from versions: 1.2.3, 4.5.6)
132
+ # PIP OUTPUT: Could not find a version that satisfies the requirement Django==versionplease (from versions: 1.1.3, 1.8rc1)
144
133
  if line =~ /from versions: /
145
134
  textAfterLastMatch = $'.chomp(")\n")
146
135
  versionList = textAfterLastMatch.split(', ').sort do |x,y|
@@ -153,18 +142,14 @@ Puppet::Type.type(:package).provide :pip, :parent => ::Puppet::Provider::Package
153
142
  end
154
143
  end
155
144
 
156
- # More resource-intensive approach for pip version 1.5.3 and older.
157
-
158
145
  def latest_with_old_pip
159
146
  command = resource_or_provider_command
160
147
  self.class.validate_command(command)
161
148
 
162
149
  Dir.mktmpdir("puppet_pip") do |dir|
163
- command_and_options = [command, 'install', "#{@resource[:name]}", '-d', "#{dir}", '-v']
164
- command_and_options << install_options if @resource[:install_options]
165
- execpipe command_and_options do |process|
150
+ execpipe [command, "install", "#{@resource[:name]}", "-d", "#{dir}", "-v"] do |process|
166
151
  process.collect do |line|
167
- # PIP OUTPUT: Using version 0.10.1 (newest of versions: 1.2.3, 4.5.6)
152
+ # PIP OUTPUT: Using version 0.10.1 (newest of versions: 0.10.1, 0.10, 0.9, 0.8.1, 0.8, 0.7.2, 0.7.1, 0.7, 0.6.1, 0.6, 0.5.2, 0.5.1, 0.5, 0.4, 0.3.1, 0.3, 0.2, 0.1)
168
153
  if line =~ /Using version (.+?) \(newest of versions/
169
154
  return $1
170
155
  end
@@ -224,13 +209,4 @@ Puppet::Type.type(:package).provide :pip, :parent => ::Puppet::Provider::Package
224
209
  def install_options
225
210
  join_options(@resource[:install_options])
226
211
  end
227
-
228
- def self.quote(path)
229
- if path.include?(" ")
230
- "\"#{path}\""
231
- else
232
- path
233
- end
234
- end
235
- private_class_method :quote
236
212
  end
@@ -69,7 +69,7 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
69
69
  name = qatom[:pfx] + name if qatom[:pfx]
70
70
  name = name + '-' + qatom[:pv] if qatom[:pv]
71
71
  name = name + '-' + qatom[:pr] if qatom[:pr]
72
- name = name + ':' + qatom[:slot] if qatom[:slot]
72
+ name = name + qatom[:slot] if qatom[:slot]
73
73
  cmd << '--update' if [:latest].include?(should)
74
74
  cmd += install_options if @resource[:install_options]
75
75
  cmd << name
@@ -83,7 +83,7 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
83
83
  name = qatom[:pfx] + name if qatom[:pfx]
84
84
  name = name + '-' + qatom[:pv] if qatom[:pv]
85
85
  name = name + '-' + qatom[:pr] if qatom[:pr]
86
- name = name + ':' + qatom[:slot] if qatom[:slot]
86
+ name = name + qatom[:slot] if qatom[:slot]
87
87
  cmd += uninstall_options if @resource[:uninstall_options]
88
88
  cmd << name
89
89
  if [:purged].include?(should)
@@ -177,7 +177,7 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
177
177
  package_sets << package_set.to_s.strip
178
178
  end
179
179
 
180
- if @resource[:name] =~ /^@/
180
+ if @resource[:name].match(/^@/)
181
181
  if package_sets.include?(@resource[:name][1..-1].to_s)
182
182
  return({:name => "#{@resource[:name]}", :ensure => '9999', :version_available => nil, :installed_versions => nil, :installable_versions => "9999,"})
183
183
  end
@@ -257,7 +257,7 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
257
257
  # [2.7.12: 2.7
258
258
  # 3.4.5: 3.4
259
259
  # 3.5.2: 3.5]
260
- version_for_slot = versions_and_slots.find { |version_and_slot| version_and_slot.last == slot }
260
+ version_for_slot = versions_and_slots.find { |version_and_slot| version_and_slot.last == slot[1..-1] }
261
261
  # [3.5.2: 3.5]
262
262
  version_for_slot.first if version_for_slot
263
263
  # 3.5.2