bolt 0.20.3 → 0.20.5

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

Potentially problematic release.


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

Files changed (256) hide show
  1. checksums.yaml +4 -4
  2. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +3 -3
  3. data/bolt-modules/boltlib/lib/puppet/functions/set_feature.rb +33 -0
  4. data/lib/bolt/inventory.rb +19 -1
  5. data/lib/bolt/target.rb +15 -0
  6. data/lib/bolt/transport/local.rb +6 -1
  7. data/lib/bolt/transport/orch.rb +2 -0
  8. data/lib/bolt/transport/ssh.rb +7 -2
  9. data/lib/bolt/transport/winrm.rb +6 -1
  10. data/lib/bolt/version.rb +1 -1
  11. data/modules/facts/plans/retrieve.pp +2 -26
  12. data/modules/facts/tasks/init.json +9 -0
  13. data/vendored/puppet/lib/hiera/puppet_function.rb +1 -1
  14. data/vendored/puppet/lib/hiera/scope.rb +24 -2
  15. data/vendored/puppet/lib/puppet.rb +4 -13
  16. data/vendored/puppet/lib/puppet/application.rb +2 -2
  17. data/vendored/puppet/lib/puppet/application/agent.rb +1 -1
  18. data/vendored/puppet/lib/puppet/application/apply.rb +1 -1
  19. data/vendored/puppet/lib/puppet/application/cert.rb +1 -1
  20. data/vendored/puppet/lib/puppet/application/device.rb +8 -8
  21. data/vendored/puppet/lib/puppet/application/face_base.rb +1 -1
  22. data/vendored/puppet/lib/puppet/application/lookup.rb +2 -2
  23. data/vendored/puppet/lib/puppet/application/resource.rb +2 -2
  24. data/vendored/puppet/lib/puppet/application/script.rb +1 -1
  25. data/vendored/puppet/lib/puppet/configurer.rb +47 -24
  26. data/vendored/puppet/lib/puppet/confine.rb +4 -1
  27. data/vendored/puppet/lib/puppet/context.rb +1 -1
  28. data/vendored/puppet/lib/puppet/defaults.rb +32 -44
  29. data/vendored/puppet/lib/puppet/error.rb +14 -7
  30. data/vendored/puppet/lib/puppet/external/dot.rb +23 -17
  31. data/vendored/puppet/lib/puppet/face/config.rb +58 -3
  32. data/vendored/puppet/lib/puppet/face/epp.rb +1 -1
  33. data/vendored/puppet/lib/puppet/face/module/build.rb +3 -3
  34. data/vendored/puppet/lib/puppet/face/module/install.rb +0 -4
  35. data/vendored/puppet/lib/puppet/face/module/list.rb +0 -5
  36. data/vendored/puppet/lib/puppet/face/module/search.rb +1 -1
  37. data/vendored/puppet/lib/puppet/face/module/uninstall.rb +0 -4
  38. data/vendored/puppet/lib/puppet/face/module/upgrade.rb +0 -4
  39. data/vendored/puppet/lib/puppet/face/status.rb +2 -2
  40. data/vendored/puppet/lib/puppet/file_serving/base.rb +5 -5
  41. data/vendored/puppet/lib/puppet/file_serving/metadata.rb +2 -1
  42. data/vendored/puppet/lib/puppet/forge.rb +7 -8
  43. data/vendored/puppet/lib/puppet/forge/errors.rb +3 -3
  44. data/vendored/puppet/lib/puppet/functions/abs.rb +61 -0
  45. data/vendored/puppet/lib/puppet/functions/all.rb +2 -2
  46. data/vendored/puppet/lib/puppet/functions/any.rb +2 -2
  47. data/vendored/puppet/lib/puppet/functions/assert_type.rb +3 -3
  48. data/vendored/puppet/lib/puppet/functions/break.rb +3 -7
  49. data/vendored/puppet/lib/puppet/functions/camelcase.rb +62 -0
  50. data/vendored/puppet/lib/puppet/functions/capitalize.rb +61 -0
  51. data/vendored/puppet/lib/puppet/functions/ceiling.rb +37 -0
  52. data/vendored/puppet/lib/puppet/functions/chomp.rb +57 -0
  53. data/vendored/puppet/lib/puppet/functions/chop.rb +67 -0
  54. data/vendored/puppet/lib/puppet/functions/compare.rb +125 -0
  55. data/vendored/puppet/lib/puppet/functions/convert_to.rb +3 -2
  56. data/vendored/puppet/lib/puppet/functions/dig.rb +21 -1
  57. data/vendored/puppet/lib/puppet/functions/downcase.rb +89 -0
  58. data/vendored/puppet/lib/puppet/functions/each.rb +2 -2
  59. data/vendored/puppet/lib/puppet/functions/empty.rb +1 -3
  60. data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
  61. data/vendored/puppet/lib/puppet/functions/filter.rb +2 -2
  62. data/vendored/puppet/lib/puppet/functions/floor.rb +37 -0
  63. data/vendored/puppet/lib/puppet/functions/get.rb +150 -0
  64. data/vendored/puppet/lib/puppet/functions/getvar.rb +87 -0
  65. data/vendored/puppet/lib/puppet/functions/hiera.rb +5 -5
  66. data/vendored/puppet/lib/puppet/functions/hiera_array.rb +5 -5
  67. data/vendored/puppet/lib/puppet/functions/hiera_hash.rb +6 -6
  68. data/vendored/puppet/lib/puppet/functions/hiera_include.rb +7 -7
  69. data/vendored/puppet/lib/puppet/functions/hocon_data.rb +1 -1
  70. data/vendored/puppet/lib/puppet/functions/json_data.rb +3 -3
  71. data/vendored/puppet/lib/puppet/functions/lest.rb +1 -1
  72. data/vendored/puppet/lib/puppet/functions/lookup.rb +3 -2
  73. data/vendored/puppet/lib/puppet/functions/lstrip.rb +58 -0
  74. data/vendored/puppet/lib/puppet/functions/map.rb +1 -1
  75. data/vendored/puppet/lib/puppet/functions/match.rb +11 -0
  76. data/vendored/puppet/lib/puppet/functions/max.rb +183 -0
  77. data/vendored/puppet/lib/puppet/functions/min.rb +182 -0
  78. data/vendored/puppet/lib/puppet/functions/next.rb +1 -8
  79. data/vendored/puppet/lib/puppet/functions/reduce.rb +1 -1
  80. data/vendored/puppet/lib/puppet/functions/return.rb +1 -8
  81. data/vendored/puppet/lib/puppet/functions/reverse_each.rb +1 -1
  82. data/vendored/puppet/lib/puppet/functions/round.rb +24 -0
  83. data/vendored/puppet/lib/puppet/functions/rstrip.rb +58 -0
  84. data/vendored/puppet/lib/puppet/functions/size.rb +15 -0
  85. data/vendored/puppet/lib/puppet/functions/sort.rb +74 -0
  86. data/vendored/puppet/lib/puppet/functions/step.rb +1 -1
  87. data/vendored/puppet/lib/puppet/functions/strftime.rb +1 -7
  88. data/vendored/puppet/lib/puppet/functions/strip.rb +58 -0
  89. data/vendored/puppet/lib/puppet/functions/then.rb +1 -1
  90. data/vendored/puppet/lib/puppet/functions/tree_each.rb +7 -7
  91. data/vendored/puppet/lib/puppet/functions/upcase.rb +89 -0
  92. data/vendored/puppet/lib/puppet/functions/with.rb +4 -4
  93. data/vendored/puppet/lib/puppet/functions/yaml_data.rb +4 -2
  94. data/vendored/puppet/lib/puppet/graph/simple_graph.rb +9 -5
  95. data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/rest.rb +0 -11
  96. data/vendored/puppet/lib/puppet/indirector/indirection.rb +8 -12
  97. data/vendored/puppet/lib/puppet/indirector/node/exec.rb +1 -1
  98. data/vendored/puppet/lib/puppet/indirector/node/ldap.rb +1 -1
  99. data/vendored/puppet/lib/puppet/indirector/request.rb +11 -11
  100. data/vendored/puppet/lib/puppet/indirector/rest.rb +11 -11
  101. data/vendored/puppet/lib/puppet/interface/action.rb +2 -5
  102. data/vendored/puppet/lib/puppet/metatype/manager.rb +0 -2
  103. data/vendored/puppet/lib/puppet/module.rb +7 -33
  104. data/vendored/puppet/lib/puppet/module/task.rb +0 -1
  105. data/vendored/puppet/lib/puppet/module_tool.rb +2 -5
  106. data/vendored/puppet/lib/puppet/module_tool/applications/application.rb +5 -5
  107. data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +2 -2
  108. data/vendored/puppet/lib/puppet/module_tool/applications/checksummer.rb +3 -3
  109. data/vendored/puppet/lib/puppet/module_tool/applications/installer.rb +6 -7
  110. data/vendored/puppet/lib/puppet/module_tool/applications/uninstaller.rb +1 -2
  111. data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +2 -2
  112. data/vendored/puppet/lib/puppet/module_tool/applications/upgrader.rb +5 -6
  113. data/vendored/puppet/lib/puppet/module_tool/dependency.rb +1 -1
  114. data/vendored/puppet/lib/puppet/module_tool/installed_modules.rb +2 -2
  115. data/vendored/puppet/lib/puppet/module_tool/local_tarball.rb +3 -3
  116. data/vendored/puppet/lib/puppet/module_tool/metadata.rb +3 -4
  117. data/vendored/puppet/lib/puppet/module_tool/shared_behaviors.rb +2 -2
  118. data/vendored/puppet/lib/puppet/network/authconfig.rb +0 -13
  119. data/vendored/puppet/lib/puppet/network/format_support.rb +1 -1
  120. data/vendored/puppet/lib/puppet/network/formats.rb +5 -7
  121. data/vendored/puppet/lib/puppet/network/http.rb +0 -2
  122. data/vendored/puppet/lib/puppet/network/http/api.rb +1 -10
  123. data/vendored/puppet/lib/puppet/network/http/api/master/v3/environment.rb +2 -2
  124. data/vendored/puppet/lib/puppet/network/http/api/master/v3/environments.rb +2 -2
  125. data/vendored/puppet/lib/puppet/network/http/compression.rb +1 -1
  126. data/vendored/puppet/lib/puppet/network/http/connection.rb +11 -3
  127. data/vendored/puppet/lib/puppet/network/http/error.rb +3 -3
  128. data/vendored/puppet/lib/puppet/network/http/factory.rb +3 -0
  129. data/vendored/puppet/lib/puppet/network/http/handler.rb +59 -27
  130. data/vendored/puppet/lib/puppet/network/resolver.rb +140 -67
  131. data/vendored/puppet/lib/puppet/node/environment.rb +2 -19
  132. data/vendored/puppet/lib/puppet/parameter.rb +12 -7
  133. data/vendored/puppet/lib/puppet/parser/ast.rb +4 -8
  134. data/vendored/puppet/lib/puppet/parser/ast/branch.rb +3 -3
  135. data/vendored/puppet/lib/puppet/parser/ast/leaf.rb +5 -0
  136. data/vendored/puppet/lib/puppet/parser/ast/pops_bridge.rb +18 -0
  137. data/vendored/puppet/lib/puppet/parser/compiler.rb +3 -4
  138. data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +9 -2
  139. data/vendored/puppet/lib/puppet/parser/functions.rb +1 -1
  140. data/vendored/puppet/lib/puppet/parser/functions/assert_type.rb +3 -3
  141. data/vendored/puppet/lib/puppet/parser/functions/create_resources.rb +1 -7
  142. data/vendored/puppet/lib/puppet/parser/functions/each.rb +2 -2
  143. data/vendored/puppet/lib/puppet/parser/functions/filter.rb +1 -1
  144. data/vendored/puppet/lib/puppet/parser/functions/hiera.rb +4 -4
  145. data/vendored/puppet/lib/puppet/parser/functions/hiera_array.rb +5 -5
  146. data/vendored/puppet/lib/puppet/parser/functions/hiera_hash.rb +6 -6
  147. data/vendored/puppet/lib/puppet/parser/functions/hiera_include.rb +10 -11
  148. data/vendored/puppet/lib/puppet/parser/functions/inline_template.rb +1 -1
  149. data/vendored/puppet/lib/puppet/parser/functions/lest.rb +1 -1
  150. data/vendored/puppet/lib/puppet/parser/functions/lookup.rb +1 -1
  151. data/vendored/puppet/lib/puppet/parser/functions/map.rb +1 -1
  152. data/vendored/puppet/lib/puppet/parser/functions/reduce.rb +1 -1
  153. data/vendored/puppet/lib/puppet/parser/functions/return.rb +22 -1
  154. data/vendored/puppet/lib/puppet/parser/functions/reverse_each.rb +1 -1
  155. data/vendored/puppet/lib/puppet/parser/functions/step.rb +1 -1
  156. data/vendored/puppet/lib/puppet/parser/functions/then.rb +1 -1
  157. data/vendored/puppet/lib/puppet/parser/functions/with.rb +4 -4
  158. data/vendored/puppet/lib/puppet/parser/resource.rb +0 -1
  159. data/vendored/puppet/lib/puppet/parser/resource/param.rb +12 -5
  160. data/vendored/puppet/lib/puppet/parser/scope.rb +5 -7
  161. data/vendored/puppet/lib/puppet/pops/evaluator/compare_operator.rb +3 -1
  162. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +2 -7
  163. data/vendored/puppet/lib/puppet/pops/issues.rb +4 -0
  164. data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +2 -2
  165. data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +17 -12
  166. data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +73 -45
  167. data/vendored/puppet/lib/puppet/pops/lookup/lookup_adapter.rb +55 -6
  168. data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +2 -0
  169. data/vendored/puppet/lib/puppet/pops/parser/epp_parser.rb +1 -1
  170. data/vendored/puppet/lib/puppet/pops/parser/epp_support.rb +6 -2
  171. data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +1 -1
  172. data/vendored/puppet/lib/puppet/pops/pcore.rb +7 -7
  173. data/vendored/puppet/lib/puppet/pops/puppet_stack.rb +15 -1
  174. data/vendored/puppet/lib/puppet/pops/serialization.rb +2 -2
  175. data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +2 -2
  176. data/vendored/puppet/lib/puppet/pops/serialization/json.rb +7 -7
  177. data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +5 -5
  178. data/vendored/puppet/lib/puppet/pops/types/types.rb +8 -4
  179. data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +73 -0
  180. data/vendored/puppet/lib/puppet/pops/validation/validator_factory_4_0.rb +4 -3
  181. data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +7 -0
  182. data/vendored/puppet/lib/puppet/provider/service/systemd.rb +1 -1
  183. data/vendored/puppet/lib/puppet/provider/user/aix.rb +2 -2
  184. data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +21 -9
  185. data/vendored/puppet/lib/puppet/reference/providers.rb +1 -1
  186. data/vendored/puppet/lib/puppet/reference/report.rb +1 -1
  187. data/vendored/puppet/lib/puppet/resource.rb +1 -1
  188. data/vendored/puppet/lib/puppet/resource/capability_finder.rb +4 -4
  189. data/vendored/puppet/lib/puppet/resource/catalog.rb +6 -3
  190. data/vendored/puppet/lib/puppet/resource/type.rb +6 -2
  191. data/vendored/puppet/lib/puppet/rest/client.rb +79 -0
  192. data/vendored/puppet/lib/puppet/rest/errors.rb +14 -0
  193. data/vendored/puppet/lib/puppet/rest/response.rb +29 -0
  194. data/vendored/puppet/lib/puppet/rest/route.rb +102 -0
  195. data/vendored/puppet/lib/puppet/rest/routes.rb +31 -0
  196. data/vendored/puppet/lib/puppet/settings.rb +9 -5
  197. data/vendored/puppet/lib/puppet/settings/config_file.rb +1 -1
  198. data/vendored/puppet/lib/puppet/settings/environment_conf.rb +10 -1
  199. data/vendored/puppet/lib/puppet/ssl.rb +0 -1
  200. data/vendored/puppet/lib/puppet/ssl/certificate.rb +6 -2
  201. data/vendored/puppet/lib/puppet/ssl/certificate_authority.rb +3 -3
  202. data/vendored/puppet/lib/puppet/ssl/host.rb +258 -19
  203. data/vendored/puppet/lib/puppet/ssl/validator/default_validator.rb +33 -19
  204. data/vendored/puppet/lib/puppet/syntax_checkers/json.rb +1 -1
  205. data/vendored/puppet/lib/puppet/transaction/event.rb +34 -7
  206. data/vendored/puppet/lib/puppet/transaction/report.rb +17 -14
  207. data/vendored/puppet/lib/puppet/type.rb +20 -12
  208. data/vendored/puppet/lib/puppet/type/file.rb +1 -1
  209. data/vendored/puppet/lib/puppet/type/file/content.rb +15 -2
  210. data/vendored/puppet/lib/puppet/type/file/ensure.rb +1 -1
  211. data/vendored/puppet/lib/puppet/type/schedule.rb +1 -1
  212. data/vendored/puppet/lib/puppet/type/stage.rb +1 -1
  213. data/vendored/puppet/lib/puppet/type/tidy.rb +5 -1
  214. data/vendored/puppet/lib/puppet/type/user.rb +35 -18
  215. data/vendored/puppet/lib/puppet/type/yumrepo.rb +8 -17
  216. data/vendored/puppet/lib/puppet/util.rb +0 -1
  217. data/vendored/puppet/lib/puppet/util/autoload.rb +1 -6
  218. data/vendored/puppet/lib/puppet/util/checksums.rb +0 -2
  219. data/vendored/puppet/lib/puppet/util/classgen.rb +0 -6
  220. data/vendored/puppet/lib/puppet/util/fileparsing.rb +27 -5
  221. data/vendored/puppet/lib/puppet/util/instance_loader.rb +3 -3
  222. data/vendored/puppet/lib/puppet/util/json.rb +77 -0
  223. data/vendored/puppet/lib/puppet/util/json_lockfile.rb +3 -3
  224. data/vendored/puppet/lib/puppet/util/ldap/connection.rb +7 -7
  225. data/vendored/puppet/lib/puppet/util/log/destinations.rb +2 -2
  226. data/vendored/puppet/lib/puppet/util/logging.rb +1 -1
  227. data/vendored/puppet/lib/puppet/util/plist.rb +1 -1
  228. data/vendored/puppet/lib/puppet/util/provider_features.rb +2 -5
  229. data/vendored/puppet/lib/puppet/util/reference.rb +5 -4
  230. data/vendored/puppet/lib/puppet/util/tagging.rb +16 -3
  231. data/vendored/puppet/lib/puppet/version.rb +1 -1
  232. metadata +44 -26
  233. data/vendored/puppet/lib/puppet/application/master.rb +0 -317
  234. data/vendored/puppet/lib/puppet/feature/rack.rb +0 -19
  235. data/vendored/puppet/lib/puppet/network/http/api/ca.rb +0 -2
  236. data/vendored/puppet/lib/puppet/network/http/api/ca/v1.rb +0 -11
  237. data/vendored/puppet/lib/puppet/network/http/rack.rb +0 -33
  238. data/vendored/puppet/lib/puppet/network/http/rack/rest.rb +0 -162
  239. data/vendored/puppet/lib/puppet/network/http/webrick.rb +0 -124
  240. data/vendored/puppet/lib/puppet/network/http/webrick/rest.rb +0 -114
  241. data/vendored/puppet/lib/puppet/network/server.rb +0 -39
  242. data/vendored/puppet/lib/puppet/ssl/configuration.rb +0 -61
  243. data/vendored/puppet/lib/puppet/util/methodhelper.rb +0 -32
  244. data/vendored/puppet/lib/puppet/vendor/load_semantic.rb +0 -1
  245. data/vendored/puppet/lib/puppet/vendor/load_semantic_puppet.rb +0 -1
  246. data/vendored/puppet/lib/puppet/vendor/semantic/lib/semantic.rb +0 -5
  247. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +0 -11
  248. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb +0 -181
  249. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb +0 -60
  250. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph_node.rb +0 -117
  251. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb +0 -58
  252. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/source.rb +0 -25
  253. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/unsatisfiable_graph.rb +0 -31
  254. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/gem_version.rb +0 -3
  255. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +0 -203
  256. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +0 -758
