puppet 6.21.1-universal-darwin → 6.22.1-universal-darwin

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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +24 -18
  4. data/ext/project_data.yaml +2 -2
  5. data/lib/puppet/application/ssl.rb +11 -0
  6. data/lib/puppet/defaults.rb +22 -2
  7. data/lib/puppet/environments.rb +16 -1
  8. data/lib/puppet/face/facts.rb +128 -30
  9. data/lib/puppet/file_system/memory_file.rb +8 -1
  10. data/lib/puppet/file_system/windows.rb +2 -0
  11. data/lib/puppet/functions/partition.rb +8 -0
  12. data/lib/puppet/indirector/facts/facter.rb +24 -3
  13. data/lib/puppet/network/formats.rb +67 -0
  14. data/lib/puppet/network/http/factory.rb +4 -0
  15. data/lib/puppet/provider/package/dnfmodule.rb +1 -1
  16. data/lib/puppet/provider/service/systemd.rb +1 -1
  17. data/lib/puppet/provider/user/useradd.rb +1 -1
  18. data/lib/puppet/settings/environment_conf.rb +1 -0
  19. data/lib/puppet/util/fact_dif.rb +36 -17
  20. data/lib/puppet/util/monkey_patches.rb +7 -0
  21. data/lib/puppet/util/windows/adsi.rb +46 -0
  22. data/lib/puppet/util/windows/api_types.rb +1 -1
  23. data/lib/puppet/util/windows/principal.rb +9 -2
  24. data/lib/puppet/util/windows/sid.rb +4 -2
  25. data/lib/puppet/version.rb +1 -1
  26. data/locales/puppet.pot +139 -87
  27. data/man/man5/puppet.conf.5 +11 -3
  28. data/man/man8/puppet-agent.8 +1 -1
  29. data/man/man8/puppet-apply.8 +1 -1
  30. data/man/man8/puppet-catalog.8 +1 -1
  31. data/man/man8/puppet-config.8 +1 -1
  32. data/man/man8/puppet-describe.8 +1 -1
  33. data/man/man8/puppet-device.8 +1 -1
  34. data/man/man8/puppet-doc.8 +1 -1
  35. data/man/man8/puppet-epp.8 +1 -1
  36. data/man/man8/puppet-facts.8 +60 -2
  37. data/man/man8/puppet-filebucket.8 +1 -1
  38. data/man/man8/puppet-generate.8 +1 -1
  39. data/man/man8/puppet-help.8 +1 -1
  40. data/man/man8/puppet-key.8 +1 -1
  41. data/man/man8/puppet-lookup.8 +1 -1
  42. data/man/man8/puppet-man.8 +1 -1
  43. data/man/man8/puppet-module.8 +1 -1
  44. data/man/man8/puppet-node.8 +1 -1
  45. data/man/man8/puppet-parser.8 +1 -1
  46. data/man/man8/puppet-plugin.8 +1 -1
  47. data/man/man8/puppet-report.8 +1 -1
  48. data/man/man8/puppet-resource.8 +1 -1
  49. data/man/man8/puppet-script.8 +1 -1
  50. data/man/man8/puppet-ssl.8 +5 -1
  51. data/man/man8/puppet-status.8 +1 -1
  52. data/man/man8/puppet.8 +2 -2
  53. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services_vendor_preset +9 -0
  54. data/spec/integration/application/plugin_spec.rb +1 -1
  55. data/spec/integration/http/client_spec.rb +12 -0
  56. data/spec/integration/indirector/direct_file_server_spec.rb +1 -3
  57. data/spec/integration/util/windows/adsi_spec.rb +18 -0
  58. data/spec/integration/util/windows/principal_spec.rb +21 -0
  59. data/spec/integration/util/windows/registry_spec.rb +6 -0
  60. data/spec/spec_helper.rb +11 -1
  61. data/spec/unit/application/facts_spec.rb +482 -3
  62. data/spec/unit/application/ssl_spec.rb +23 -0
  63. data/spec/unit/defaults_spec.rb +16 -0
  64. data/spec/unit/environments_spec.rb +164 -88
  65. data/spec/unit/face/facts_spec.rb +4 -0
  66. data/spec/unit/file_system_spec.rb +9 -0
  67. data/spec/unit/indirector/facts/facter_spec.rb +95 -0
  68. data/spec/unit/network/formats_spec.rb +41 -0
  69. data/spec/unit/network/http/factory_spec.rb +19 -0
  70. data/spec/unit/provider/package/dnfmodule_spec.rb +10 -1
  71. data/spec/unit/provider/service/systemd_spec.rb +11 -0
  72. data/spec/unit/provider/user/useradd_spec.rb +18 -3
  73. data/spec/unit/resource/catalog_spec.rb +1 -1
  74. data/spec/unit/util/windows/sid_spec.rb +6 -0
  75. metadata +4 -6
  76. data/spec/lib/matchers/include.rb +0 -27
  77. data/spec/lib/matchers/include_spec.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ee93175cca7e18018a8607fc1663272ecdf80b7283c69932e2fbc0bbd9a0218
