bolt 0.17.1 → 0.17.2

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 (224) hide show
  1. checksums.yaml +4 -4
  2. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +25 -13
  3. data/lib/bolt/cli.rb +45 -15
  4. data/lib/bolt/config.rb +48 -132
  5. data/lib/bolt/executor.rb +3 -10
  6. data/lib/bolt/inventory.rb +15 -1
  7. data/lib/bolt/puppetdb.rb +11 -0
  8. data/lib/bolt/puppetdb/client.rb +68 -0
  9. data/lib/bolt/puppetdb/config.rb +76 -0
  10. data/lib/bolt/target.rb +5 -4
  11. data/lib/bolt/transport/base.rb +11 -2
  12. data/lib/bolt/transport/local.rb +11 -5
  13. data/lib/bolt/transport/orch.rb +16 -5
  14. data/lib/bolt/transport/ssh.rb +32 -1
  15. data/lib/bolt/transport/ssh/connection.rb +17 -10
  16. data/lib/bolt/transport/winrm.rb +18 -1
  17. data/lib/bolt/transport/winrm/connection.rb +15 -16
  18. data/lib/bolt/util.rb +15 -0
  19. data/lib/bolt/version.rb +1 -1
  20. data/lib/bolt_ext/puppetdb_inventory.rb +5 -135
  21. data/vendored/facter/lib/facter/ec2/rest.rb +1 -1
  22. data/vendored/hiera/lib/hiera/version.rb +1 -1
  23. data/vendored/puppet/lib/puppet/application/agent.rb +1 -3
  24. data/vendored/puppet/lib/puppet/application/apply.rb +2 -4
  25. data/vendored/puppet/lib/puppet/application/cert.rb +6 -1
  26. data/vendored/puppet/lib/puppet/application/device.rb +100 -13
  27. data/vendored/puppet/lib/puppet/application/facts.rb +5 -0
  28. data/vendored/puppet/lib/puppet/application/lookup.rb +11 -1
  29. data/vendored/puppet/lib/puppet/configurer.rb +17 -4
  30. data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +1 -1
  31. data/vendored/puppet/lib/puppet/datatypes.rb +1 -1
  32. data/vendored/puppet/lib/puppet/defaults.rb +1 -1
  33. data/vendored/puppet/lib/puppet/environments.rb +2 -2
  34. data/vendored/puppet/lib/puppet/error.rb +6 -3
  35. data/vendored/puppet/lib/puppet/external/dot.rb +0 -7
  36. data/vendored/puppet/lib/puppet/external/nagios/parser.rb +1 -1
  37. data/vendored/puppet/lib/puppet/face/config.rb +41 -8
  38. data/vendored/puppet/lib/puppet/face/epp.rb +30 -5
  39. data/vendored/puppet/lib/puppet/face/facts.rb +49 -0
  40. data/vendored/puppet/lib/puppet/face/help.rb +33 -35
  41. data/vendored/puppet/lib/puppet/face/man.rb +55 -12
  42. data/vendored/puppet/lib/puppet/face/parser.rb +30 -3
  43. data/vendored/puppet/lib/puppet/file_bucket/file.rb +0 -2
  44. data/vendored/puppet/lib/puppet/file_serving/base.rb +10 -10
  45. data/vendored/puppet/lib/puppet/functions.rb +1 -3
  46. data/vendored/puppet/lib/puppet/functions/alert.rb +1 -1
  47. data/vendored/puppet/lib/puppet/functions/all.rb +6 -6
  48. data/vendored/puppet/lib/puppet/functions/annotate.rb +10 -10
  49. data/vendored/puppet/lib/puppet/functions/any.rb +6 -6
  50. data/vendored/puppet/lib/puppet/functions/assert_type.rb +4 -4
  51. data/vendored/puppet/lib/puppet/functions/binary_file.rb +14 -2
  52. data/vendored/puppet/lib/puppet/functions/break.rb +31 -2
  53. data/vendored/puppet/lib/puppet/functions/call.rb +4 -4
  54. data/vendored/puppet/lib/puppet/functions/contain.rb +19 -3
  55. data/vendored/puppet/lib/puppet/functions/convert_to.rb +6 -5
  56. data/vendored/puppet/lib/puppet/functions/crit.rb +1 -1
  57. data/vendored/puppet/lib/puppet/functions/debug.rb +1 -1
  58. data/vendored/puppet/lib/puppet/functions/defined.rb +11 -9
  59. data/vendored/puppet/lib/puppet/functions/dig.rb +26 -2
  60. data/vendored/puppet/lib/puppet/functions/each.rb +8 -8
  61. data/vendored/puppet/lib/puppet/functions/emerg.rb +1 -1
  62. data/vendored/puppet/lib/puppet/functions/empty.rb +79 -0
  63. data/vendored/puppet/lib/puppet/functions/err.rb +1 -1
  64. data/vendored/puppet/lib/puppet/functions/filter.rb +7 -7
  65. data/vendored/puppet/lib/puppet/functions/find_file.rb +15 -1
  66. data/vendored/puppet/lib/puppet/functions/flatten.rb +64 -0
  67. data/vendored/puppet/lib/puppet/functions/hiera.rb +6 -6
  68. data/vendored/puppet/lib/puppet/functions/hiera_array.rb +6 -6
  69. data/vendored/puppet/lib/puppet/functions/hiera_hash.rb +6 -6
  70. data/vendored/puppet/lib/puppet/functions/hiera_include.rb +8 -8
  71. data/vendored/puppet/lib/puppet/functions/include.rb +28 -2
  72. data/vendored/puppet/lib/puppet/functions/info.rb +1 -1
  73. data/vendored/puppet/lib/puppet/functions/inline_epp.rb +2 -2
  74. data/vendored/puppet/lib/puppet/functions/join.rb +56 -0
  75. data/vendored/puppet/lib/puppet/functions/keys.rb +25 -0
  76. data/vendored/puppet/lib/puppet/functions/length.rb +44 -0
  77. data/vendored/puppet/lib/puppet/functions/lest.rb +39 -1
  78. data/vendored/puppet/lib/puppet/functions/map.rb +10 -9
  79. data/vendored/puppet/lib/puppet/functions/match.rb +6 -6
  80. data/vendored/puppet/lib/puppet/functions/new.rb +995 -2
  81. data/vendored/puppet/lib/puppet/functions/next.rb +1 -1
  82. data/vendored/puppet/lib/puppet/functions/notice.rb +1 -1
  83. data/vendored/puppet/lib/puppet/functions/reduce.rb +6 -6
  84. data/vendored/puppet/lib/puppet/functions/regsubst.rb +9 -3
  85. data/vendored/puppet/lib/puppet/functions/require.rb +36 -2
  86. data/vendored/puppet/lib/puppet/functions/return.rb +1 -1
  87. data/vendored/puppet/lib/puppet/functions/reverse_each.rb +71 -2
  88. data/vendored/puppet/lib/puppet/functions/slice.rb +23 -9
  89. data/vendored/puppet/lib/puppet/functions/split.rb +12 -10
  90. data/vendored/puppet/lib/puppet/functions/step.rb +73 -1
  91. data/vendored/puppet/lib/puppet/functions/strftime.rb +176 -2
  92. data/vendored/puppet/lib/puppet/functions/then.rb +65 -2
  93. data/vendored/puppet/lib/puppet/functions/tree_each.rb +19 -19
  94. data/vendored/puppet/lib/puppet/functions/type.rb +42 -1
  95. data/vendored/puppet/lib/puppet/functions/unique.rb +13 -13
  96. data/vendored/puppet/lib/puppet/functions/unwrap.rb +8 -4
  97. data/vendored/puppet/lib/puppet/functions/values.rb +25 -0
  98. data/vendored/puppet/lib/puppet/functions/versioncmp.rb +1 -1
  99. data/vendored/puppet/lib/puppet/functions/warning.rb +1 -1
  100. data/vendored/puppet/lib/puppet/functions/with.rb +6 -4
  101. data/vendored/puppet/lib/puppet/indirector/certificate_status/file.rb +1 -1
  102. data/vendored/puppet/lib/puppet/indirector/facts/facter.rb +1 -3
  103. data/vendored/puppet/lib/puppet/indirector/facts/rest.rb +21 -0
  104. data/vendored/puppet/lib/puppet/indirector/facts/yaml.rb +0 -4
  105. data/vendored/puppet/lib/puppet/indirector/file_content/http.rb +3 -1
  106. data/vendored/puppet/lib/puppet/indirector/indirection.rb +5 -3
  107. data/vendored/puppet/lib/puppet/indirector/request.rb +6 -2
  108. data/vendored/puppet/lib/puppet/module/task.rb +2 -2
  109. data/vendored/puppet/lib/puppet/module_tool/tar/mini.rb +57 -4
  110. data/vendored/puppet/lib/puppet/network/authconfig.rb +1 -1
  111. data/vendored/puppet/lib/puppet/network/http/api/indirected_routes.rb +1 -0
  112. data/vendored/puppet/lib/puppet/network/resolver.rb +1 -2
  113. data/vendored/puppet/lib/puppet/node.rb +4 -3
  114. data/vendored/puppet/lib/puppet/parser/compiler.rb +12 -5
  115. data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +1 -1
  116. data/vendored/puppet/lib/puppet/parser/functions/fqdn_rand.rb +15 -4
  117. data/vendored/puppet/lib/puppet/parser/functions/new.rb +31 -46
  118. data/vendored/puppet/lib/puppet/parser/parser_factory.rb +1 -1
  119. data/vendored/puppet/lib/puppet/parser/resource.rb +1 -1
  120. data/vendored/puppet/lib/puppet/parser/type_loader.rb +11 -11
  121. data/vendored/puppet/lib/puppet/pops/evaluator/closure.rb +1 -1
  122. data/vendored/puppet/lib/puppet/pops/evaluator/collector_transformer.rb +1 -1
  123. data/vendored/puppet/lib/puppet/pops/evaluator/epp_evaluator.rb +2 -2
  124. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_resource_support.rb +2 -2
  125. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +5 -2
  126. data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +1 -1
  127. data/vendored/puppet/lib/puppet/pops/issue_reporter.rb +18 -1
  128. data/vendored/puppet/lib/puppet/pops/issues.rb +6 -3
  129. data/vendored/puppet/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +1 -2
  130. data/vendored/puppet/lib/puppet/pops/loader/ruby_function_instantiator.rb +1 -2
  131. data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +4 -4
  132. data/vendored/puppet/lib/puppet/pops/loader/type_definition_instantiator.rb +4 -1
  133. data/vendored/puppet/lib/puppet/pops/loaders.rb +18 -7
  134. data/vendored/puppet/lib/puppet/pops/lookup/global_data_provider.rb +1 -1
  135. data/vendored/puppet/lib/puppet/pops/model/factory.rb +6 -3
  136. data/vendored/puppet/lib/puppet/pops/model/model_tree_dumper.rb +4 -0
  137. data/vendored/puppet/lib/puppet/pops/model/pn_transformer.rb +400 -0
  138. data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +1 -1
  139. data/vendored/puppet/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  140. data/vendored/puppet/lib/puppet/pops/parser/lexer_support.rb +3 -2
  141. data/vendored/puppet/lib/puppet/pops/parser/locator.rb +0 -2
  142. data/vendored/puppet/lib/puppet/pops/parser/pn_parser.rb +316 -0
  143. data/vendored/puppet/lib/puppet/pops/pcore.rb +17 -17
  144. data/vendored/puppet/lib/puppet/pops/pn.rb +236 -0
  145. data/vendored/puppet/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  146. data/vendored/puppet/lib/puppet/pops/types/class_loader.rb +6 -3
  147. data/vendored/puppet/lib/puppet/pops/types/implementation_registry.rb +28 -35
  148. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +3 -3
  149. data/vendored/puppet/lib/puppet/pops/types/p_timespan_type.rb +2 -2
  150. data/vendored/puppet/lib/puppet/pops/types/p_type_set_type.rb +24 -1
  151. data/vendored/puppet/lib/puppet/pops/types/ruby_generator.rb +3 -4
  152. data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +1 -1
  153. data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +0 -4
  154. data/vendored/puppet/lib/puppet/pops/types/type_mismatch_describer.rb +1 -1
  155. data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +14 -7
  156. data/vendored/puppet/lib/puppet/pops/types/types.rb +1 -1
  157. data/vendored/puppet/lib/puppet/pops/utils.rb +2 -2
  158. data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +6 -2
  159. data/vendored/puppet/lib/puppet/provider/group/groupadd.rb +3 -1
  160. data/vendored/puppet/lib/puppet/provider/group/windows_adsi.rb +4 -7
  161. data/vendored/puppet/lib/puppet/provider/nameservice.rb +3 -3
  162. data/vendored/puppet/lib/puppet/provider/package/dnf.rb +1 -1
  163. data/vendored/puppet/lib/puppet/provider/package/gem.rb +1 -1
  164. data/vendored/puppet/lib/puppet/provider/package/pacman.rb +4 -4
  165. data/vendored/puppet/lib/puppet/provider/package/pip.rb +3 -3
  166. data/vendored/puppet/lib/puppet/provider/package/pkgdmg.rb +3 -3
  167. data/vendored/puppet/lib/puppet/provider/package/pkgutil.rb +2 -2
  168. data/vendored/puppet/lib/puppet/provider/package/portage.rb +9 -9
  169. data/vendored/puppet/lib/puppet/provider/package/zypper.rb +2 -2
  170. data/vendored/puppet/lib/puppet/provider/service/base.rb +1 -1
  171. data/vendored/puppet/lib/puppet/provider/service/smf.rb +3 -2
  172. data/vendored/puppet/lib/puppet/provider/user/useradd.rb +6 -2
  173. data/vendored/puppet/lib/puppet/provider/user/windows_adsi.rb +1 -1
  174. data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +3 -2
  175. data/vendored/puppet/lib/puppet/reference/configuration.rb +2 -0
  176. data/vendored/puppet/lib/puppet/reference/type.rb +11 -11
  177. data/vendored/puppet/lib/puppet/resource.rb +1 -1
  178. data/vendored/puppet/lib/puppet/resource/capability_finder.rb +2 -2
  179. data/vendored/puppet/lib/puppet/resource/catalog.rb +2 -2
  180. data/vendored/puppet/lib/puppet/resource/status.rb +9 -2
  181. data/vendored/puppet/lib/puppet/resource/type.rb +1 -1
  182. data/vendored/puppet/lib/puppet/settings.rb +31 -19
  183. data/vendored/puppet/lib/puppet/settings/base_setting.rb +5 -0
  184. data/vendored/puppet/lib/puppet/settings/config_file.rb +1 -1
  185. data/vendored/puppet/lib/puppet/settings/ttl_setting.rb +5 -0
  186. data/vendored/puppet/lib/puppet/ssl/certificate_factory.rb +2 -2
  187. data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +0 -2
  188. data/vendored/puppet/lib/puppet/transaction/additional_resource_generator.rb +2 -2
  189. data/vendored/puppet/lib/puppet/transaction/event.rb +1 -1
  190. data/vendored/puppet/lib/puppet/transaction/report.rb +1 -1
  191. data/vendored/puppet/lib/puppet/type.rb +9 -13
  192. data/vendored/puppet/lib/puppet/type/augeas.rb +2 -2
  193. data/vendored/puppet/lib/puppet/type/cron.rb +11 -6
  194. data/vendored/puppet/lib/puppet/type/exec.rb +1 -1
  195. data/vendored/puppet/lib/puppet/type/file.rb +4 -5
  196. data/vendored/puppet/lib/puppet/type/host.rb +1 -1
  197. data/vendored/puppet/lib/puppet/type/k5login.rb +30 -54
  198. data/vendored/puppet/lib/puppet/type/package.rb +3 -3
  199. data/vendored/puppet/lib/puppet/type/schedule.rb +12 -12
  200. data/vendored/puppet/lib/puppet/type/scheduled_task.rb +2 -2
  201. data/vendored/puppet/lib/puppet/type/ssh_authorized_key.rb +5 -5
  202. data/vendored/puppet/lib/puppet/type/sshkey.rb +2 -2
  203. data/vendored/puppet/lib/puppet/type/tidy.rb +9 -2
  204. data/vendored/puppet/lib/puppet/type/user.rb +1 -1
  205. data/vendored/puppet/lib/puppet/type/yumrepo.rb +25 -4
  206. data/vendored/puppet/lib/puppet/type/zfs.rb +4 -0
  207. data/vendored/puppet/lib/puppet/util.rb +0 -4
  208. data/vendored/puppet/lib/puppet/util/backups.rb +1 -1
  209. data/vendored/puppet/lib/puppet/util/http_proxy.rb +4 -2
  210. data/vendored/puppet/lib/puppet/util/inifile.rb +3 -4
  211. data/vendored/puppet/lib/puppet/util/log.rb +2 -5
  212. data/vendored/puppet/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  213. data/vendored/puppet/lib/puppet/util/reference.rb +1 -8
  214. data/vendored/puppet/lib/puppet/util/tagging.rb +1 -1
  215. data/vendored/puppet/lib/puppet/util/warnings.rb +0 -2
  216. data/vendored/puppet/lib/puppet/util/windows/adsi.rb +15 -18
  217. data/vendored/puppet/lib/puppet/util/windows/com.rb +2 -1
  218. data/vendored/puppet/lib/puppet/util/windows/file.rb +2 -2
  219. data/vendored/puppet/lib/puppet/util/windows/principal.rb +7 -6
  220. data/vendored/puppet/lib/puppet/util/windows/sid.rb +60 -7
  221. data/vendored/puppet/lib/puppet/util/windows/taskscheduler.rb +0 -9
  222. data/vendored/puppet/lib/puppet/version.rb +1 -1
  223. data/vendored/puppet/lib/puppet_pal.rb +53 -48
  224. metadata +15 -2