@@ -25,7 +25,7 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
25
25
  defaultfor :osfamily => :coreos
26
26
  defaultfor :operatingsystem => :amazon, :operatingsystemmajrelease => ["2"]
27
27
  defaultfor :operatingsystem => :debian, :operatingsystemmajrelease => ["8", "stretch/sid", "9", "buster/sid"]
28
- defaultfor :operatingsystem => :ubuntu, :operatingsystemmajrelease => ["15.04","15.10","16.04","16.10"]
28
+ defaultfor :operatingsystem => :ubuntu, :operatingsystemmajrelease => ["15.04","15.10","16.04","16.10","17.04","17.10","18.04"]
29
29
  defaultfor :operatingsystem => :cumuluslinux, :operatingsystemmajrelease => ["3"]
30
30
 
31
31
  def self.instances
@@ -7,7 +7,7 @@
7
7
  # but puppet does not allow it. There is a ticket open for that (#5431)
8
8
  # - AIX maximum password age is in WEEKs, not days
9
9
  #
10
- # See https://docs.puppetlabs.com/guides/provider_development.html
10
+ # See https://puppet.com/docs/puppet/latest/provider_development.html
11
11
  # for more information
12
12
  #
13
13
  # Author:: Hector Rivas Gandara <keymon@gmail.com>
