puppet 7.1.0-x64-mingw32 → 7.6.1-x64-mingw32

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

Potentially problematic release.


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

Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +38 -30
  3. data/ext/build_defaults.yaml +0 -1
  4. data/lib/puppet/application.rb +10 -6
  5. data/lib/puppet/application/agent.rb +1 -0
  6. data/lib/puppet/application/apply.rb +3 -2
  7. data/lib/puppet/application/device.rb +1 -0
  8. data/lib/puppet/application/script.rb +1 -0
  9. data/lib/puppet/application/ssl.rb +11 -0
  10. data/lib/puppet/configurer.rb +16 -3
  11. data/lib/puppet/defaults.rb +14 -19
  12. data/lib/puppet/environments.rb +16 -1
  13. data/lib/puppet/face/facts.rb +26 -2
  14. data/lib/puppet/ffi/windows/api_types.rb +1 -1
  15. data/lib/puppet/ffi/windows/constants.rb +1 -1
  16. data/lib/puppet/file_serving/configuration/parser.rb +5 -2
  17. data/lib/puppet/file_system/memory_file.rb +8 -1
  18. data/lib/puppet/file_system/windows.rb +2 -0
  19. data/lib/puppet/functions.rb +1 -1
  20. data/lib/puppet/functions/partition.rb +8 -0
  21. data/lib/puppet/http/factory.rb +4 -0
  22. data/lib/puppet/indirector/facts/facter.rb +1 -0
  23. data/lib/puppet/loaders.rb +0 -4
  24. data/lib/puppet/module.rb +1 -0
  25. data/lib/puppet/module_tool/applications/installer.rb +48 -2
  26. data/lib/puppet/module_tool/errors/shared.rb +17 -2
  27. data/lib/puppet/network/formats.rb +67 -0
  28. data/lib/puppet/network/http.rb +5 -2
  29. data/lib/puppet/network/http/api.rb +10 -6
  30. data/lib/puppet/network/http/api/master.rb +3 -2
  31. data/lib/puppet/network/http/api/master/v3.rb +2 -25
  32. data/lib/puppet/network/http/api/master/v3/environments.rb +2 -33
  33. data/lib/puppet/network/http/api/server.rb +10 -0
  34. data/lib/puppet/network/http/api/server/v3.rb +39 -0
  35. data/lib/puppet/network/http/api/server/v3/environments.rb +48 -0
  36. data/lib/puppet/node/environment.rb +12 -5
  37. data/lib/puppet/parser/ast/leaf.rb +3 -2
  38. data/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
  39. data/lib/puppet/pops/loader/base_loader.rb +42 -32
  40. data/lib/puppet/pops/loader/dependency_loader.rb +2 -2
  41. data/lib/puppet/pops/loader/loader.rb +15 -5
  42. data/lib/puppet/pops/loader/module_loaders.rb +8 -8
  43. data/lib/puppet/pops/loader/predefined_loader.rb +4 -0
  44. data/lib/puppet/pops/loader/runtime3_type_loader.rb +1 -1
  45. data/lib/puppet/pops/loader/static_loader.rb +4 -0
  46. data/lib/puppet/pops/loaders.rb +4 -4
  47. data/lib/puppet/pops/model/ast_transformer.rb +1 -1
  48. data/lib/puppet/pops/parser/lexer2.rb +0 -4
  49. data/lib/puppet/pops/types/p_type_set_type.rb +1 -1
  50. data/lib/puppet/pops/validation/checker4_0.rb +0 -1
  51. data/lib/puppet/property/list.rb +1 -1
  52. data/lib/puppet/provider/group/groupadd.rb +13 -8
  53. data/lib/puppet/provider/package/apt.rb +34 -2
  54. data/lib/puppet/provider/package/aptitude.rb +6 -0
  55. data/lib/puppet/provider/package/dnfmodule.rb +1 -1
  56. data/lib/puppet/provider/package/puppet_gem.rb +12 -1
  57. data/lib/puppet/provider/service/debian.rb +2 -0
  58. data/lib/puppet/provider/service/systemd.rb +1 -1
  59. data/lib/puppet/provider/user/useradd.rb +62 -8
  60. data/lib/puppet/reference/configuration.rb +6 -5
  61. data/lib/puppet/settings.rb +36 -30
  62. data/lib/puppet/settings/alias_setting.rb +37 -0
  63. data/lib/puppet/settings/environment_conf.rb +1 -0
  64. data/lib/puppet/type/package.rb +3 -3
  65. data/lib/puppet/util/autoload.rb +1 -8
  66. data/lib/puppet/util/monkey_patches.rb +7 -0
  67. data/lib/puppet/util/posix.rb +1 -1
  68. data/lib/puppet/util/windows/adsi.rb +46 -0
  69. data/lib/puppet/util/windows/principal.rb +9 -2
  70. data/lib/puppet/util/windows/sid.rb +4 -2
  71. data/lib/puppet/version.rb +1 -1
  72. data/locales/puppet.pot +166 -146
  73. data/man/man5/puppet.conf.5 +14 -6
  74. data/man/man8/puppet-agent.8 +2 -2
  75. data/man/man8/puppet-apply.8 +2 -2
  76. data/man/man8/puppet-catalog.8 +1 -1
  77. data/man/man8/puppet-config.8 +1 -1
  78. data/man/man8/puppet-describe.8 +1 -1
  79. data/man/man8/puppet-device.8 +2 -2
  80. data/man/man8/puppet-doc.8 +1 -1
  81. data/man/man8/puppet-epp.8 +1 -1
  82. data/man/man8/puppet-facts.8 +8 -2
  83. data/man/man8/puppet-filebucket.8 +1 -1
  84. data/man/man8/puppet-generate.8 +1 -1
  85. data/man/man8/puppet-help.8 +1 -1
  86. data/man/man8/puppet-lookup.8 +1 -1
  87. data/man/man8/puppet-module.8 +1 -1
  88. data/man/man8/puppet-node.8 +1 -1
  89. data/man/man8/puppet-parser.8 +1 -1
  90. data/man/man8/puppet-plugin.8 +1 -1
  91. data/man/man8/puppet-report.8 +1 -1
  92. data/man/man8/puppet-resource.8 +1 -1
  93. data/man/man8/puppet-script.8 +2 -2
  94. data/man/man8/puppet-ssl.8 +5 -1
  95. data/man/man8/puppet.8 +2 -2
  96. data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +91 -0
  97. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services_vendor_preset +9 -0
  98. data/spec/integration/application/agent_spec.rb +160 -3
  99. data/spec/integration/application/apply_spec.rb +19 -0
  100. data/spec/integration/application/plugin_spec.rb +1 -1
  101. data/spec/integration/defaults_spec.rb +0 -7
  102. data/spec/integration/http/client_spec.rb +12 -0
  103. data/spec/integration/indirector/direct_file_server_spec.rb +1 -3
  104. data/spec/integration/indirector/file_content/file_server_spec.rb +0 -2
  105. data/spec/integration/indirector/file_metadata/file_server_spec.rb +0 -2
  106. data/spec/integration/parser/collection_spec.rb +10 -0
  107. data/spec/integration/resource/type_collection_spec.rb +2 -6
  108. data/spec/integration/transaction_spec.rb +4 -9
  109. data/spec/integration/util/windows/adsi_spec.rb +21 -1
  110. data/spec/integration/util/windows/principal_spec.rb +21 -0
  111. data/spec/integration/util/windows/registry_spec.rb +6 -10
  112. data/spec/spec_helper.rb +12 -5
  113. data/spec/unit/agent_spec.rb +8 -6
  114. data/spec/unit/application/agent_spec.rb +0 -1
  115. data/spec/unit/application/facts_spec.rb +58 -7
  116. data/spec/unit/application/filebucket_spec.rb +0 -2
  117. data/spec/unit/application/ssl_spec.rb +23 -0
  118. data/spec/unit/application_spec.rb +17 -9
  119. data/spec/unit/confine/feature_spec.rb +1 -1
  120. data/spec/unit/confine_spec.rb +8 -2
  121. data/spec/unit/environments_spec.rb +164 -88
  122. data/spec/unit/face/node_spec.rb +0 -11
  123. data/spec/unit/file_serving/configuration/parser_spec.rb +8 -1
  124. data/spec/unit/file_serving/metadata_spec.rb +3 -3
  125. data/spec/unit/file_serving/terminus_helper_spec.rb +11 -4
  126. data/spec/unit/file_system_spec.rb +9 -0
  127. data/spec/unit/forge/module_release_spec.rb +2 -7
  128. data/spec/unit/http/factory_spec.rb +19 -0
  129. data/spec/unit/indirector/face_spec.rb +0 -1
  130. data/spec/unit/indirector/facts/facter_spec.rb +20 -5
  131. data/spec/unit/indirector/file_bucket_file/selector_spec.rb +26 -8
  132. data/spec/unit/indirector/indirection_spec.rb +8 -12
  133. data/spec/unit/indirector_spec.rb +2 -2
  134. data/spec/unit/module_spec.rb +1 -1
  135. data/spec/unit/module_tool/applications/installer_spec.rb +66 -0
  136. data/spec/unit/network/formats_spec.rb +41 -0
  137. data/spec/unit/network/http/api/indirected_routes_spec.rb +0 -4
  138. data/spec/unit/network/http/api/master_spec.rb +38 -0
  139. data/spec/unit/network/http/api/{master → server}/v3/environments_spec.rb +2 -2
  140. data/spec/unit/network/http/api/{master → server}/v3_spec.rb +19 -19
  141. data/spec/unit/network/http/api_spec.rb +11 -11
  142. data/spec/unit/parser/compiler_spec.rb +3 -19
  143. data/spec/unit/parser/resource_spec.rb +14 -8
  144. data/spec/unit/pops/evaluator/deferred_resolver_spec.rb +20 -0
  145. data/spec/unit/pops/loaders/dependency_loader_spec.rb +1 -1
  146. data/spec/unit/pops/parser/lexer2_spec.rb +0 -4
  147. data/spec/unit/pops/types/type_parser_spec.rb +2 -1
  148. data/spec/unit/pops/validator/validator_spec.rb +20 -43
  149. data/spec/unit/property_spec.rb +1 -0
  150. data/spec/unit/provider/group/groupadd_spec.rb +5 -2
  151. data/spec/unit/provider/nameservice_spec.rb +66 -65
  152. data/spec/unit/provider/package/apt_spec.rb +28 -23
  153. data/spec/unit/provider/package/aptitude_spec.rb +1 -1
  154. data/spec/unit/provider/package/base_spec.rb +6 -5
  155. data/spec/unit/provider/package/dnfmodule_spec.rb +10 -1
  156. data/spec/unit/provider/package/pacman_spec.rb +18 -12
  157. data/spec/unit/provider/package/pip_spec.rb +6 -11
  158. data/spec/unit/provider/package/pkgdmg_spec.rb +0 -4
  159. data/spec/unit/provider/package/puppet_gem_spec.rb +28 -0
  160. data/spec/unit/provider/service/systemd_spec.rb +11 -0
  161. data/spec/unit/provider/user/hpux_spec.rb +1 -1
  162. data/spec/unit/provider/user/useradd_spec.rb +70 -3
  163. data/spec/unit/provider_spec.rb +6 -8
  164. data/spec/unit/resource/type_spec.rb +1 -1
  165. data/spec/unit/resource_spec.rb +11 -10
  166. data/spec/unit/settings_spec.rb +13 -6
  167. data/spec/unit/ssl/base_spec.rb +0 -1
  168. data/spec/unit/ssl/certificate_request_spec.rb +4 -10
  169. data/spec/unit/ssl/ssl_provider_spec.rb +5 -2
  170. data/spec/unit/transaction/additional_resource_generator_spec.rb +3 -7
  171. data/spec/unit/transaction/event_manager_spec.rb +14 -11
  172. data/spec/unit/transaction_spec.rb +13 -4
  173. data/spec/unit/type/file/content_spec.rb +0 -1
  174. data/spec/unit/type/file/selinux_spec.rb +0 -2
  175. data/spec/unit/type/file_spec.rb +0 -6
  176. data/spec/unit/type/group_spec.rb +13 -6
  177. data/spec/unit/type/resources_spec.rb +7 -7
  178. data/spec/unit/type/service_spec.rb +1 -1
  179. data/spec/unit/type/tidy_spec.rb +0 -1
  180. data/spec/unit/type_spec.rb +2 -2
  181. data/spec/unit/util/at_fork_spec.rb +2 -2
  182. data/spec/unit/util/autoload_spec.rb +5 -1
  183. data/spec/unit/util/backups_spec.rb +1 -2
  184. data/spec/unit/util/execution_spec.rb +15 -11
  185. data/spec/unit/util/inifile_spec.rb +6 -14
  186. data/spec/unit/util/log_spec.rb +8 -7
  187. data/spec/unit/util/logging_spec.rb +3 -3
  188. data/spec/unit/util/posix_spec.rb +16 -10
  189. data/spec/unit/util/selinux_spec.rb +76 -52
  190. data/spec/unit/util/suidmanager_spec.rb +44 -41
  191. data/spec/unit/util/windows/sid_spec.rb +6 -0
  192. data/spec/unit/util_spec.rb +13 -6
  193. metadata +18 -16
  194. data/spec/lib/matchers/include.rb +0 -27
  195. data/spec/lib/matchers/include_spec.rb +0 -32
  196. data/spec/unit/pops/parser/parse_application_spec.rb +0 -13
  197. data/spec/unit/pops/parser/parse_capabilities_spec.rb +0 -23
  198. data/spec/unit/pops/parser/parse_site_spec.rb +0 -43