@@ -5,10 +5,6 @@ class Puppet::Node::Facts::Yaml < Puppet::Indirector::Yaml
5
5
  desc "Store client facts as flat files, serialized using YAML, or
6
6
  return deserialized facts from disk."
7
7
 
8
- def allow_remote_requests?
9
- false
10
- end
11
-
12
8
  def search(request)
13
9
  node_names = []
14
10
  Dir.glob(yaml_dir_path).each do |file|
@@ -1,15 +1,17 @@
1
1
  require 'puppet/file_serving/metadata'
2
2
  require 'puppet/indirector/generic_http'
3
+ require 'puppet/network/http'
3
4
 
4
5
  class Puppet::Indirector::FileContent::Http < Puppet::Indirector::GenericHttp
5
6
  desc "Retrieve file contents from a remote HTTP server."
6
7
 
7
8
  include Puppet::FileServing::TerminusHelper
9
+ include Puppet::Network::HTTP::Compression.module
8
10
 
9
11
  @http_method = :get
10
12
 
11
13
  def find(request)
12
14
  response = super
13
- model.from_binary(response.body)
15
+ model.from_binary(uncompress_body(response))
14
16
  end
15
17
  end
@@ -163,7 +163,9 @@ class Puppet::Indirector::Indirection
163
163
  # remove it, we expire it and write it back out to disk. This way people