@@ -276,7 +276,7 @@ Puppet::Type.type(:user).provide :aix, :parent => Puppet::Provider::AixObject do
276
276
  # Must receive "user:enc_password" as input
277
277
  # command, arguments = {:failonfail => true, :combine => true}
278
278
  # Fix for bugs #11200 and #10915
279
- cmd = [self.class.command(:chpasswd), get_ia_module_args, '-e', '-c', user].flatten
279
+ cmd = [self.class.command(:chpasswd), get_ia_module_args, '-e', '-c'].flatten
280
280
  begin
281
281
  output = execute(cmd, {:failonfail => false, :combine => true, :stdinfile => tmpfile.path })
282
282
  # chpasswd can return 1, even on success (at least on AIX 6.1); empty output indicates success
@@ -164,15 +164,7 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
164
164
  result = self.virtual_inifile[name]
165
165
  # Create a new section if not found.
166
166
  unless result
167
- dirs = reposdir()
168
- if dirs.empty?
169
- # If no repo directories are present, default to using yum.conf.
170
- path = '/etc/yum.conf'
171
- else
172
- # The ordering of reposdir is [defaults, custom], and we want to use
173
- # the custom directory if present.
174
- path = File.join(dirs.last, "#{name}.repo")
175
- end
167
+ path = getRepoPath(name)
176
168
  result = self.virtual_inifile.add_section(name, path)