@@ -20,7 +20,7 @@ module Puppet::FFI::Windows
20
20
 
21
21
  class ::FFI::Pointer
22
22
  NULL_HANDLE = 0
23
- WCHAR_NULL = "\0\0".encode('UTF-16LE').freeze
23
+ WCHAR_NULL = "\0\0".force_encoding('UTF-16LE').freeze
24
24
 
25
25
  def self.from_string_to_wide_string(str, &block)
26
26
  str = Puppet::Util::Windows::String.wide_string(str)
@@ -375,7 +375,7 @@ module Puppet::FFI::Windows
375
375
  SERVICE_CONFIG_PRESHUTDOWN_INFO = 0x00000007
376
376
  SERVICE_CONFIG_TRIGGER_INFO = 0x00000008
377
377
  SERVICE_CONFIG_PREFERRED_NODE = 0x00000009
378
- SERVICE_CONFIG_LAUNCH_PROTECTED = 0x00000012
378
+ SERVICE_CONFIG_LAUNCH_PROTECTED = 0x0000000C
379
379
  SERVICE_NO_CHANGE = 0xffffffff
380
380
  SERVICE_CONFIG_TYPES = {
381
381
  SERVICE_CONFIG_DESCRIPTION => :SERVICE_CONFIG_DESCRIPTION,
@@ -33,8 +33,11 @@ class Puppet::FileServing::Configuration::Parser
33
33
  when "path"
34
34
  path(mount, value)
35
35
  when "allow", "deny"
36
- error_location_str = Puppet::Util::Errors.error_location(@file.filename, @count)
37
- Puppet.err("Entry '#{line.chomp}' is unsupported and will be ignored at #{error_location_str}")
36
+ # ignore `allow *`, otherwise report error
37
+ if var != 'allow' || value != '*'
38
+ error_location_str = Puppet::Util::Errors.error_location(@file.filename, @count)
39
+ Puppet.err("Entry '#{line.chomp}' is unsupported and will be ignored at #{error_location_str}")
40
+ end
38
41
  else
39
42
  error_location_str = Puppet::Util::Errors.error_location(@file.filename, @count)
40
43
  raise ArgumentError.new(_("Invalid argument '%{var}' at %{error_location}") %
@@ -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)
@@ -606,7 +606,7 @@ module Puppet::Functions
606
606
  attr_reader :local_types, :parser, :loader
607
607
 
608
608
  def initialize(loader, name)
609
- @loader = Puppet::Pops::Loader::PredefinedLoader.new(loader, :"local_function_#{name}")
609
+ @loader = Puppet::Pops::Loader::PredefinedLoader.new(loader, :"local_function_#{name}", loader.environment)
610
610
  @local_types = []
611
611
  # get the shared parser used by puppet's compiler
612
612
  @parser = Puppet::Pops::Parser::EvaluatingParser.singleton()
@@ -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
@@ -26,6 +26,10 @@ class Puppet::HTTP::Factory
26
26
 
27
27
  http = Puppet::HTTP::Proxy.proxy(URI(site.addr))
28
28
  http.use_ssl = site.use_ssl?
29
+ if site.use_ssl?
30
+ http.min_version = OpenSSL::SSL::TLS1_VERSION if http.respond_to?(:min_version)
31
+ http.ciphers = Puppet[:ciphers]
32
+ end
29
33
  http.read_timeout = Puppet[:http_read_timeout]
30
34
  http.open_timeout = Puppet[:http_connect_timeout]
31
35
  http.keep_alive_timeout = KEEP_ALIVE_TIMEOUT if http.respond_to?(:keep_alive_timeout=)
@@ -103,6 +103,7 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
103
103
  options_for_facter += " --show-legacy" if options[:show_legacy]
104
104
  options_for_facter += " --no-block" if options[:no_block] == false
105
105
  options_for_facter += " --no-cache" if options[:no_cache] == false
106
+ options_for_facter += " --timing" if options[:timing]
106
107
 
107
108
  Puppet::Node::Facts.new(request.key, Facter.resolve(options_for_facter))
108
109
  end
@@ -24,10 +24,6 @@ module Puppet
24
24
  require 'puppet/pops/loader/predefined_loader'
25
25
  require 'puppet/pops/loader/generic_plan_instantiator'
26
26
  require 'puppet/pops/loader/puppet_plan_instantiator'
27
-
28
- # The implementation of synchronized applies it to all subclasses so we
29
- # want to add it to be base class after any subclasses are created
30
- Loader.include Puppet::Concurrent::Synchronized
31
27
  end
32
28
  end
33
29
 
data/lib/puppet/module.rb CHANGED
@@ -25,6 +25,7 @@ class Puppet::Module
25
25
  "plugins" => "lib",
26
26
  "pluginfacts" => "facts.d",
27
27
  "locales" => "locales",
28
+ "scripts" => "scripts",
28
29
  }