164
164
  # can still use the expired object if they want.
165
165
  def expire(key, options={})
166
- return nil unless cache?
166
+ request = request(:expire, key, nil, options)
167
+
168
+ return nil unless cache? && !request.ignore_cache_save?
167
169
 
168
170
  return nil unless instance = cache.find(request(:find, key, nil, options))
169
171
 
@@ -196,7 +198,7 @@ class Puppet::Indirector::Indirection
196
198
  result = terminus.find(request)
197
199
  if not result.nil?
198
200
  result.expiration ||= self.expiration if result.respond_to?(:expiration)
199
- if cache?
201
+ if cache? && !request.ignore_cache_save?
200
202
  Puppet.info _("Caching %{indirection} for %{request}") % { indirection: self.name, request: request.key }
201
203
  begin
202
204
  cache.save request(:save, key, result, options)
@@ -287,7 +289,7 @@ class Puppet::Indirector::Indirection
287
289
  result = terminus.save(request)
288
290
 
289
291
  # If caching is enabled, save our document there
290
- cache.save(request) if cache?
292
+ cache.save(request) if cache? && !request.ignore_cache_save?
291
293
 
292
294
  result
293
295
  end
@@ -10,7 +10,7 @@ require 'puppet/util/psych_support'
10
10
  class Puppet::Indirector::Request