4
- data.tar.gz: 97b734453ce4e59a3a5aabab929c58c8939002f2801a40cf1024c1d45744c72a
3
+ metadata.gz: 5f6df2839f6418cacbd0b1efbe293838b2e454e6eada1da7214bd64f85c2ab0b
4
+ data.tar.gz: b3377b7ebc62ef72c380d7419c63bed98cf1195368d6bfb8cdf973da2f1ab84d
5
5
  SHA512:
6
- metadata.gz: a2323af5df043cdb154a4ca9b7b3fbcc4c3bc7b581efd6f884de2471ce9b3a2f69f1fda18f348c316ff272e6b111b460543c73a1d5bf18729aadaff826c2cdb8
7
- data.tar.gz: 892b5609e917a10aa4ca0ca980106fa2ead648a39319b4c6277b76dbb42f432a5dbcd8f7af4db2155adc3131ef12aa50d009d7bac73a820df73490c22b9f9431
6
+ metadata.gz: 86fb2036780d5e04bcc9f8279415ffd77e37fe1e9b5d10f0521c63ec6229ad9e08d5b1186e158142c1d6aa1934ba108c6de75ce59bd94256b371f18950cc9017
7
+ data.tar.gz: 97f58ebbeb1b32fd437b9b7108bccc50b879adb120708a80080f109161f171bd7ba6fd8acec9c0c5879e210f297d13b24bea0e3759c957f29dedda2fe2dc609f
data/Gemfile CHANGED
@@ -56,7 +56,7 @@ group(:development, optional: true) do
56
56
  gem 'memory_profiler', require: false, platforms: [:mri]
57
57
  gem 'pry', require: false, platforms: [:ruby]
58
58
  gem "racc", "1.4.9", require: false, platforms: [:ruby]
59
- if RUBY_PLATFORM != 'java'
59
+ if RUBY_PLATFORM != 'java' && RUBY_VERSION.to_f >= 2.5
60
60
  gem 'ruby-prof', '>= 0.16.0', require: false
61
61
  end
62
62
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,18 @@
1
+ GIT
2
+ remote: git://github.com/ciprianbadescu/packaging
3
+ revision: 5f8d2bda941abfeeb8fb1731c9b1dd4d108f5d33
4
+ branch: maint/windows-signing
5
+ specs:
6
+ packaging (0.99.49.171.g5f8d2bd)
7
+ artifactory (~> 2)
8
+ csv (= 3.1.5)
9
+ rake (>= 12.3)
10
+ release-metrics
11
+
1
12
  PATH
2
13
  remote: .
3
14
  specs:
4
- puppet (6.21.1)
15
+ puppet (6.22.1)
5
16
  CFPropertyList (~> 2.2)
6
17
  concurrent-ruby (~> 1.0)
7
18
  deep_merge (~> 1.0)
@@ -29,11 +40,11 @@ GEM
29
40
  deep_merge (1.2.1)
30
41
  diff-lcs (1.4.4)
31
42
  docopt (0.6.1)
32
- facter (4.0.51)
43
+ facter (4.1.1)
33
44
  hocon (~> 1.3)
34
45
  thor (>= 1.0.1, < 2.0)
35
46
  fast_gettext (1.1.2)
36
- ffi (1.14.2)
47
+ ffi (1.15.0)
37
48
  gettext (3.2.9)
38
49
  locale (>= 2.0.5)
39
50
  text (>= 1.3.0)
@@ -42,11 +53,11 @@ GEM
42
53
  gettext (>= 3.0.2, < 3.3.0)
43
54
  locale
44
55
  hashdiff (1.0.1)
45
- hiera (3.6.0)
46
- hiera-eyaml (3.2.0)
47
- highline (~> 1.6.19)
56
+ hiera (3.7.0)
57
+ hiera-eyaml (3.2.1)
58
+ highline
48
59
  optimist