29
30
 
30
31
  # Find and return the +module+ that +path+ belongs to. If +path+ is
@@ -131,8 +131,54 @@ module Puppet::ModuleTool
131
131
  begin
132
132
  Puppet.info _("Resolving dependencies ...")
133
133
  releases = SemanticPuppet::Dependency.resolve(graph)
134
- rescue SemanticPuppet::Dependency::UnsatisfiableGraph
135
- raise NoVersionsSatisfyError, results.merge(:requested_name => name)
134
+ rescue SemanticPuppet::Dependency::UnsatisfiableGraph => e
135
+ unsatisfied = nil
136
+
137
+ if e.respond_to?(:unsatisfied)
138
+ constraints = {}
139
+ # If the module we're installing satisfies all its
140
+ # dependencies, but would break an already installed
141
+ # module that depends on it, show what would break.
142
+ if name == e.unsatisfied
143
+ graph.constraints[name].each do |mod, range, _|
144
+ next unless mod.split.include?('constraint')
145
+
146
+ # If the user requested a specific version or range,
147
+ # only show the modules with non-intersecting ranges
148
+ if options[:version]
149
+ requested_range = SemanticPuppet::VersionRange.parse(options[:version])
150
+ constraint_range = SemanticPuppet::VersionRange.parse(range)
151
+
152
+ if requested_range.intersection(constraint_range) == SemanticPuppet::VersionRange::EMPTY_RANGE
153
+ constraints[mod.split.first] = range
154
+ end
155
+ else
156
+ constraints[mod.split.first] = range
157
+ end
158
+ end
159
+
160
+ # If the module fails to satisfy one of its
161
+ # dependencies, show the unsatisfiable module
162
+ else
163
+ unsatisfied_range = graph.dependencies[name].max.constraints[e.unsatisfied].first[1]
164
+ constraints[e.unsatisfied] = unsatisfied_range
165
+ end
166
+
167
+ installed_module = @environment.module_by_forge_name(e.unsatisfied.tr('-', '/'))
168
+ current_version = installed_module.version if installed_module
169
+
170
+ unsatisfied = {
171
+ :name => e.unsatisfied,
172
+ :constraints => constraints,
173
+ :current_version => current_version
174
+ }
175
+ end
176
+
177
+ raise NoVersionsSatisfyError, results.merge(
178
+ :requested_name => name,
179
+ :requested_version => options[:version] || graph.dependencies[name].max.version.to_s,
180
+ :unsatisfied => unsatisfied
181
+ )
136
182
  end