11
11
  include Puppet::Util::PsychSupport
12
12
 
13
- attr_accessor :key, :method, :options, :instance, :node, :ip, :authenticated, :ignore_cache, :ignore_terminus
13
+ attr_accessor :key, :method, :options, :instance, :node, :ip, :authenticated, :ignore_cache, :ignore_cache_save, :ignore_terminus
14
14
 
15
15
  attr_accessor :server, :port, :uri, :protocol
16
16
 
@@ -18,7 +18,7 @@ class Puppet::Indirector::Request
18
18
 
19
19
  # trusted_information is specifically left out because we can't serialize it
20
20
  # and keep it "trusted"
21
- OPTION_ATTRIBUTES = [:ip, :node, :authenticated, :ignore_terminus, :ignore_cache, :instance, :environment]
21
+ OPTION_ATTRIBUTES = [:ip, :node, :authenticated, :ignore_terminus, :ignore_cache, :ignore_cache_save, :instance, :environment]
22
22
 
23
23
  # Is this an authenticated request?
24
24
  def authenticated?
@@ -50,6 +50,10 @@ class Puppet::Indirector::Request
50
50
  ignore_cache
51
51
  end
52
52
 
53
+ def ignore_cache_save?
54
+ ignore_cache_save
55
+ end
56
+
53
57
  def ignore_terminus?
54
58
  ignore_terminus
55
59
  end
@@ -72,8 +72,6 @@ class Puppet::Module
72
72
  self.module == other.module
73
73
  end
74
74
 
75
- private
76
-
77
75
  def self.new_with_files(pup_module, name, tasks_files)
78
76
  files = tasks_files.map do |filename|
79
77
  File.join(pup_module.tasks_directory, File.basename(filename))
@@ -82,9 +80,11 @@ class Puppet::Module
82
80
  metadata_files, exe_files = files.partition { |f| is_tasks_metadata_filename?(f) }
83
81
  Puppet::Module::Task.new(pup_module, name, exe_files, metadata_files.first)
84
82
  end