49
- highline (1.6.21)
60
+ highline (2.0.3)
50
61
  hocon (1.3.1)
51
62
  hpricot (0.8.6)
52
63
  httpclient (2.8.3)
@@ -60,22 +71,17 @@ GEM
60
71
  multi_json (1.15.0)
61
72
  mustache (1.1.1)
62
73
  optimist (3.0.1)
63
- packaging (0.99.75)
64
- artifactory (~> 2)
65
- csv (= 3.1.5)
66
- rake (>= 12.3)
67
- release-metrics
68
74
  parallel (1.20.1)
69
75
  parser (2.7.2.0)
70
76
  ast (~> 2.4.1)
71
77
  powerpack (0.1.3)
72
- pry (0.14.0)
78
+ pry (0.14.1)
73
79
  coderay (~> 1.1)
74
80
  method_source (~> 1.0)
75
81
  public_suffix (4.0.6)
76
82
  puppet-resource_api (1.8.13)
77
83
  hocon (>= 1.0)
78
- puppetserver-ca (1.9.1)
84
+ puppetserver-ca (1.9.4)
79
85
  facter (>= 2.0.1, < 5)
80
86
  racc (1.4.9)
81
87
  rainbow (2.2.2)
@@ -86,7 +92,7 @@ GEM
86
92
  release-metrics (1.1.0)
87
93
  csv
88
94
  docopt
89
- rexml (3.2.4)
95
+ rexml (3.2.5)
90
96
  ronn (0.7.3)
91
97
  hpricot (>= 0.8.2)
92
98
  mustache (>= 0.7.0)
@@ -116,14 +122,14 @@ GEM
116
122
  unicode-display_width (~> 1.0, >= 1.0.1)
117
123
  rubocop-i18n (1.2.0)
118
124
  rubocop (~> 0.49.0)
119
- ruby-prof (1.4.2)
125
+ ruby-prof (1.4.3)
120
126
  ruby-progressbar (1.11.0)
121
127
  semantic_puppet (1.0.3)
122
128
  text (1.3.1)
123
129
  thor (1.1.0)
124
130
  unicode-display_width (1.7.0)
125
131
  vcr (5.1.0)
126
- webmock (3.11.2)
132
+ webmock (3.12.2)
127
133
  addressable (>= 2.3.6)
128
134
  crack (>= 0.3.2)
129
135
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -142,7 +148,7 @@ DEPENDENCIES
142
148
  memory_profiler
143
149
  minitar (~> 0.9)
144
150
  msgpack (~> 1.2)
145
- packaging (~> 0.99)
151
+ packaging!
146
152
  pry
147
153
  puppet!
148
154
  puppet-resource_api (~> 1.5)
@@ -41,7 +41,7 @@ gem_platform_dependencies:
41
41
  gem_runtime_dependencies:
42
42
  ffi: ['> 1.9.24', '< 2']
43
43
  # win32-xxxx gems are pinned due to PUP-6445
44
- win32-dir: '= 0.4.9'
44
+ win32-dir: ['>= 0.4.9', '<= 0.7.2']
45
45
  win32-process: '= 0.7.5'
46
46
  # Use of win32-security is deprecated
47
47
  win32-security: '= 0.2.5'
@@ -51,7 +51,7 @@ gem_platform_dependencies:
51
51
  gem_runtime_dependencies:
52
52
  ffi: ['> 1.9.24', '< 2']
53
53
  # win32-xxxx gems are pinned due to PUP-6445
54
- win32-dir: '= 0.4.9'
54
+ win32-dir: ['>= 0.4.9', '<= 0.7.2']
55
55
  win32-process: '= 0.7.5'
56
56
  # Use of win32-security is deprecated
57
57
  win32-security: '= 0.2.5'
@@ -74,6 +74,9 @@ ACTIONS
74
74
  `--localca` is specified, then also remove this host's local copy of the
75
75
  CA certificate(s) and CRL bundle. if `--target CERTNAME` is specified, then
76
76
  remove the files for the specified device on this host instead of this host.
77
+
78
+ * show:
79
+ Print the full-text version of this host's certificate.
77
80
  HELP
78
81
  end
79
82
 
@@ -142,11 +145,19 @@ HELP
142
145
  end
143
146
  @machine.ensure_client_certificate
144
147
  Puppet.notice(_("Completed SSL initialization"))
148
+ when 'show'
149
+ show(certname)
145
150
  else
146
151
  raise Puppet::Error, _("Unknown action '%{action}'") % { action: action }
147
152
  end
148
153
  end