137
183
 
138
184
  unless forced?
@@ -7,6 +7,7 @@ module Puppet::ModuleTool::Errors
7
7
  @installed_version = options[:installed_version]
8
8
  @conditions = options[:conditions]
9
9
  @action = options[:action]
10
+ @unsatisfied = options[:unsatisfied]
10
11
 
11
12
  super _("Could not %{action} '%{module_name}' (%{version}); no version satisfies all dependencies") % { action: @action, module_name: @requested_name, version: vstring }
12
13
  end
@@ -14,9 +15,23 @@ module Puppet::ModuleTool::Errors
14
15
  def multiline
15
16
  message = []
16
17
  message << _("Could not %{action} module '%{module_name}' (%{version})") % { action: @action, module_name: @requested_name, version: vstring }
17
- message << _(" No version of '%{module_name}' can satisfy all dependencies") % { module_name: @requested_name }
18
+
19
+ if @unsatisfied
20
+ message << _(" The requested version cannot satisfy one or more of the following installed modules:")
21
+ if @unsatisfied[:current_version]
22
+ message << _(" %{name}, installed: %{current_version}, expected: %{constraints}") % { name: @unsatisfied[:name], current_version: @unsatisfied[:current_version], constraints: @unsatisfied[:constraints][@unsatisfied[:name]] }
23
+ else
24
+ @unsatisfied[:constraints].each do |mod, range|
25
+ message << _(" %{mod}, expects '%{name}': %{range}") % { mod: mod, name: @requested_name, range: range }
26
+ end
27
+ end
28
+ message << _("")
29
+ else
30
+ message << _(" The requested version cannot satisfy all dependencies")
31
+ end
32
+
18
33
  #TRANSLATORS `puppet module %{action} --ignore-dependencies` is a command line and should not be translated