83
+ private_class_method :new_with_files
85
84
 
86
85
  def self.task_name_from_path(path)
87
86
  return File.basename(path, '.*')
88
87
  end
88
+ private_class_method :task_name_from_path
89
89
  end
90
90
  end
@@ -3,24 +3,77 @@ class Puppet::ModuleTool::Tar::Mini
3
3
  Zlib::GzipReader.open(sourcefile) do |reader|
4
4
  Archive::Tar::Minitar.unpack(reader, destdir, find_valid_files(reader)) do |action, name, stats|
5
5
  case action
6
- when :file_done
7
- File.chmod(0644, "#{destdir}/#{name}")
8
- when :dir, :file_start
6
+ when :dir
9
7
  validate_entry(destdir, name)
8
+ set_dir_mode!(stats)
9
+ Puppet.debug("Extracting: #{destdir}/#{name}")
10
+ when :file_start
11
+ # Octal string of the old file mode.
12
+ validate_entry(destdir, name)
13
+ set_file_mode!(stats)
10
14
  Puppet.debug("Extracting: #{destdir}/#{name}")
11
15
  end
16
+ set_default_user_and_group!(stats)
17
+ stats
12
18
  end
13
19
  end
14
20
  end
15
21
 
16
22
  def pack(sourcedir, destfile)
17
23
  Zlib::GzipWriter.open(destfile) do |writer|
18
- Archive::Tar::Minitar.pack(sourcedir, writer)
24
+ Archive::Tar::Minitar.pack(sourcedir, writer) do |step, name, stats|
25
+ # TODO smcclellan 2017-10-31 Set permissions here when this yield block
26
+ # executes before the header is written. As it stands, the `stats`
27
+ # argument isn't mutable in a way that will effect the desired mode for
28
+ # the file.
29
+ end
19
30
  end
20
31
  end
21
32
 
22
33
  private
23
34
 
35
+ EXECUTABLE = 0755
36
+ NOT_EXECUTABLE = 0644
37
+ USER_EXECUTE = 0100
38
+
39
+ def set_dir_mode!(stats)
40
+ if stats.key?(:mode)
41
+ # This is only the case for `pack`, so this code will not run.
42
+ stats[:mode] = EXECUTABLE
43
+ elsif stats.key?(:entry)
44
+ old_mode = stats[:entry].instance_variable_get(:@mode)
45
+ if old_mode.is_a?(Integer)
46
+ stats[:entry].instance_variable_set(:@mode, EXECUTABLE)
47
+ end
48
+ end
49
+ end
50
+
51
+ # Sets a file mode to 0755 if the file is executable by the user.
52
+ # Sets a file mode to 0644 if the file mode is set (non-Windows).
53
+ def sanitized_mode(old_mode)
54
+ old_mode & USER_EXECUTE != 0 ? EXECUTABLE : NOT_EXECUTABLE
55
+ end
56
+
57
+ def set_file_mode!(stats)
58
+ if stats.key?(:mode)
59
+ # This is only the case for `pack`, so this code will not run.
60
+ stats[:mode] = sanitized_mode(stats[:mode])
61
+ elsif stats.key?(:entry)
62
+ old_mode = stats[:entry].instance_variable_get(:@mode)
63
+ # If the user can execute the file, set 0755, otherwise 0644.
64
+ if old_mode.is_a?(Integer)
65
+ new_mode = sanitized_mode(old_mode)
66
+ stats[:entry].instance_variable_set(:@mode, new_mode)
67
+ end
68
+ end
69
+ end
70
+
71
+ # Sets UID and GID to 0 for standardization.
72
+ def set_default_user_and_group!(stats)
73
+ stats[:uid] = 0
74
+ stats[:gid] = 0
75
+ end
76
+
24
77
  # Find all the valid files in tarfile.
25
78
  #
26
79
  # This check was mainly added to ignore 'x' and 'g' flags from the PAX
@@ -38,7 +38,7 @@ module Puppet
38
38
  { :acl => "#{ca_url_prefix}/v1/certificate/", :method => :find, :authenticated => :any },
39
39
  { :acl => "#{ca_url_prefix}/v1/certificate_request", :method => [:find, :save], :authenticated => :any },
40
40
  ]
41
- end
41
+ end
42
42
 
43
43
  # Just proxy the setting methods to our rights stuff
44
44
  [:allow, :deny].each do |method|
@@ -265,6 +265,7 @@ class Puppet::Network::HTTP::API::IndirectedRoutes
265
265
  # NOTE These specific hooks for paths are ridiculous, but it's a *many*-line
266
266
  # fix to not need this, and our goal is to move away from the complication
267
267
  # that leads to the fix being too long.
268
+ return :singular if indirection == "facts"
268
269
  return :singular if indirection == "status"
269
270
  return :singular if indirection == "certificate_status"
270
271
 
@@ -40,8 +40,6 @@ module Puppet::Network::Resolver
40
40
  end
41
41
  end
42
42
 
43
- private
44
-
45
43
  def self.each_priority(records)
46
44
  pri_hash = records.inject({}) do |groups, element|
47
45
  groups[element.priority] ||= []
@@ -53,6 +51,7 @@ module Puppet::Network::Resolver
53
51
  yield key, pri_hash[key]
54
52
  end
55
53
  end
54
+ private_class_method :each_priority
56
55
 
57
56
  def self.find_weighted_server(records)
58
57
  return nil if records.nil? || records.empty?
@@ -28,9 +28,10 @@ class Puppet::Node
28
28
  @classes = data['classes'] || []
29
29
  @parameters = data['parameters'] || {}
30
30
  env_name = data['environment'] || @parameters[ENVIRONMENT]