177
169
  end
178
170
  result
@@ -187,6 +179,7 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
187
179
 
188
180
  target_mode = 0644
189
181
  inifile.each_file do |file|
182
+ next unless Puppet::FileSystem.exist?(file)
190
183
  current_mode = Puppet::FileSystem.stat(file).mode & 0777
191
184
  unless current_mode == target_mode
192
185
  resource.info _("changing mode of %{file} from %{current_mode} to %{target_mode}") %
@@ -196,6 +189,19 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
196
189
  end
197
190
  end
198
191
 
192
+ def self.getRepoPath(name)
193
+ dirs = reposdir()
194
+ if dirs.empty?
195
+ # If no repo directories are present, default to using yum.conf.
196
+ path = '/etc/yum.conf'
197
+ else
198
+ # The ordering of reposdir is [defaults, custom], and we want to use
199
+ # the custom directory if present.
200
+ path = File.join(dirs.last, "#{name}.repo")
201
+ end
202
+ path
203
+ end
204
+
199
205
  # Create a new section for the given repository and set all the specified
200
206
  # properties in the section.
201
207
  #
@@ -204,6 +210,12 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
204
210
  def create
205
211
  @property_hash[:ensure] = :present
206
212
 
213
+ # Check to see if the file that would be created in the
214
+ # default location for the yumrepo already exists on disk.
215
+ # If it does, read it in to the virtual inifile
216
+ path = self.class.getRepoPath(name)
217
+ self.class.virtual_inifile.read(path) if Puppet::FileSystem.file?(path)
218
+
207
219
  # We fetch a list of properties from the type, then iterate