19
- message << _(" Use `puppet module %{action} --ignore-dependencies` to %{action} only this module") % { action: @action }
34
+ message << _(" Use `puppet module %{action} '%{module_name}' --ignore-dependencies` to %{action} only this module") % { action: @action, module_name: @requested_name }
20
35
  message.join("\n")
21
36
  end
22
37
  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
@@ -3,8 +3,11 @@ module Puppet::Network::HTTP
3
3
  HEADER_ENABLE_PROFILING = "X-Puppet-Profiling"
4
4
  HEADER_PUPPET_VERSION = "X-Puppet-Version"
5
5
 
6
- MASTER_URL_PREFIX = "/puppet"
7
- MASTER_URL_VERSIONS = "v3"
6
+ SERVER_URL_PREFIX = "/puppet"
7
+ SERVER_URL_VERSIONS = "v3"
8
+
9
+ MASTER_URL_PREFIX = SERVER_URL_PREFIX
10
+ MASTER_URL_VERSIONS = SERVER_URL_VERSIONS
8
11
 
9
12
  CA_URL_PREFIX = "/puppet-ca"
10
13
  CA_URL_VERSIONS = "v1"
@@ -18,18 +18,22 @@ class Puppet::Network::HTTP::API
18
18
  "Note that Puppet 3 agents aren't compatible with this version; if you're " +