31
- env_name = env_name.intern unless env_name.nil?
32
- @environment_name = env_name
33
- self.environment = env_name
31
+ unless env_name.nil?
32
+ @parameters[ENVIRONMENT] = env_name
33
+ @environment_name = env_name.intern
34
+ end
34
35
  end
35
36
 
36
37
  def self.from_data_hash(data)
@@ -41,7 +41,7 @@ class Puppet::Parser::Compiler
41
41
  message = _("%{message} on node %{node}") % { message: detail, node: node.name }
42
42
  Puppet.log_exception(detail, message)
43
43
  raise Puppet::Error, message, detail.backtrace
44
- end
44
+ end
45
45
 
46
46
  attr_reader :node, :facts, :collections, :catalog, :resources, :relationships, :topscope
47
47
  attr_reader :qualified_variables
@@ -460,10 +460,10 @@ class Puppet::Parser::Compiler
460
460
  component_ref = args['component']
461
461
  kind = args['kind']
462
462
 
463
- # That component_ref is either a QNAME or a Class['literal'|QREF] is asserted during validation so no
463
+ # That component_ref is either a QREF or a Class['literal'|QREF] is asserted during validation so no
464
464
  # need to check that here
465
- if component_ref.is_a?(Puppet::Pops::Model::QualifiedName)
466
- component_name = component_ref.value
465
+ if component_ref.is_a?(Puppet::Pops::Model::QualifiedReference)
466
+ component_name = component_ref.cased_value
467
467
  component_type = 'type'
468
468
  component = krt.find_definition(component_name)
469
469
  else
@@ -664,7 +664,7 @@ class Puppet::Parser::Compiler
664
664
  data[target] = source_data.merge(metaparams_as_data(target, names))
665
665
  end
666
666
 
667
- target.tag(*(source.tags))
667
+ target.merge_tags_from(source)
668
668
  end
669
669
  end
670
670
 
@@ -747,9 +747,16 @@ class Puppet::Parser::Compiler
747
747
  # Set the node's parameters into the top-scope as variables.
748
748
  def set_node_parameters
749
749
  node.parameters.each do |param, value|
750
+ # We don't want to set @topscope['environment'] from the parameters,
751
+ # instead we want to get that from the node's environment itself in
752
+ # case a custom node terminus has done any mucking about with
753
+ # node.parameters.
754
+ next if param.to_s == 'environment'
750
755
  # Ensure node does not leak Symbol instances in general
751
756
  @topscope[param.to_s] = value.is_a?(Symbol) ? value.to_s : value
752
757
  end
758
+ @topscope['environment'] = node.environment.name.to_s
759
+
753
760
  # These might be nil.
754
761
  catalog.client_version = node.parameters["clientversion"]
755
762
  catalog.server_version = node.parameters["serverversion"]
@@ -1,7 +1,7 @@
1
1
  class Puppet::Parser::Compiler
2
2
  # Validator that asserts that all capability resources that are referenced by 'consume' or 'require' has
3
3
  # been exported by some other resource in the environment
4
- class CatalogValidator::EnvironmentRelationshipValidator < CatalogValidator
4
+ class CatalogValidator::EnvironmentRelationshipValidator < CatalogValidator
5
5
 
6
6
  def validate
7
7
  assumed_exports = {}
@@ -1,3 +1,4 @@
1
+ require 'digest/md5'
1
2
  require 'digest/sha2'
2
3
 