149
154
 
155
+ def show(certname)
156
+ password = @cert_provider.load_private_key_password
157
+ ssl_context = @ssl_provider.load_context(certname: certname, password: password)
158
+ puts ssl_context.client_cert.to_text
159
+ end
160
+
150
161
  def submit_request(ssl_context)
151
162
  key = @cert_provider.load_private_key(Puppet[:certname])
152
163
  unless key
@@ -58,6 +58,18 @@ module Puppet
58
58
  end
59
59
  end
60
60
 
61
+ def self.default_cadir
62
+ return "" if Puppet::Util::Platform.windows?
63
+ old_ca_dir = "#{Puppet[:ssldir]}/ca"
64
+ new_ca_dir = '/etc/puppetlabs/puppetserver/ca'
65
+
66
+ if File.exist?("#{new_ca_dir}/ca_crt.pem")
67
+ new_ca_dir
68
+ else
69
+ old_ca_dir
70
+ end
71
+ end
72
+
61
73
  ############################################################################################
62
74
  # NOTE: For information about the available values for the ":type" property of settings,
63
75
  # see the docs for Settings.define_settings
@@ -1085,6 +1097,14 @@ EOT
1085
1097
  certificate revocation checking and does not attempt to download the CRL.
1086
1098
  EOT
1087
1099
  },
1100
+ :ciphers => {
1101
+ :default => 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256',
1102
+ :type => :string,
1103
+ :desc => "The list of ciphersuites for TLS connections initiated by puppet. The
1104
+ default value is chosen to support TLS 1.0 and up, but can be made
1105
+ more restrictive if needed. The ciphersuites must be specified in OpenSSL
1106
+ format, not IANA."
1107
+ },
1088
1108
  :key_type => {
1089
1109
  :default => 'rsa',
1090
1110
  :type => :enum,
@@ -1142,7 +1162,7 @@ EOT
1142
1162
  :desc => "The name to use the Certificate Authority certificate.",
1143
1163
  },
1144
1164
  :cadir => {
1145
- :default => "$ssldir/ca",
1165
+ :default => lambda { default_cadir },
1146
1166
  :type => :directory,
1147
1167
  :desc => "The root directory for the certificate authority.",
1148
1168
  },
@@ -1760,7 +1780,7 @@ EOT
1760
1780
  },
1761
1781
  :agent_disabled_lockfile => {
1762
1782
  :default => "$statedir/agent_disabled.lock",
1763
- :type => :file,
1783
+ :type => :string,
1764
1784
  :desc => "A lock file to indicate that puppet agent runs have been administratively
1765
1785
  disabled. File contains a JSON object with state information.",
1766
1786
  },
@@ -225,6 +225,9 @@ module Puppet::Environments
225
225
  private
226
226
 
227
227
  def create_environment(name)
228
+ # interpolated modulepaths may be cached from prior environment instances
229
+ Puppet.settings.clear_environment_settings(name)
230
+
228
231
  env_symbol = name.intern
229
232
  setting_values = Puppet.settings.values(env_symbol, Puppet.settings.preferred_run_mode)