208
220
  # over them, avoiding ensure. We're relying on .should to
209
221
  # check if the property has been set and should be modified,
@@ -90,7 +90,7 @@ providers = Puppet::Util::Reference.newreference :providers, :title => "Provider
90
90
 
91
91
  ret << markdown_header(type.name.to_s + "_", 2)
92
92
 
93
- ret << "[#{type.name}](https://docs.puppetlabs.com/puppet/latest/reference/type.html##{type.name})\n\n"
93
+ ret << "[#{type.name}](https://puppet.com/docs/puppet/latest/type.html##{type.name})\n\n"
94
94
  ret << option("Default provider", default)
95
95
  ret << doctable(headers, table_data)
96
96
 
@@ -14,7 +14,7 @@ Puppet master and Puppet apply will handle every report with a set of report
14
14
  processors, configurable with the `reports` setting in puppet.conf. This page
15
15
  documents the built-in report processors.
16
16
 
17
- See [About Reporting](https://docs.puppetlabs.com/puppet/latest/reference/reporting_about.html)
17
+ See [About Reporting](https://puppet.com/docs/puppet/latest/reporting_about.html)
18
18
  for more details.
19
19
 
20
20
  "
@@ -34,7 +34,7 @@ class Puppet::Resource
34
34
  TYPE_NODE = 'Node'.freeze
35
35
  TYPE_SITE = 'Site'.freeze
36
36
 
37
- PCORE_TYPE_KEY = '__pcore_type__'.freeze
37
+ PCORE_TYPE_KEY = '__ptype'.freeze
38
38
  VALUE_KEY = 'value'.freeze
39
39
 
40
40
  def self.from_data_hash(data)
@@ -7,7 +7,7 @@
7
7
 
8
8
  require 'net/http'
9
9
  require 'cgi'
10
- require 'json'
10
+ require 'puppet/util/json'
11
11
 
12
12
  # @api private
13
13
  module Puppet::Resource::CapabilityFinder
@@ -92,11 +92,11 @@ module Puppet::Resource::CapabilityFinder
92
92
  response = Puppet::Util::Puppetdb::Http.action(url) do |conn, uri|
93
93
  conn.get(uri, { 'Accept' => 'application/json'})
94
94
  end
95
- JSON.parse(response.body)
95
+ Puppet::Util::Json.load(response.body)
96
96
  end
97
97
 
98
98
  # The format of the response body is documented at
99
- # https://docs.puppetlabs.com/puppetdb/3.0/api/query/v4/resources.html#response-format
99
+ # https://puppet.com/docs/puppetdb/3.0/api/query/v4/resources.html#response-format
100
100
  unless result.is_a?(Array)
101
101
  #TRANSLATOR PuppetDB is a product name and should not be translated
102
102
  raise Puppet::DevError, _("Unexpected response from PuppetDB when looking up %{capability}: expected an Array but got %{result}") %
@@ -104,7 +104,7 @@ module Puppet::Resource::CapabilityFinder
104
104
  end
105
105
 
106
106
  result
107
- rescue JSON::JSONError => e
107
+ rescue Puppet::Util::Json::ParseError => e
108
108
  #TRANSLATOR PuppetDB is a product name and should not be translated
109
109
  raise Puppet::DevError, _("Invalid JSON from PuppetDB when looking up %{capability}\n%{detail}") % { capability: cap, detail: e }
110
110
  end
@@ -235,7 +235,10 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
235
235
 
236
236
  begin
237
237
  transaction.report.as_logging_destination do
238
- transaction.evaluate
238
+ transaction_evaluate_time = Puppet::Util.thinmark do
239
+ transaction.evaluate
240
+ end
241
+ transaction.report.add_times(:transaction_evaluation, transaction_evaluate_time)
239
242
  end
240
243
  ensure
241
244
  # Don't try to store state unless we're a host config
@@ -539,7 +542,7 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
539
542
  # Store the classes in the classfile.
540
543
  def write_class_file
541
544
  # classfile paths may contain UTF-8
542
- # https://docs.puppet.com/puppet/latest/reference/configuration.html#classfile
545
+ # https://puppet.com/docs/puppet/latest/configuration.html#classfile
543
546
  classfile = Puppet.settings.setting(:classfile)
544
547
  Puppet::FileSystem.open(classfile.value, classfile.mode.to_i(8), "w:UTF-8") do |f|
545
548
  f.puts classes.join("\n")
@@ -551,7 +554,7 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
551
554
  # Store the list of resources we manage
552
555
  def write_resource_file
553
556
  # resourcefile contains resources that may be UTF-8 names
554
- # https://docs.puppet.com/puppet/latest/reference/configuration.html#resourcefile
557
+ # https://puppet.com/docs/puppet/latest/configuration.html#resourcefile
555
558
  resourcefile = Puppet.settings.setting(:resourcefile)
556
559
  Puppet::FileSystem.open(resourcefile.value, resourcefile.mode.to_i(8), "w:UTF-8") do |f|
557
560
  to_print = resources.map do |resource|
@@ -189,8 +189,12 @@ class Puppet::Resource::Type
189
189
  def merge(other)
190
190
  fail _("%{name} is not a class; cannot add code to it") % { name: name } unless type == :hostclass
191
191
  fail _("%{name} is not a class; cannot add code from it") % { name: other.name } unless other.type == :hostclass
192
- fail _("Cannot have code outside of a class/node/define because 'freeze_main' is enabled") if name == "" and Puppet.settings[:freeze_main]
193
-
192
+ if name == "" && Puppet.settings[:freeze_main]
193
+ # It is ok to merge definitions into main even if freeze is on (definitions are nodes, classes, defines, functions, and types)
194
+ unless other.code.is_definitions_only?
195
+ fail _("Cannot have code outside of a class/node/define because 'freeze_main' is enabled")
196
+ end
197
+ end
194
198
  if parent and other.parent and parent != other.parent
195
199
  fail _("Cannot merge classes with different parent classes (%{name} => %{parent} vs. %{other_name} => %{other_parent})") % { name: name, parent: parent, other_name: other.name, other_parent: other.parent }
196
200
  end
@@ -0,0 +1,79 @@
1
+ require 'httpclient'
2
+
3
+ require 'puppet'
4
+ require 'puppet/rest/response'
5
+ require 'puppet/rest/errors'
6
+
7
+ module Puppet::Rest
8
+ class Client
9
+ attr_reader :dns_resolver
10
+
11
+ # Create a new HTTP client for querying the given API.
12
+ # @param [OpenSSL::X509::Store] ssl_store the SSL configuration for this client
13
+ # @param [Integer] receive_timeout how long in seconds this client will wait
14
+ # for a response after making a request
15
+ # @param [HTTPClient] client the third-party HTTP client wrapped by this
16
+ # class. This param is only used for testing.
17
+ def initialize(ssl_store: OpenSSL::X509::Store.new,
18
+ receive_timeout: Puppet[:http_read_timeout],
19
+ client: HTTPClient.new(agent_name: nil,
20
+ default_header: {
21
+ 'User-Agent' => Puppet[:http_user_agent],
22
+ 'X-PUPPET-VERSION' => Puppet::PUPPETVERSION
23
+ }))
24
+ @client = client
25
+ @client.tcp_keepalive = true
26
+ @client.connect_timeout = Puppet[:http_connect_timeout]
27
+ @client.receive_timeout = receive_timeout
28
+ @client.transparent_gzip_decompression = true
29
+
30
+ if Puppet[:http_debug]
31
+ @client.debug_dev = $stderr
32
+ end
33
+
34
+ @client.ssl_config.cert_store = ssl_store
35
+
36
+ configure_verify_mode(@client.ssl_config)
37
+
38
+ @dns_resolver = Puppet::Network::Resolver.new
39
+ end
40
+
41
+ # Make a GET request to the specified URL with the specified params.
42
+ # @param [String] url the full path to query
43
+ # @param [Hash] query any URL params to add to send to the endpoint
44
+ # @param [Hash] header any additional entries to add to the default header
45
+ # @yields [String] chunks of the response body
46
+ # @raise [Puppet::Rest::ResponseError] if the response status is not OK
47
+ def get(url, query: nil, header: nil, &block)
48
+ begin
49
+ @client.get_content(url, { query: query, header: header }) do |chunk|
50
+ block.call(chunk)
51
+ end
52
+ rescue HTTPClient::BadResponseError => e
53
+ raise Puppet::Rest::ResponseError.new(e.message, Puppet::Rest::Response.new(e.res))
54
+ end
55
+ end
56
+
57
+ private
58
+
59
+ # Checks for SSL certificates on disk and sets VERIFY_PEER
60
+ # if they are found. Otherwise, sets VERIFY_NONE.
61
+ def configure_verify_mode(ssl_config)
62
+ # Either the path to an external CA or to our CA cert from the Puppet master
63
+ # TODO We may be able to consolidate this with the current intermediate CA work?
64
+ ca_path = Puppet[:ssl_client_ca_auth] || Puppet[:localcacert]
65
+
66
+ if ssl_certificates_are_present?(ca_path)
67
+ ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER
68
+ ssl_config.add_trust_ca(ca_path)
69
+ ssl_config.set_client_cert_file(Puppet[:hostcert], Puppet[:hostprivkey])
70
+ else
71
+ ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
72
+ end
73
+ end
74
+
75
+ def ssl_certificates_are_present?(ca_path)
76
+ Puppet::FileSystem.exist?(Puppet[:hostcert]) && Puppet::FileSystem.exist?(ca_path)
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,14 @@
1
+ module Puppet::Rest
2
+ class ResponseError < Puppet::Error
3
+ attr_reader :response
4
+
5
+ # Error thrown when request status is not OK.
6
+ # @param [String] msg the error message
7
+ # @param [Puppet::Rest::Response] response the response from the failed
8
+ # request
9
+ def initialize(msg, response = nil)
10
+ super(msg)
11
+ @response = response
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,29 @@
1
+ module Puppet::Rest
2
+ # This is a wrapper for the HTTP::Message class of the HTTPClient
3
+ # gem. It is designed to wrap a message sent as an HTTP response.
4
+ class Response
5
+ def initialize(message)
6
+ @message = message
7
+ end
8
+
9
+ def body
10
+ @message.body
11
+ end
12
+
13
+ def content_type
14
+ @message.content_type
15
+ end
16
+
17
+ def content_encoding
18
+ @message.headers['Content-Encoding']
19
+ end
20
+
21
+ def status_code
22
+ @message.status
23
+ end
24
+
25
+ def ok?
26
+ @message.ok?
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,102 @@
1
+ require 'uri'
2
+
3
+ module Puppet::Rest
4
+ class Route
5
+ # Create a Route containing information for querying the given API,
6
+ # hosted at a server determined either by SRV service or by the
7
+ # fallback server on the fallback port.
8
+ # @param [String] api the path leading to the root of the API. Must
9
+ # contain a trailing slash for proper endpoint path
10
+ # construction
11
+ # @param [String] default_server the fqdn of the fallback server
12
+ # @param [Integer] port the fallback port
13
+ # @param [Symbol] srv_service the name of the service when using SRV
14
+ # records
15
+ def initialize(api:, default_server:, default_port:, srv_service:)
16
+ @api = api
17
+ @default_server = default_server
18
+ @default_port = default_port
19
+ @srv_service = srv_service
20
+ end
21
+
22
+ # Select a server and port to create a base URL for the API specified by this
23
+ # route. If the connection fails and SRV records are in use, the next suitable
24
+ # server will be tried. If SRV records are not in use or no successful connection
25
+ # could be made, fall back to the configured server and port for this API, taking
26
+ # into account failover settings.
27
+ # @parma [Puppet::Network::Resolver] dns_resolver the DNS resolver to use to check
28
+ # SRV records
29
+ # @yield [URI] supply a base URL to make a request with
30
+ # @raise [Puppet::Error] if connection to selected server and port fails, and SRV
31
+ # records are not in use
32
+ def with_base_url(dns_resolver)
33
+ if @server && @port
34
+ # First try connecting to the previously selected server and port.
35
+ begin
36
+ return yield(base_url)
37
+ rescue SystemCallError => e
38
+ if Puppet[:use_srv_records]
39
+ Puppet.debug "Connection to cached server and port #{@server}:#{@port} failed, reselecting."
40
+ else
41
+ raise Puppet::Error, _("Connection to cached server and port %{server}:%{port} failed: %{message}") %
42
+ { server: @server, port: @port, message: e.message }
43
+ end
44
+ end
45
+ end
46
+
47
+ if Puppet[:use_srv_records]
48
+ dns_resolver.each_srv_record(@srv_service) do |srv_server, srv_port|
49
+ # Try each of the servers for this service in weighted order
50
+ # until a working one is found.
51
+ begin
52
+ @server = srv_server
53
+ @port = srv_port
54
+ return yield(base_url)
55
+ rescue SystemCallError
56
+ Puppet.debug "Connection to selected server and port #{@server}:#{@port} failed. Trying next cached SRV record."
57
+ @server = nil
58
+ @port = nil
59
+ end
60
+ end
61
+ end
62
+
63
+ # If we have provided a specific server and port, use those.
64
+ if @default_server && @default_port
65
+ @server = @default_server
66
+ @port = @default_port
67
+ else
68
+ # Otherwise, get server and port from default settings, taking
69
+ # into account the server list for HA.
70
+ bound_server = Puppet.lookup(:server) do
71
+ if primary_server = Puppet.settings[:server_list][0]
72
+ primary_server[0]
73
+ else
74
+ Puppet.settings[:server]
75
+ end
76
+ end
77
+
78
+ bound_port = Puppet.lookup(:serverport) do
79
+ if primary_server = Puppet.settings[:server_list][0]
80
+ primary_server[1]
81
+ else
82
+ Puppet.settings[:masterport]
83
+ end
84
+ end
85
+
86
+ @server = bound_server
87
+ @port = bound_port
88
+ end
89
+
90
+ Puppet.debug "No more servers in SRV record, falling back to #{@server}:#{@port}" if Puppet[:use_srv_records]
91
+ return yield(base_url)
92
+ end
93
+
94
+ private
95
+
96
+ # Returns a URI built from the information stored by this route,
97
+ # e.g. 'https://myserver.com:555/myapi/v1/'
98
+ def base_url
99
+ URI::HTTPS.build(host: @server, port: @port, path: @api)
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,31 @@
1
+ require 'puppet/rest/route'
2
+
3
+ module Puppet::Rest
4
+ module Routes
5
+ ACCEPT_ENCODING = 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'
6
+
7
+ def self.ca
8
+ @ca ||= Route.new(api: '/puppet-ca/v1/',
9
+ default_server: Puppet[:ca_server],
10
+ default_port: Puppet[:ca_port],
11
+ srv_service: :ca)
12
+ end
13
+
14
+ # Make an HTTP request to fetch the named certificate, using the given
15
+ # HTTP client.
16
+ # @param [Puppet::Rest::Client] client the HTTP client to use to make the request
17
+ # @param [String] name the name of the certificate to fetch
18
+ # @raise [Puppet::Rest::ResponseError] if the response status is not OK
19
+ # @return [String] the PEM-encoded certificate or certificate bundle
20
+ def self.get_certificate(client, name)
21
+ ca.with_base_url(client.dns_resolver) do |base_url|
22
+ header = { 'Accept' => 'text/plain', 'accept-encoding' => ACCEPT_ENCODING }
23
+ body = ''
24
+ client.get(base_url + "certificate/#{name}", header: header) do |chunk|
25
+ body << chunk
26
+ end
27
+ body
28
+ end
29
+ end
30
+ end
31
+ end