3
4
  Puppet::Parser::Functions::newfunction(:fqdn_rand, :arity => -2, :type => :rvalue, :doc =>
@@ -17,9 +18,19 @@ Puppet::Parser::Functions::newfunction(:fqdn_rand, :arity => -2, :type => :rvalu
17
18
  `fqdn_rand(30, 'expensive job 2')` will produce totally different numbers.)") do |args|
18
19
  max = args.shift.to_i
19
20
 
20
- # We are consciously not using different hash algs based on fips mode here
21
- # since the randomness is not guaranteed to be predictable for a given node
22
- # It just needs to be unique for a given node
23
- seed = Digest::SHA256.hexdigest([self['::fqdn'],max,args].join(':')).hex
21
+ # Puppet 5.4's fqdn_rand function produces a different value than earlier versions
22
+ # for the same set of inputs.
23
+ # This causes problems because the values are often written into service configuration files.
24
+ # When they change, services get notified and restart.
25
+
26
+ # Restoring previous fqdn_rand behavior of calculating its seed value using MD5
27
+ # when running on a non-FIPS enabled platform and only using SHA256 on FIPS enabled
28
+ # platforms.
29
+ if Puppet::Util::Platform.fips_enabled?
30
+ seed = Digest::SHA256.hexdigest([self['::fqdn'],max,args].join(':')).hex
31
+ else
32
+ seed = Digest::MD5.hexdigest([self['::fqdn'],max,args].join(':')).hex
33
+ end
34
+
24
35
  Puppet::Util.deterministic_rand_int(seed,max)
25
36
  end
@@ -56,16 +56,14 @@ Would fail with an assertion error (since value is less than 0).
56
56
  The following sections show the arguments and conversion rules
57
57
  per data type built into the Puppet Type System.
58
58
 
59
- Conversion to Optional[T] and NotUndef[T]
60
- -----------------------------------------
59
+ ### Conversion to Optional[T] and NotUndef[T]
61
60
 
62
61
  Conversion to these data types is the same as a conversion to the type argument `T`.
63
62
  In the case of `Optional[T]` it is accepted that the argument to convert may be `undef`.
64
63
  It is however not acceptable to give other arguments (than `undef`) that cannot be
65
64
  converted to `T`.
66
65
 
67
- Conversion to Integer
68
- ---------------------
66
+ ### Conversion to Integer
69
67
 
70
68
  A new `Integer` can be created from `Integer`, `Float`, `Boolean`, and `String` values.
71
69
  For conversion from `String` it is possible to specify the radix (base).
@@ -113,8 +111,7 @@ $a_number = Integer(true) # results in 1
113
111
  $a_number = Integer(-38, 10, true) # results in 38
114
112
  ```
115
113
 
116
- Conversion to Float
117
- -------------------
114
+ ### Conversion to Float
118
115
 
119
116
  A new `Float` can be created from `Integer`, `Float`, `Boolean`, and `String` values.
120
117
  For conversion from `String` both float and integer formats are supported.
@@ -126,15 +123,13 @@ function Float.new(
126
123
  )
127
124
  ```
128
125
 
129
-
130
126
  * For an integer, the floating point fraction of `.0` is added to the value.
131
127
  * A `Boolean` `true` is converted to 1.0, and a `false` to 0.0
132
128
  * In `String` format, integer prefixes for hex and binary are understood (but not octal since
133
129
  floating point in string format may start with a '0').
134
130
  * When `abs` is set to `true`, the result will be an absolute floating point value.
135
131
 
136
- Conversion to Numeric
137
- ---------------------
132
+ ### Conversion to Numeric
138
133
 
139
134
  A new `Integer` or `Float` can be created from `Integer`, `Float`, `Boolean` and
140
135
  `String` values.
@@ -163,8 +158,7 @@ $a_number = Numeric(-42.3, true) # results in 42.3
163
158
  $a_number = Numeric(-42, true) # results in 42
164
159
  ```
165
160
 
166
- Conversion to Timespan
167
- -------------------
161
+ ### Conversion to Timespan
168
162
 
169
163
  A new `Timespan` can be created from `Integer`, `Float`, `String`, and `Hash` values. Several variants of the constructor are provided.
170
164
 
@@ -281,8 +275,7 @@ $duration = Timespan('10:03.5', '%M:%S.%L') # 10 minutes, 3 seconds, and 5 milli
281
275
  $duration = Timespan('10:03.5', '%M:%S.%N') # 10 minutes, 3 seconds, and 5 nano-seconds
282
276
  ```
283
277
 
284
- Conversion to Timestamp
285
- -------------------
278
+ ### Conversion to Timestamp
286
279
 
287
280
  A new `Timestamp` can be created from `Integer`, `Float`, `String`, and `Hash` values. Several variants of the constructor are provided.
288
281
 
@@ -475,8 +468,8 @@ $ts = Timestamp('2016-08-24T12:13:14', default, 'PST') # 2016-08-24 20:13:14.0
475
468
 
476
469
  ```
477
470
 
478
- Conversion to Type
479
- ------------------
471
+ ### Conversion to Type
472
+
480
473
  A new `Type` can be create from its `String` representation.
481
474
 
482
475
  **Example:** Creating a type from a string
@@ -485,8 +478,7 @@ A new `Type` can be create from its `String` representation.
485
478
  $t = Type.new('Integer[10]')
486
479
  ```
487
480
 
488
- Conversion to String
489
- --------------------
481
+ ### Conversion to String
490
482
 
491
483
  Conversion to `String` is the most comprehensive conversion as there are many
492
484
  use cases where a string representation is wanted. The defaults for the many options
@@ -529,7 +521,7 @@ included in a string format.
529
521
  Note that all data type supports the formats `s` and `p` with the meaning "default string representation" and
530
522
  "default programmatic string representation" (which for example means that a String is quoted in 'p' format).
531
523
 
532
- ### Signatures of String conversion
524
+ #### Signatures of String conversion
533
525
 
534
526
  ```puppet
535
527
  type Format = Pattern[/^%([\s\+\-#0\[\{<\(\|]*)([1-9][0-9]*)?(?:\.([0-9]+))?([a-zA-Z])/]
@@ -587,7 +579,7 @@ $str = String([1,2,3], $formats) # produces '(0x1, 0x2, 0x3)'
587
579
  The given formats are merged with the default formats, and matching of values to convert against format is based on
588
580
  the specificity of the mapped type; for example, different formats can be used for short and long arrays.
589
581
 
590
- ### Integer to String
582
+ #### Integer to String
591
583
 
592
584
  | Format | Integer Formats
593
585
  | ------ | ---------------
@@ -602,7 +594,7 @@ the specificity of the mapped type; for example, different formats can be used f
602
594
 
603
595
  Defaults to `d`.
604
596
 
605
- ### Float to String
597
+ #### Float to String
606
598
 
607
599
  | Format | Float formats
608
600
  | ------ | -------------
@@ -616,7 +608,7 @@ Defaults to `d`.
616
608
 
617
609
  Defaults to `p`.
618
610
 
619
- ### String to String
611
+ #### String to String
620
612
 
621
613
  | Format | String
622
614
  | ------ | ------
@@ -630,7 +622,7 @@ Defaults to `p`.
630
622
 
631
623
  Defaults to `s` at top level and `p` inside array or hash.
632
624
 
633
- ### Boolean to String
625
+ #### Boolean to String
634
626
 
635
627
  | Format | Boolean Formats
636
628
  | ---- | -------------------
@@ -641,14 +633,14 @@ Defaults to `s` at top level and `p` inside array or hash.
641
633
  | s | String 'true' / 'false'.
642
634
  | p | String 'true' / 'false'.
643
635
 
644
- ### Regexp to String
636
+ #### Regexp to String
645
637
 
646
638
  | Format | Regexp Formats
647
639
  | ---- | --------------
648
640
  | s | No delimiters, quoted if alternative flag `#` is used.
649
641
  | p | Delimiters `/ /`.
650
642
 
651
- ### Undef to String
643
+ #### Undef to String
652
644
 
653
645
  | Format | Undef formats
654
646
  | ------ | -------------
@@ -661,7 +653,7 @@ Defaults to `s` at top level and `p` inside array or hash.
661
653
  | V | String 'N/A'.
662
654
  | u | String 'undef', or 'undefined' if alternative `#` flag is used.
663
655
 
664
- ### Default value to String
656
+ #### Default value to String
665
657
 
666
658
  | Format | Default formats
667
659
  | ------ | ---------------
@@ -669,7 +661,7 @@ Defaults to `s` at top level and `p` inside array or hash.
669
661
  | s | Same as d.
670
662
  | p | Same as d.
671
663
 
672
- ### Binary value to String
664
+ #### Binary value to String
673
665
 
674
666
  | Format | Default formats
675
667
  | ------ | ---------------
@@ -686,7 +678,7 @@ Defaults to `s` at top level and `p` inside array or hash.
686
678
  as hex escaped characters on the form `\\xHH` where `H` is a hex digit.
687
679
  * The width and precision values are applied to the text part only in `%p` format.
688
680
 
689
- ### Array & Tuple to String
681
+ #### Array & Tuple to String
690
682
 
691
683
  | Format | Array/Tuple Formats
692
684
  | ------ | -------------
@@ -701,7 +693,7 @@ The alternate form flag `#` will cause indentation of nested array or hash conta
701
693
  it is taken as the maximum allowed length of a sequence of elements (not including delimiters). If this max length
702
694
  is exceeded, each element will be indented.
703
695
 
704
- ### Hash & Struct to String
696
+ #### Hash & Struct to String
705
697
 
706
698
  | Format | Hash/Struct Formats
707
699
  | ------ | -------------
@@ -715,14 +707,14 @@ more information about options.
715
707
 
716
708
  The alternate form flag `#` will format each hash key/value entry indented on a separate line.
717
709
 
718
- ### Type to String
710
+ #### Type to String
719
711
 
720
712
  | Format | Array/Tuple Formats
721
713
  | ------ | -------------
722
714
  | s | The same as `p`, quoted if alternative flag `#` is used.
723
715
  | p | Outputs the type in string form as specified by the Puppet Language.
724
716
 
725
- ### Flags
717
+ #### Flags
726
718
 
727
719
  | Flag | Effect
728
720
  | ------ | ------
@@ -733,8 +725,7 @@ The alternate form flag `#` will format each hash key/value entry indented on a
733
725
  | 0 | Pad with 0 instead of space for widths larger than value.
734
726
  | <[({\| | Defines an enclosing pair <> [] () {} or \| \| when used with a container type.
735
727
 
736
- Conversion to Boolean
737
- ---
728
+ ### Conversion to Boolean
738
729
 
739
730
  Accepts a single value as argument:
740
731
 
@@ -745,8 +736,7 @@ Accepts a single value as argument:
745
736
  * `false` if 'false', 'no', 'n' (case independent compare)
746
737
  * Boolean is already boolean and is simply returned
747
738
 
748
- Conversion to Array and Tuple
749
- ---
739
+ ### Conversion to Array and Tuple
750
740
 
751
741
  When given a single value as argument:
752
742
 
@@ -771,8 +761,7 @@ $arr = Array($value, true)
771
761
  Conversion to a `Tuple` works exactly as conversion to an `Array`, only that the constructed array is
772
762
  asserted against the given tuple type.
773
763
 
774
- Conversion to Hash and Struct
775
- ---
764
+ ### Conversion to Hash and Struct
776
765
 
777
766
  Accepts a single value as argument:
778
767
 
@@ -811,8 +800,8 @@ Would notice the hash `{a => {b => {x => wine}}, b => {y => wine}}`
811
800
  Conversion to a `Struct` works exactly as conversion to a `Hash`, only that the constructed hash is
812
801
  asserted against the given struct type.
813
802
 
814
- Conversion to a Regexp
815
- ---
803
+ ### Conversion to a Regexp
804
+
816
805
  A `String` can be converted into a `Regexp`
817
806
 
818
807
  **Example**: Converting a String into a Regexp
@@ -824,8 +813,7 @@ if('foo.com' =~ $r) {
824
813
  }
825
814
  ```
826
815
 
827
- Creating a SemVer
828
- ---
816
+ ### Creating a SemVer
829
817
 
830
818
  A SemVer object represents a single [Semantic Version](http://semver.org/).
831
819
  It can be created from a String, individual values for its parts, or a hash specifying the value per part.
@@ -874,8 +862,7 @@ notice(SemVer('2.3.4') =~ $t) # false
874
862
  notice(SemVer('3.4.5') =~ $t) # true
875
863
  ```
876
864
 
877
- Creating a SemVerRange
878
- ---
865
+ ### Creating a SemVerRange
879
866
 
880
867
  A `SemVerRange` object represents a range of `SemVer`. It can be created from
881
868
  a `String`, or from two `SemVer` instances, where either end can be given as
@@ -909,10 +896,9 @@ function SemVerRange.new(
909
896
  )
910
897
  ```
911
898
 
912
- For examples of `SemVerRange` use see "Creating a SemVer"
899
+ For examples of `SemVerRange` use, see "Creating a SemVer".
913
900
 
914
- Creating a Binary
915
- ---
901
+ ### Creating a Binary
916
902
 
917
903
  A `Binary` object represents a sequence of bytes and it can be created from a String in Base64 format,
918
904
  an Array containing byte values. A Binary can also be created from a Hash containing the value to convert to
@@ -932,7 +918,6 @@ function Binary.new(
932
918
  Optional[Base64Format] $format
933
919
  )
934
920
 
935
-
936
921
  function Binary.new(
937
922
  Array[ByteInteger] $byte_array
938
923
  }