230
233
  env = Puppet::Node::Environment.create(
@@ -350,7 +353,19 @@ module Puppet::Environments
350
353
 
351
354
  # @!macro loader_list
352
355
  def list
353
- @loader.list
356
+ # Evict all that have expired, in the same way as `get`
357
+ clear_all_expired
358
+
359
+ @loader.list.map do |env|
360
+ name = env.name
361
+ old_entry = @cache[name]
362
+ if old_entry
363
+ old_entry.value
364
+ else
365
+ add_entry(name, entry(env))
366
+ env
367
+ end
368
+ end
354
369
  end
355
370
 
356
371
  # @!macro loader_search_paths
@@ -2,28 +2,20 @@ require 'puppet/indirector/face'
2
2
  require 'puppet/node/facts'
3
3
  require 'puppet/util/fact_dif'
4
4
 
5
- EXCLUDE_LIST = %w[facterversion
6
- swapfree_mb swapsize_mb
7
- load_averages\.*
8
- memory\.swap\.available_bytes memory\.swap\.capacity memory\.swap\.total_bytes
9
- memory\.swap\.used_bytes memory\.swap\.available
10
- memory\.system\.available memory\.system\.available_bytes memory\.system\.capacity memory\.swap\.used
11
- memory\.system\.total_bytes memory\.system\.used memory\.system\.used_bytes
12
- memoryfree memoryfree_mb memorysize_mb
13
- mountpoints\..* mtu_.* mountpoints\..*\.capacity
14
- networking\.interfaces\..*\.mtu networking\.mtu partitions\..*\.filesystem
15
- partitions\..*\.size_bytes partitions\..*\.mount partitions\..*\.uuid
16
- disks\..*\.size_bytes
17
- hypervisors\.lpar\.partition_number hypervisors\.xen\.privileged hypervisors\.zone\..* hypervisors\.ldom\..*
18
- processors\.speed
19
- ldom_.*
20
- boardassettag dmi\.board\.asset_tag
21
- blockdevice_.*_vendor blockdevice_.*_size
22
- system_uptime\.days system_uptime\.hours system_uptime\.seconds system_uptime\.uptime
23
- uptime_days uptime_hours uptime_seconds
24
- system_profiler\.uptime
25
- sp_uptime
26
- uptime]
5
+ EXCLUDE_LIST = %w[ ^facterversion$
6
+ ^load_averages\..*$
7
+ ^processors\.speed$
8
+ ^swapfree$ ^swapfree_mb$
9
+ ^memoryfree$ ^memoryfree_mb$
10
+ ^memory\.swap\.available_bytes$ ^memory\.swap\.used_bytes$
11
+ ^memory\.swap\.available$ ^memory\.swap\.capacity$ ^memory\.swap\.used$
12
+ ^memory\.system\.available_bytes$ ^memory\.system\.used_bytes$
13
+ ^memory\.system\.available$ ^memory\.system\.capacity$ ^memory\.system\.used$
14
+ ^mountpoints\..*\.available.*$ ^mountpoints\..*\.capacity$ ^mountpoints\..*\.used.*$
15
+ ^sp_uptime$ ^system_profiler\.uptime$
16
+ ^uptime$ ^uptime_days$ ^uptime_hours$ ^uptime_seconds$
17
+ ^system_uptime\.uptime$ ^system_uptime\.days$ ^system_uptime\.hours$ ^system_uptime\.seconds$
18
+ ]
27
19
 
28
20
  Puppet::Indirector::Face.define(:facts, '0.0.1') do
29
21
  copyright "Puppet Inc.", 2011
@@ -125,26 +117,132 @@ Puppet::Indirector::Face.define(:facts, '0.0.1') do
125
117
  $ puppet facts diff
126
118
  EOT
127
119
 
128
- render_as :json
120
+ option("--structured") do
121
+ default_to { false }
122
+ summary _("Render the different facts as structured.")
123
+ end
124
+
125
+ option("--exclude " + _("<regex>")) do
126
+ summary _("Regex used to exclude specific facts from diff.")
127
+ end
129
128
 
130
129
  when_invoked do |*args|
130
+ options = args.pop
131
+
131
132
  Puppet.settings.preferred_run_mode = :agent
132
133
  Puppet::Node::Facts.indirection.terminus_class = :facter
133
134
 
134
135
  if Puppet::Util::Package.versioncmp(Facter.value('facterversion'), '4.0.0') < 0
135
- facter3_result = Puppet::Node::Facts.indirection.find(Puppet.settings[:certname])
136
- begin
137
- require 'facter-ng'
138
- facter4_result = Puppet::Node::Facts.indirection.find(Puppet.settings[:certname])
139
- rescue LoadError
140
- raise ArgumentError, 'facter-ng could not be loaded'
136
+ cmd_flags = '--render-as json --show-legacy'
137
+
138
+ # puppet/ruby are in PATH since it was updated in the wrapper script
139
+ puppet_show_cmd = "puppet facts show"
140
+ if Puppet::Util::Platform.windows?
141
+ puppet_show_cmd = "ruby -S -- #{puppet_show_cmd}"
141
142
  end
142
- fact_diff = FactDif.new(facter3_result.to_json, facter4_result.to_json, EXCLUDE_LIST)
143
+
144
+ facter_3_result = Puppet::Util::Execution.execute("#{puppet_show_cmd} --no-facterng #{cmd_flags}", combine: false)
145
+ facter_ng_result = Puppet::Util::Execution.execute("#{puppet_show_cmd} --facterng #{cmd_flags}", combine: false)
146
+
147
+ exclude_list = options[:exclude].nil? ? EXCLUDE_LIST : EXCLUDE_LIST + [ options[:exclude] ]
148
+ fact_diff = FactDif.new(facter_3_result, facter_ng_result, exclude_list, options[:structured])
143
149
  fact_diff.difs
144
150
  else
145
151
  Puppet.warning _("Already using Facter 4. To use `puppet facts diff` remove facterng from the .conf file or run `puppet config set facterng false`.")
146
152
  exit 0
147
153
  end
148
154
  end
155
+
156
+ when_rendering :console do |result|
157
+ case result
158
+ when Array, Hash
159
+ Puppet::Util::Json.dump(result, :pretty => true)
160
+ else
161
+ result
162
+ end
163
+ end
164
+ end
165
+
166
+ action(:show) do
167
+ summary _("Retrieve current node's facts.")
168
+ arguments _("[<facts>]")
169
+ description <<-'EOT'
170
+ Reads facts from the local system using `facter` terminus.
171
+ A query can be provided to retrieve just a specific fact or a set of facts.
172
+ EOT
173
+ returns "The output of facter with added puppet specific facts."
174
+ notes <<-'EOT'
175
+
176
+ EOT
177
+ examples <<-'EOT'
178
+ retrieve facts:
179
+
180
+ $ puppet facts show os
181
+ EOT
182
+
183
+ option("--config-file " + _("<path>")) do
184
+ default_to { nil }
185
+ summary _("The location of the config file for Facter.")
186
+ end
187
+
188
+ option("--custom-dir " + _("<path>")) do
189
+ default_to { nil }
190
+ summary _("The path to a directory that contains custom facts.")
191
+ end
192
+
193
+ option("--external-dir " + _("<path>")) do
194
+ default_to { nil }
195
+ summary _("The path to a directory that contains external facts.")
196
+ end
197
+
198
+ option("--no-block") do
199
+ summary _("Disable fact blocking mechanism.")
200
+ end
201
+
202
+ option("--no-cache") do
203
+ summary _("Disable fact caching mechanism.")
204
+ end
205
+
206
+ option("--show-legacy") do
207
+ summary _("Show legacy facts when querying all facts.")
208
+ end
209
+
210
+ option("--value-only") do
211
+ summary _("Show only the value when the action is called with a single query")
212
+ end
213
+
214
+ when_invoked do |*args|
215
+ options = args.pop
216
+
217
+ Puppet.settings.preferred_run_mode = :agent
218
+ Puppet::Node::Facts.indirection.terminus_class = :facter
219
+
220
+ if options[:value_only] && !args.count.eql?(1)
221
+ options[:value_only] = nil
222
+ Puppet.warning("Incorrect use of --value-only argument; it can only be used when querying for a single fact!")
223
+ end
224
+
225
+ options[:user_query] = args
226
+ options[:resolve_options] = true
227
+ result = Puppet::Node::Facts.indirection.find(Puppet.settings[:certname], options)
228
+
229
+ if options[:value_only]
230
+ result.values.values.first
231
+ else
232
+ result.values
233
+ end
234
+ end
235
+
236
+ when_rendering :console do |result|
237
+ # VALID_TYPES = [Integer, Float, TrueClass, FalseClass, NilClass, Symbol, String, Array, Hash].freeze
238
+ # from https://github.com/puppetlabs/facter/blob/4.0.49/lib/facter/custom_facts/util/normalization.rb#L8
239
+
240
+ case result
241
+ when Array, Hash
242
+ Puppet::Util::Json.dump(result, :pretty => true)
243
+ else # one of VALID_TYPES above
244
+ result
245
+ end
246
+ end
149
247
  end
150
248
  end
@@ -7,6 +7,13 @@ class Puppet::FileSystem::MemoryFile
7
7
  new(path, :exist? => false, :executable? => false)
8
8
  end
9
9
 
10
+ def self.a_missing_directory(path)
11
+ new(path,
12
+ :exist? => false,
13
+ :executable? => false,
14
+ :directory? => true)
15
+ end
16
+
10
17
  def self.a_regular_file_containing(path, content)
11
18
  new(path, :exist? => true, :executable? => false, :content => content)
12
19
  end
@@ -18,7 +25,7 @@ class Puppet::FileSystem::MemoryFile
18
25
  def self.a_directory(path, children = [])
19
26
  new(path,
20
27
  :exist? => true,
21
- :excutable? => true,
28
+ :executable? => true,
22
29
  :directory? => true,
23
30
  :children => children)
24
31
  end
@@ -128,6 +128,8 @@ class Puppet::FileSystem::Windows < Puppet::FileSystem::Posix
128
128
  end
129
129
 
130
130
  current_sid = Puppet::Util::Windows::SID.name_to_sid(Puppet::Util::Windows::ADSI::User.current_user_name)
131
+ current_sid = Puppet::Util::Windows::SID.name_to_sid(Puppet::Util::Windows::ADSI::User.current_sam_compatible_user_name) unless current_sid
132
+
131
133
  dacl = case mode
132
134
  when 0644
133
135
  dacl = secure_dacl(current_sid)
@@ -5,13 +5,21 @@
5
5
  Puppet::Functions.create_function(:partition) do
6
6
  # @param collection A collection of things to partition.
7
7
  # @example Partition array of empty strings, results in e.g. [[''], [b, c]]
8
+ # ```puppet
8
9
  # ['', b, c].partition |$s| { $s.empty }
10
+ # ```
9
11
  # @example Partition array of strings using index, results in e.g. [['', 'ab'], ['b']]
12
+ # ```puppet
10
13
  # ['', b, ab].partition |$i, $s| { $i == 2 or $s.empty }
14
+ # ```
11
15
  # @example Partition hash of strings by key-value pair, results in e.g. [[['b', []]], [['a', [1, 2]]]]
16
+ # ```puppet
12
17
  # { a => [1, 2], b => [] }.partition |$kv| { $kv[1].empty }
18
+ # ```
13
19
  # @example Partition hash of strings by key and value, results in e.g. [[['b', []]], [['a', [1, 2]]]]
20
+ # ```puppet
14
21
  # { a => [1, 2], b => [] }.partition |$k, $v| { $v.empty }
22
+ # ```
15
23
  dispatch :partition_1 do
16
24
  required_param 'Collection', :collection
17
25
  block_param 'Callable[1,1]', :block
@@ -32,8 +32,14 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
32
32
  # Initialize core Puppet facts, such as puppetversion
33
33
  Puppet.initialize_facts
34
34
 
35
- result = Puppet::Node::Facts.new(request.key, Facter.to_hash)
36
- result.add_local_facts
35
+ result = if request.options[:resolve_options]
36
+ raise(Puppet::Error, _("puppet facts show requires version 4.0.40 or greater of Facter.")) unless Facter.respond_to?(:resolve)
37
+ find_with_options(request)
38
+ else
39
+ Puppet::Node::Facts.new(request.key, Facter.to_hash)
40
+ end
41
+
42
+ result.add_local_facts unless request.options[:resolve_options]
37
43
  result.sanitize
38
44
  result
39
45
  end
@@ -61,7 +67,7 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
61
67
 
62
68
  true
63
69
  end
64
-
70
+ dirs << request.options[:custom_dir] if request.options[:custom_dir]
65
71
  Facter.search(*dirs)
66
72
  end
67
73
 
@@ -83,6 +89,21 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
83
89
  dirs << dir
84
90
  end
85
91
 
92
+ dirs << request.options[:external_dir] if request.options[:external_dir]
86
93
  Facter.search_external dirs
87
94
  end
95
+
96
+ private
97
+
98
+ def find_with_options(request)
99
+ options = request.options
100
+ options_for_facter = String.new
101
+ options_for_facter += options[:user_query].join(' ')
102
+ options_for_facter += " --config #{options[:config_file]}" if options[:config_file]
103
+ options_for_facter += " --show-legacy" if options[:show_legacy]
104
+ options_for_facter += " --no-block" if options[:no_block] == false
105
+ options_for_facter += " --no-cache" if options[:no_cache] == false
106
+
107
+ Puppet::Node::Facts.new(request.key, Facter.resolve(options_for_facter))
108
+ end
88
109
  end
@@ -183,6 +183,73 @@ Puppet::Network::FormatHandler.create(:console,
183
183
  end
184
184
  end
185
185
 
186
+ Puppet::Network::FormatHandler.create(:flat,
187
+ :mime => 'text/x-flat-text',
188
+ :weight => 0) do
189
+
190
+ def flatten_hash(hash)
191
+ hash.each_with_object({}) do |(k, v), h|
192
+ if v.is_a? Hash
193
+ flatten_hash(v).map do |h_k, h_v|
194
+ h["#{k}.#{h_k}"] = h_v
195
+ end
196
+ elsif v.is_a? Array
197
+ v.each_with_index do |el, i|
198
+ if el.is_a? Hash
199
+ flatten_hash(el).map do |el_k, el_v|
200
+ h["#{k}.#{i}.#{el_k}"] = el_v
201
+ end
202
+ else
203
+ h["#{k}.#{i}"] = el
204
+ end
205
+ end
206
+ else
207
+ h[k] = v
208
+ end
209
+ end
210
+ end
211
+
212
+ def flatten_array(array)
213
+ a={}
214
+ array.each_with_index do |el, i|
215
+ if el.is_a? Hash
216
+ flatten_hash(el).map do |el_k, el_v|
217
+ a["#{i}.#{el_k}"] = el_v
218
+ end
219
+ else
220
+ a["#{i}"] = el
221
+ end
222
+ end
223
+ a
224
+ end
225
+
226
+ def construct_output(data)
227
+ output = ''
228
+ data.each do |key, value|
229
+ output << "#{key}=#{value}"
230
+ output << "\n"
231
+ end
232
+ output
233
+ end
234
+
235
+ def render(datum)
236
+ return datum if datum.is_a?(String) || datum.is_a?(Numeric)
237
+ # Simple hash
238
+ if datum.is_a?(Hash)
239
+ data = flatten_hash(datum)
240
+ return construct_output(data)
241
+ elsif datum.is_a?(Array)
242
+ data = flatten_array(datum)
243
+ return construct_output(data)
244
+ end
245
+ Puppet::Util::Json.dump(datum, :pretty => true, :quirks_mode => true)
246
+ end
247
+ def render_multiple(data)
248
+ data.collect(&:render).join("\n")
249
+ end
250
+ end
251
+
252
+
186
253
  Puppet::Network::FormatHandler.create(:rich_data_json, mime: 'application/vnd.puppet.rich+json', charset: Encoding::UTF_8, weight: 30) do
187
254
  def intern(klass, text)
188
255
  Puppet.override({:rich_data => true}) do
@@ -27,6 +27,10 @@ class Puppet::Network::HTTP::Factory
27
27
 
28
28
  http = Puppet::Util::HttpProxy.proxy(URI(site.addr))
29
29
  http.use_ssl = site.use_ssl?
30
+ if site.use_ssl?
31
+ http.min_version = OpenSSL::SSL::TLS1_VERSION if http.respond_to?(:min_version)
32
+ http.ciphers = Puppet[:ciphers]
33
+ end
30
34
  http.read_timeout = Puppet[:http_read_timeout]
31
35
  http.open_timeout = Puppet[:http_connect_timeout]
32
36
  http.keep_alive_timeout = KEEP_ALIVE_TIMEOUT if http.respond_to?(:keep_alive_timeout=)
@@ -93,7 +93,7 @@ Puppet::Type.type(:package).provide :dnfmodule, :parent => :dnf do
93
93
  # module has no default profile and no profile was requested, so just enable the stream
94
94
  # DNF versions prior to 4.2.8 do not need this workaround
95
95
  # see https://bugzilla.redhat.com/show_bug.cgi?id=1669527
96
- if @resource[:flavor] == nil && e.message =~ /^missing groups or modules: #{Regexp.quote(@resource[:name])}$/
96
+ if @resource[:flavor] == nil && e.message =~ /^(?:missing|broken) groups or modules: #{Regexp.quote(@resource[:name])}$/
97
97
  enable(args)
98
98
  else
99
99
  raise
@@ -30,7 +30,7 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
30
30
  def self.instances
31
31
  i = []
32
32
  output = systemctl('list-unit-files', '--type', 'service', '--full', '--all', '--no-pager')
33
- output.scan(/^(\S+)\s+(disabled|enabled|masked|indirect|bad|static)\s*$/i).each do |m|
33
+ output.scan(/^(\S+)\s+(disabled|enabled|masked|indirect|bad|static)\s*([^-]\S+)?\s*$/i).each do |m|
34
34
  Puppet.debug("#{m[0]} marked as bad by `systemctl`. It is recommended to be further checked.") if m[1] == "bad"
35
35
  i << new(:name => m[0])
36
36
  end
@@ -135,7 +135,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
135
135
 
136
136
  Puppet::FileSystem.each_line(group_file) do |line|
137
137
  data = line.chomp.split(':')
138
- if data.last.split(',').include?(user)
138
+ if !data.empty? && data.last.split(',').include?(user)
139
139
  @groups_of[user] << data.first
140
140
  end
141
141
  end
@@ -29,6 +29,7 @@ class Puppet::Settings::EnvironmentConf
29
29
  section = config.sections[:main]
30
30
  rescue Errno::ENOENT
31
31
  # environment.conf is an optional file
32
+ Puppet.debug { "Path to #{path_to_env} does not exist, using default environment.conf" }
32
33
  end
33
34
 
34
35
  new(path_to_env, section, global_module_path)