19
19
  "running Puppet 3, you must either upgrade your agents to match the server " +
20
20
  "or point them to a server running Puppet 3.\n\n" +
21
- "Master Info:\n" +
21
+ "Server Info:\n" +
22
22
  " Puppet version: #{Puppet.version}\n" +
23
- " Supported /puppet API versions: #{Puppet::Network::HTTP::MASTER_URL_VERSIONS}\n",
23
+ " Supported /puppet API versions: #{Puppet::Network::HTTP::SERVER_URL_VERSIONS}\n",
24
24
  Puppet::Network::HTTP::Issues::HANDLER_NOT_FOUND)
25
25
  end)
26
26
  end
27
27
 
28
- def self.master_routes
29
- master_prefix = Regexp.new("^#{Puppet::Network::HTTP::MASTER_URL_PREFIX}/")
30
- Puppet::Network::HTTP::Route.path(master_prefix).
28
+ def self.server_routes
29
+ server_prefix = Regexp.new("^#{Puppet::Network::HTTP::SERVER_URL_PREFIX}/")
30
+ Puppet::Network::HTTP::Route.path(server_prefix).
31
31
  any.
32
- chain(Puppet::Network::HTTP::API::Master::V3.routes,
32
+ chain(Puppet::Network::HTTP::API::Server::V3.routes,
33
33
  Puppet::Network::HTTP::API.not_found)
34
34
  end
35
+
36
+ def self.master_routes
37
+ server_routes
38
+ end
35
39
  end
@@ -1,2 +1,3 @@
1
- module Puppet::Network::HTTP::API::Master
2
- end
1
+ require 'puppet/network/http/api/server'
2
+
3
+ Puppet::Network::HTTP::API::Master = Puppet::Network::HTTP::API::Server
@@ -1,26 +1,3 @@
1
- class Puppet::Network::HTTP::API::Master::V3
2
- require 'puppet/network/http/api/master/v3/environments'
3
- require 'puppet/network/http/api/indirected_routes'
1
+ require 'puppet/network/http/api/master'
2
+ require 'puppet/network/http/api/server/v3'
4
3
 
5
- def self.wrap(&block)
6
- lambda do |request, response|
7
- Puppet::Network::Authorization.check_external_authorization(request.method, request.path)
8
-
9
- block.call.call(request, response)
10
- end
11
- end
12
-
13
- INDIRECTED = Puppet::Network::HTTP::Route.
14
- path(/.*/).
15
- any(wrap { Puppet::Network::HTTP::API::IndirectedRoutes.new } )
16
-
17
- ENVIRONMENTS = Puppet::Network::HTTP::Route.
18
- path(%r{^/environments$}).
19
- get(wrap { Environments.new(Puppet.lookup(:environments)) } )
20
-
21
- def self.routes
22
- Puppet::Network::HTTP::Route.path(%r{v3}).
23
- any.
24
- chain(ENVIRONMENTS, INDIRECTED)
25
- end
26
- end
@@ -1,34 +1,3 @@
1
- require 'puppet/util/json'
1
+ require 'puppet/network/http/api/master'
2
+ require 'puppet/network/http/api/server/v3/environments'
2
3
 
3
- class Puppet::Network::HTTP::API::Master::V3::Environments
4
- def initialize(env_loader)
5
- @env_loader = env_loader
6
- end
7
-
8
- def call(request, response)
9
- response.respond_with(200, "application/json", Puppet::Util::Json.dump({
10
- "search_paths" => @env_loader.search_paths,
11
- "environments" => Hash[@env_loader.list.collect do |env|
12
- [env.name, {
13
- "settings" => {
14
- "modulepath" => env.full_modulepath,
15
- "manifest" => env.manifest,
16
- "environment_timeout" => timeout(env),
17
- "config_version" => env.config_version || '',
18
- }
19
- }]
20
- end]
21
- }))
22
- end
23
-
24
- private
25
-
26
- def timeout(env)
27
- ttl = @env_loader.get_conf(env.name).environment_timeout
28
- if ttl == Float::INFINITY
29
- "unlimited"
30
- else
31
- ttl
32
- end
33
- end
34
- end
@@ -0,0 +1,10 @@
1
+ module Puppet
2
+ module Network
3
+ module HTTP
4
+ class API
5
+ module Server
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,39 @@
1
+ require 'puppet/network/http/api/server/v3/environments'
2
+ require 'puppet/network/http/api/indirected_routes'
3
+
4
+ module Puppet
5
+ module Network
6
+ module HTTP
7
+ class API
8
+ module Server
9
+ class V3
10
+
11
+ def self.wrap(&block)
12
+ lambda do |request, response|
13
+ Puppet::Network::Authorization.
14
+ check_external_authorization(request.method,
15
+ request.path)
16
+
17
+ block.call.call(request, response)
18
+ end
19
+ end
20
+
21
+ INDIRECTED = Puppet::Network::HTTP::Route.
22
+ path(/.*/).
23
+ any(wrap { Puppet::Network::HTTP::API::IndirectedRoutes.new } )
24
+
25
+ ENVIRONMENTS = Puppet::Network::HTTP::Route.
26
+ path(%r{^/environments$}).
27
+ get(wrap { Environments.new(Puppet.lookup(:environments)) } )
28
+
29
+ def self.routes
30
+ Puppet::Network::HTTP::Route.path(%r{v3}).
31
+ any.
32
+ chain(ENVIRONMENTS, INDIRECTED)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end