puppet 4.7.1-universal-darwin → 4.8.0-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.
- data/Gemfile +0 -3
- data/MAINTAINERS +76 -0
- data/README.md +0 -6
- data/Rakefile +2 -2
- data/lib/puppet/agent.rb +3 -3
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/configurer.rb +2 -2
- data/lib/puppet/data_providers.rb +1 -0
- data/lib/puppet/data_providers/data_adapter.rb +1 -0
- data/lib/puppet/data_providers/data_function_support.rb +1 -0
- data/lib/puppet/data_providers/function_env_data_provider.rb +1 -0
- data/lib/puppet/data_providers/function_module_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_config.rb +1 -0
- data/lib/puppet/data_providers/hiera_env_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_interpolate.rb +1 -0
- data/lib/puppet/data_providers/hiera_module_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_support.rb +1 -2
- data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -0
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -0
- data/lib/puppet/defaults.rb +20 -1
- data/lib/puppet/environments.rb +5 -2
- data/lib/puppet/face/catalog.rb +1 -1
- data/lib/puppet/face/epp.rb +57 -11
- data/lib/puppet/face/module/install.rb +6 -6
- data/lib/puppet/functions.rb +23 -24
- data/lib/puppet/functions/alert.rb +14 -0
- data/lib/puppet/functions/binary_file.rb +25 -0
- data/lib/puppet/functions/break.rb +22 -0
- data/lib/puppet/functions/contain.rb +33 -0
- data/lib/puppet/functions/crit.rb +14 -0
- data/lib/puppet/functions/debug.rb +14 -0
- data/lib/puppet/functions/emerg.rb +14 -0
- data/lib/puppet/functions/epp.rb +1 -1
- data/lib/puppet/functions/err.rb +14 -0
- data/lib/puppet/functions/find_file.rb +31 -0
- data/lib/puppet/functions/include.rb +21 -0
- data/lib/puppet/functions/info.rb +14 -0
- data/lib/puppet/functions/new.rb +1 -1
- data/lib/puppet/functions/next.rb +23 -0
- data/lib/puppet/functions/notice.rb +14 -0
- data/lib/puppet/functions/regsubst.rb +12 -16
- data/lib/puppet/functions/require.rb +37 -0
- data/lib/puppet/functions/return.rb +22 -0
- data/lib/puppet/functions/strftime.rb +35 -0
- data/lib/puppet/functions/warning.rb +14 -0
- data/lib/puppet/generate/models/type/type.rb +4 -0
- data/lib/puppet/generate/templates/type/pcore.erb +2 -1
- data/lib/puppet/indirector/face.rb +6 -1
- data/lib/puppet/network/http/error.rb +2 -2
- data/lib/puppet/network/http/handler.rb +2 -2
- data/lib/puppet/node/environment.rb +11 -0
- data/lib/puppet/parser/ast.rb +5 -0
- data/lib/puppet/parser/ast/pops_bridge.rb +17 -4
- data/lib/puppet/parser/compiler.rb +29 -1
- data/lib/puppet/parser/functions.rb +6 -0
- data/lib/puppet/parser/functions/assert_type.rb +1 -1
- data/lib/puppet/parser/functions/binary_file.rb +24 -0
- data/lib/puppet/parser/functions/break.rb +39 -0
- data/lib/puppet/parser/functions/contain.rb +7 -15
- data/lib/puppet/parser/functions/defined.rb +2 -2
- data/lib/puppet/parser/functions/dig.rb +1 -1
- data/lib/puppet/parser/functions/each.rb +1 -1
- data/lib/puppet/parser/functions/epp.rb +2 -2
- data/lib/puppet/parser/functions/filter.rb +1 -1
- data/lib/puppet/parser/functions/find_file.rb +28 -0
- data/lib/puppet/parser/functions/hiera.rb +4 -4
- data/lib/puppet/parser/functions/hiera_array.rb +1 -1
- data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
- data/lib/puppet/parser/functions/hiera_include.rb +1 -1
- data/lib/puppet/parser/functions/include.rb +4 -8
- data/lib/puppet/parser/functions/inline_epp.rb +1 -1
- data/lib/puppet/parser/functions/lest.rb +1 -1
- data/lib/puppet/parser/functions/lookup.rb +4 -2
- data/lib/puppet/parser/functions/map.rb +1 -1
- data/lib/puppet/parser/functions/match.rb +1 -1
- data/lib/puppet/parser/functions/new.rb +414 -18
- data/lib/puppet/parser/functions/next.rb +38 -0
- data/lib/puppet/parser/functions/reduce.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +4 -2
- data/lib/puppet/parser/functions/require.rb +4 -27
- data/lib/puppet/parser/functions/return.rb +71 -0
- data/lib/puppet/parser/functions/reverse_each.rb +1 -1
- data/lib/puppet/parser/functions/scanf.rb +13 -8
- data/lib/puppet/parser/functions/slice.rb +1 -1
- data/lib/puppet/parser/functions/split.rb +1 -1
- data/lib/puppet/parser/functions/step.rb +1 -1
- data/lib/puppet/parser/functions/strftime.rb +185 -0
- data/lib/puppet/parser/functions/then.rb +1 -1
- data/lib/puppet/parser/functions/type.rb +1 -1
- data/lib/puppet/parser/functions/with.rb +3 -3
- data/lib/puppet/parser/resource.rb +8 -5
- data/lib/puppet/parser/scope.rb +1 -1
- data/lib/puppet/plugins/configuration.rb +8 -0
- data/lib/puppet/plugins/data_providers.rb +1 -0
- data/lib/puppet/plugins/data_providers/data_provider.rb +7 -28
- data/lib/puppet/plugins/data_providers/registry.rb +1 -0
- data/lib/puppet/pops.rb +4 -0
- data/lib/puppet/pops/evaluator/access_operator.rb +36 -5
- data/lib/puppet/pops/evaluator/closure.rb +81 -12
- data/lib/puppet/pops/evaluator/compare_operator.rb +24 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +29 -5
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +53 -62
- data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -6
- data/lib/puppet/pops/functions/dispatch.rb +9 -2
- data/lib/puppet/pops/functions/dispatcher.rb +3 -1
- data/lib/puppet/pops/functions/function.rb +19 -2
- data/lib/puppet/pops/issues.rb +9 -0
- data/lib/puppet/pops/label_provider.rb +2 -2
- data/lib/puppet/pops/loader/loader.rb +17 -0
- data/lib/puppet/pops/loader/static_loader.rb +0 -41
- data/lib/puppet/pops/lookup.rb +12 -0
- data/lib/puppet/pops/lookup/context.rb +86 -0
- data/lib/puppet/pops/lookup/explainer.rb +46 -6
- data/lib/puppet/pops/lookup/invocation.rb +19 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
- data/lib/puppet/pops/model/factory.rb +20 -8
- data/lib/puppet/pops/model/model_label_provider.rb +3 -0
- data/lib/puppet/pops/model/model_meta.rb +2 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +14 -0
- data/lib/puppet/pops/parser/egrammar.ra +11 -6
- data/lib/puppet/pops/parser/eparser.rb +1112 -1086
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
- data/lib/puppet/pops/pcore.rb +1 -0
- data/lib/puppet/pops/puppet_stack.rb +3 -3
- data/lib/puppet/pops/resource/param.rb +5 -1
- data/lib/puppet/pops/resource/resource_type_impl.rb +8 -4
- data/lib/puppet/pops/resource/resource_type_set.pcore +1 -0
- data/lib/puppet/pops/serialization/abstract_reader.rb +19 -2
- data/lib/puppet/pops/serialization/abstract_writer.rb +16 -3
- data/lib/puppet/pops/serialization/deserializer.rb +5 -1
- data/lib/puppet/pops/serialization/extension.rb +2 -0
- data/lib/puppet/pops/serialization/json.rb +76 -26
- data/lib/puppet/pops/serialization/serializer.rb +5 -1
- data/lib/puppet/pops/serialization/time_factory.rb +2 -1
- data/lib/puppet/pops/time/timespan.rb +718 -0
- data/lib/puppet/pops/time/timestamp.rb +148 -0
- data/lib/puppet/pops/types/p_binary_type.rb +220 -0
- data/lib/puppet/pops/types/p_object_type.rb +12 -6
- data/lib/puppet/pops/types/p_sensitive_type.rb +5 -1
- data/lib/puppet/pops/types/p_timespan_type.rb +141 -0
- data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
- data/lib/puppet/pops/types/string_converter.rb +62 -0
- data/lib/puppet/pops/types/type_asserter.rb +1 -1
- data/lib/puppet/pops/types/type_calculator.rb +17 -3
- data/lib/puppet/pops/types/type_factory.rb +35 -1
- data/lib/puppet/pops/types/type_formatter.rb +64 -11
- data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -61
- data/lib/puppet/pops/types/type_parser.rb +18 -4
- data/lib/puppet/pops/types/types.rb +98 -63
- data/lib/puppet/pops/validation.rb +9 -1
- data/lib/puppet/pops/validation/checker4_0.rb +7 -0
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/provider.rb +3 -6
- data/lib/puppet/provider/mcx/mcxcontent.rb +1 -1
- data/lib/puppet/provider/mount/parsed.rb +18 -4
- data/lib/puppet/provider/nameservice/directoryservice.rb +15 -7
- data/lib/puppet/provider/package/gem.rb +6 -1
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkg.rb +5 -1
- data/lib/puppet/provider/package/pkgng.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +10 -0
- data/lib/puppet/provider/service/launchd.rb +1 -0
- data/lib/puppet/provider/user/directoryservice.rb +6 -6
- data/lib/puppet/provider/yumrepo/inifile.rb +1 -1
- data/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/lib/puppet/resource.rb +54 -12
- data/lib/puppet/resource/capability_finder.rb +15 -9
- data/lib/puppet/resource/catalog.rb +25 -6
- data/lib/puppet/resource/type.rb +3 -1
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +12 -4
- data/lib/puppet/syntax_checkers/base64.rb +41 -0
- data/lib/puppet/syntax_checkers/json.rb +0 -2
- data/lib/puppet/transaction.rb +6 -0
- data/lib/puppet/transaction/additional_resource_generator.rb +5 -0
- data/lib/puppet/transaction/report.rb +7 -2
- data/lib/puppet/type.rb +2 -1
- data/lib/puppet/type/file/checksum.rb +1 -0
- data/lib/puppet/type/file/content.rb +4 -4
- data/lib/puppet/type/mount.rb +44 -0
- data/lib/puppet/type/ssh_authorized_key.rb +1 -1
- data/lib/puppet/type/tidy.rb +3 -0
- data/lib/puppet/type/user.rb +12 -6
- data/lib/puppet/util/log.rb +25 -0
- data/lib/puppet/util/plist.rb +8 -3
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet_x.rb +7 -1
- data/spec/integration/application/apply_spec.rb +118 -0
- data/spec/integration/parser/compiler_spec.rb +28 -0
- data/spec/integration/parser/pcore_resource_spec.rb +40 -3
- data/spec/integration/provider/mount_spec.rb +2 -1
- data/spec/integration/util/windows/principal_spec.rb +2 -2
- data/spec/integration/util/windows/registry_spec.rb +4 -4
- data/spec/lib/puppet_spec/compiler.rb +5 -1
- data/spec/lib/puppet_spec/unindent.rb +5 -0
- data/spec/shared_contexts/types_setup.rb +6 -0
- data/spec/shared_examples/rhel_package_provider.rb +16 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/agent_spec.rb +11 -0
- data/spec/unit/application/lookup_spec.rb +94 -3
- data/spec/unit/capability_spec.rb +22 -0
- data/spec/unit/configurer_spec.rb +8 -0
- data/spec/unit/face/epp_face_spec.rb +22 -3
- data/spec/unit/functions/assert_type_spec.rb +3 -3
- data/spec/unit/functions/binary_file_spec.rb +46 -0
- data/spec/unit/functions/break_spec.rb +89 -0
- data/spec/unit/{parser/functions → functions}/contain_spec.rb +68 -3
- data/spec/unit/functions/find_file_spec.rb +69 -0
- data/spec/unit/functions/include_spec.rb +175 -0
- data/spec/unit/functions/logging_spec.rb +54 -0
- data/spec/unit/functions/lookup_spec.rb +3 -3
- data/spec/unit/functions/new_spec.rb +105 -5
- data/spec/unit/functions/next_spec.rb +93 -0
- data/spec/unit/functions/require_spec.rb +83 -0
- data/spec/unit/functions/return_spec.rb +105 -0
- data/spec/unit/{parser/functions → functions}/shared.rb +14 -11
- data/spec/unit/functions/strftime_spec.rb +152 -0
- data/spec/unit/functions4_spec.rb +22 -0
- data/spec/unit/indirector/face_spec.rb +10 -2
- data/spec/unit/network/http/error_spec.rb +1 -2
- data/spec/unit/network/http/handler_spec.rb +6 -5
- data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_spec.rb +1 -1
- data/spec/unit/parser/functions/lookup_spec.rb +1 -1
- data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
- data/spec/unit/parser/functions/split_spec.rb +1 -1
- data/spec/unit/pops/evaluator/access_ops_spec.rb +81 -1
- data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +29 -4
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +112 -4
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +12 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +0 -26
- data/spec/unit/pops/lookup/context_spec.rb +149 -0
- data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
- data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
- data/spec/unit/pops/puppet_stack_spec.rb +1 -1
- data/spec/unit/pops/resource/resource_type_impl_spec.rb +74 -0
- data/spec/unit/pops/serialization/packer_spec.rb +34 -14
- data/spec/unit/pops/serialization/serialization_spec.rb +67 -5
- data/spec/unit/pops/time/timespan_spec.rb +121 -0
- data/spec/unit/pops/types/p_binary_type_spec.rb +243 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +7 -7
- data/spec/unit/pops/types/p_sensitive_type_spec.rb +1 -1
- data/spec/unit/pops/types/p_timespan_type_spec.rb +273 -0
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +311 -0
- data/spec/unit/pops/types/p_type_set_type_spec.rb +13 -13
- data/spec/unit/pops/types/ruby_generator_spec.rb +12 -12
- data/spec/unit/pops/types/string_converter_spec.rb +89 -0
- data/spec/unit/pops/types/type_asserter_spec.rb +3 -3
- data/spec/unit/pops/types/type_calculator_spec.rb +113 -5
- data/spec/unit/pops/types/type_formatter_spec.rb +40 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +49 -38
- data/spec/unit/pops/types/type_parser_spec.rb +87 -4
- data/spec/unit/pops/types/types_spec.rb +1 -1
- data/spec/unit/pops/validator/validator_spec.rb +23 -0
- data/spec/unit/provider/mount/parsed_spec.rb +47 -29
- data/spec/unit/provider/package/pkg_spec.rb +109 -99
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
- data/spec/unit/provider/user/aix_spec.rb +1 -1
- data/spec/unit/provider/user/directoryservice_spec.rb +101 -30
- data/spec/unit/resource/capability_finder_spec.rb +29 -7
- data/spec/unit/resource/catalog_spec.rb +127 -0
- data/spec/unit/ssl/certificate_request_spec.rb +1 -1
- data/spec/unit/transaction/additional_resource_generator_spec.rb +30 -0
- data/spec/unit/transaction/persistence_spec.rb +1 -6
- data/spec/unit/transaction/report_spec.rb +23 -0
- data/spec/unit/transaction_spec.rb +38 -0
- data/spec/unit/type/mount_spec.rb +5 -0
- data/spec/unit/util/plist_spec.rb +14 -2
- metadata +71 -12
- data/spec/integration/parser/functions/require_spec.rb +0 -43
- data/spec/unit/parser/functions/include_spec.rb +0 -55
- data/spec/unit/parser/functions/require_spec.rb +0 -68
data/lib/puppet/property.rb
CHANGED
@@ -488,7 +488,7 @@ class Puppet::Property < Puppet::Parameter
|
|
488
488
|
rescue Puppet::Error
|
489
489
|
raise
|
490
490
|
rescue => detail
|
491
|
-
error = Puppet::ResourceError.new("Could not set '#{value}' on #{self.class.name}: #{detail}", @resource.
|
491
|
+
error = Puppet::ResourceError.new("Could not set '#{value}' on #{self.class.name}: #{detail}", @resource.file, @resource.line, detail)
|
492
492
|
error.set_backtrace detail.backtrace
|
493
493
|
Puppet.log_exception(detail, error.message)
|
494
494
|
raise error
|
data/lib/puppet/provider.rb
CHANGED
@@ -96,8 +96,7 @@ class Puppet::Provider
|
|
96
96
|
attr_accessor :resource
|
97
97
|
|
98
98
|
# Convenience methods - see class method with the same name.
|
99
|
-
# @see execute
|
100
|
-
# @return (see execute)
|
99
|
+
# @return (see self.execute)
|
101
100
|
def execute(*args)
|
102
101
|
Puppet::Util::Execution.execute(*args)
|
103
102
|
end
|
@@ -108,8 +107,7 @@ class Puppet::Provider
|
|
108
107
|
end
|
109
108
|
|
110
109
|
# Convenience methods - see class method with the same name.
|
111
|
-
# @see execpipe
|
112
|
-
# @return (see execpipe)
|
110
|
+
# @return (see self.execpipe)
|
113
111
|
def execpipe(*args, &block)
|
114
112
|
Puppet::Util::Execution.execpipe(*args, &block)
|
115
113
|
end
|
@@ -120,8 +118,7 @@ class Puppet::Provider
|
|
120
118
|
end
|
121
119
|
|
122
120
|
# Convenience methods - see class method with the same name.
|
123
|
-
# @see execfail
|
124
|
-
# @return (see execfail)
|
121
|
+
# @return (see self.execfail)
|
125
122
|
def execfail(*args)
|
126
123
|
Puppet::Util::Execution.execfail(*args)
|
127
124
|
end
|
@@ -36,7 +36,7 @@ Puppet::Type.type(:mcx).provide :mcxcontent, :parent => Puppet::Provider do
|
|
36
36
|
|
37
37
|
def self.instances
|
38
38
|
mcx_list = []
|
39
|
-
TypeMap.
|
39
|
+
TypeMap.each_key do |ds_type|
|
40
40
|
ds_path = "/Local/Default/#{TypeMap[ds_type]}"
|
41
41
|
output = dscl 'localhost', '-list', ds_path
|
42
42
|
member_list = output.split
|
@@ -209,14 +209,20 @@ Puppet::Type.type(:mount).provide(
|
|
209
209
|
|
210
210
|
# Update fstab entries that are mounted
|
211
211
|
providers.each do |prov|
|
212
|
-
|
213
|
-
prov.
|
212
|
+
mounts.delete_if do |mount|
|
213
|
+
if mount[:name] == prov.get(:name) && mount[:mounted] == :yes
|
214
|
+
prov.set(:ensure => :mounted)
|
215
|
+
prov.set(:live_options => mount[:live_options])
|
216
|
+
true
|
217
|
+
else
|
218
|
+
false
|
219
|
+
end
|
214
220
|
end
|
215
221
|
end
|
216
222
|
|
217
223
|
# Add mounts that are not in fstab but mounted
|
218
224
|
mounts.each do |mount|
|
219
|
-
providers << new(:ensure => :ghost, :name => mount[:name])
|
225
|
+
providers << new(:ensure => :ghost, :name => mount[:name], :live_options => mount[:live_options])
|
220
226
|
end
|
221
227
|
providers
|
222
228
|
end
|
@@ -232,6 +238,7 @@ Puppet::Type.type(:mount).provide(
|
|
232
238
|
# to fstab we need to know if the device was mounted before)
|
233
239
|
mountinstances.each do |hash|
|
234
240
|
if mount = resources[hash[:name]]
|
241
|
+
mount.provider.set(:live_options => hash[:live_options])
|
235
242
|
case mount.provider.get(:ensure)
|
236
243
|
when :absent # Mount not in fstab
|
237
244
|
mount.provider.set(:ensure => :ghost)
|
@@ -254,6 +261,7 @@ Puppet::Type.type(:mount).provide(
|
|
254
261
|
else
|
255
262
|
/ on (\S*)/
|
256
263
|
end
|
264
|
+
|
257
265
|
instances = []
|
258
266
|
mount_output = mountcmd.split("\n")
|
259
267
|
if mount_output.length >= 2 and mount_output[1] =~ /^[- \t]*$/
|
@@ -264,7 +272,13 @@ Puppet::Type.type(:mount).provide(
|
|
264
272
|
end
|
265
273
|
mount_output.each do |line|
|
266
274
|
if match = regex.match(line) and name = match.captures.first
|
267
|
-
|
275
|
+
live_options_platforms = ["Linux", "Darwin"]
|
276
|
+
if live_options_platforms.include? Facter.value(:kernel)
|
277
|
+
options = line[/\(.*\)/].tr('()', '')
|
278
|
+
instances << {:name => name, :mounted => :yes, :live_options => options}
|
279
|
+
else
|
280
|
+
instances << {:name => name, :mounted => :yes}
|
281
|
+
end
|
268
282
|
else
|
269
283
|
raise Puppet::Error, "Could not understand line #{line} from mount output"
|
270
284
|
end
|
@@ -22,6 +22,12 @@ class Puppet::Provider::NameService::DirectoryService < Puppet::Provider::NameSe
|
|
22
22
|
confine :feature => :cfpropertylist
|
23
23
|
defaultfor :operatingsystem => :darwin
|
24
24
|
|
25
|
+
# There is no generalized mechanism for provider cache management, but we can
|
26
|
+
# use post_resource_eval, which will be run for each suitable provider at the
|
27
|
+
# end of each transaction. Use this to clear @all_present after each run.
|
28
|
+
def self.post_resource_eval
|
29
|
+
@all_present = nil
|
30
|
+
end
|
25
31
|
|
26
32
|
# JJM 2007-07-25: This map is used to map NameService attributes to their
|
27
33
|
# corresponding DirectoryService attribute names.
|
@@ -87,13 +93,15 @@ class Puppet::Provider::NameService::DirectoryService < Puppet::Provider::NameSe
|
|
87
93
|
end
|
88
94
|
|
89
95
|
def self.list_all_present
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
96
|
+
@all_present ||= begin
|
97
|
+
# JJM: List all objects of this Puppet::Type already present on the system.
|
98
|
+
begin
|
99
|
+
dscl_output = execute(get_exec_preamble("-list"))
|
100
|
+
rescue Puppet::ExecutionFailure
|
101
|
+
fail("Could not get #{@resource_type.name} list from DirectoryService")
|
102
|
+
end
|
103
|
+
dscl_output.split("\n")
|
95
104
|
end
|
96
|
-
dscl_output.split("\n")
|
97
105
|
end
|
98
106
|
|
99
107
|
def self.parse_dscl_plist_data(dscl_output)
|
@@ -102,7 +110,7 @@ class Puppet::Provider::NameService::DirectoryService < Puppet::Provider::NameSe
|
|
102
110
|
|
103
111
|
def self.generate_attribute_hash(input_hash, *type_properties)
|
104
112
|
attribute_hash = {}
|
105
|
-
input_hash.
|
113
|
+
input_hash.each_key do |key|
|
106
114
|
ds_attribute = key.sub("dsAttrTypeStandard:", "")
|
107
115
|
next unless (ds_to_ns_attribute_map.keys.include?(ds_attribute) and type_properties.include? ds_to_ns_attribute_map[ds_attribute])
|
108
116
|
ds_value = input_hash[key]
|
@@ -92,7 +92,12 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
|
|
92
92
|
|
93
93
|
def install(useversion = true)
|
94
94
|
command = [command(:gemcmd), "install"]
|
95
|
-
|
95
|
+
if Puppet.features.microsoft_windows?
|
96
|
+
version = resource[:ensure]
|
97
|
+
command << "-v" << %Q["#{version}"] if (! resource[:ensure].is_a? Symbol) and useversion
|
98
|
+
else
|
99
|
+
command << "-v" << resource[:ensure] if (! resource[:ensure].is_a? Symbol) and useversion
|
100
|
+
end
|
96
101
|
|
97
102
|
if source = resource[:source]
|
98
103
|
begin
|
@@ -203,10 +203,14 @@ Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package d
|
|
203
203
|
else
|
204
204
|
command = 'update'
|
205
205
|
end
|
206
|
+
args = ['--accept']
|
207
|
+
if Puppet::Util::Package.versioncmp(Facter.value(:operatingsystemrelease), '11.2') >= 0
|
208
|
+
args.push('--sync-actuators-timeout', '900')
|
209
|
+
end
|
206
210
|
unless should.is_a? Symbol
|
207
211
|
name += "@#{should}"
|
208
212
|
end
|
209
|
-
r = exec_cmd(command(:pkg), command,
|
213
|
+
r = exec_cmd(command(:pkg), command, *args, name)
|
210
214
|
return r if nofail
|
211
215
|
raise Puppet::Error, "Unable to update #{r[:out]}" if r[:exit] != 0
|
212
216
|
end
|
@@ -62,7 +62,7 @@ Puppet::Type.type(:package).provide :pkgng, :parent => Puppet::Provider::Package
|
|
62
62
|
|
63
63
|
def self.prefetch(resources)
|
64
64
|
packages = instances
|
65
|
-
resources.
|
65
|
+
resources.each_key do |name|
|
66
66
|
if provider = packages.find{|p| p.name == name or p.origin == name }
|
67
67
|
resources[name].provider = provider
|
68
68
|
end
|
@@ -156,6 +156,16 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
|
|
156
156
|
operation = :install
|
157
157
|
|
158
158
|
case should
|
159
|
+
when :latest
|
160
|
+
current_package = self.query
|
161
|
+
if current_package && !current_package[:ensure].to_s.empty?
|
162
|
+
operation = update_command
|
163
|
+
self.debug "Ensuring latest, so using #{operation}"
|
164
|
+
else
|
165
|
+
self.debug "Ensuring latest, but package is absent, so using #{:install}"
|
166
|
+
operation = :install
|
167
|
+
end
|
168
|
+
should = nil
|
159
169
|
when true, false, Symbol
|
160
170
|
# pass
|
161
171
|
should = nil
|
@@ -135,6 +135,7 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
|
135
135
|
@label_to_path_map = {}
|
136
136
|
launchd_paths.each do |path|
|
137
137
|
return_globbed_list_of_file_paths(path).each do |filepath|
|
138
|
+
Puppet.debug("Reading launchd plist #{filepath}")
|
138
139
|
job = read_plist(filepath)
|
139
140
|
next if job.nil?
|
140
141
|
if job.has_key?("Label")
|
@@ -100,7 +100,7 @@ Puppet::Type.type(:user).provide :directoryservice do
|
|
100
100
|
# supported by the user type.
|
101
101
|
def self.generate_attribute_hash(input_hash)
|
102
102
|
attribute_hash = {}
|
103
|
-
input_hash.
|
103
|
+
input_hash.each_key do |key|
|
104
104
|
ds_attribute = key.sub("dsAttrTypeStandard:", "")
|
105
105
|
next unless ds_to_ns_attribute_map.keys.include?(ds_attribute)
|
106
106
|
ds_value = input_hash[key]
|
@@ -121,7 +121,7 @@ Puppet::Type.type(:user).provide :directoryservice do
|
|
121
121
|
end
|
122
122
|
attribute_hash[:ensure] = :present
|
123
123
|
attribute_hash[:provider] = :directoryservice
|
124
|
-
attribute_hash[:shadowhashdata] =
|
124
|
+
attribute_hash[:shadowhashdata] = input_hash['dsAttrTypeNative:ShadowHashData']
|
125
125
|
|
126
126
|
##############
|
127
127
|
# Get Groups #
|
@@ -145,12 +145,12 @@ Puppet::Type.type(:user).provide :directoryservice do
|
|
145
145
|
attribute_hash[:password] = '*'
|
146
146
|
else
|
147
147
|
embedded_binary_plist = get_embedded_binary_plist(attribute_hash[:shadowhashdata])
|
148
|
-
if embedded_binary_plist['SALTED-SHA512']
|
149
|
-
attribute_hash[:password] = get_salted_sha512(embedded_binary_plist)
|
150
|
-
else
|
148
|
+
if embedded_binary_plist['SALTED-SHA512-PBKDF2']
|
151
149
|
attribute_hash[:password] = get_salted_sha512_pbkdf2('entropy', embedded_binary_plist)
|
152
150
|
attribute_hash[:salt] = get_salted_sha512_pbkdf2('salt', embedded_binary_plist)
|
153
151
|
attribute_hash[:iterations] = get_salted_sha512_pbkdf2('iterations', embedded_binary_plist)
|
152
|
+
elsif embedded_binary_plist['SALTED-SHA512']
|
153
|
+
attribute_hash[:password] = get_salted_sha512(embedded_binary_plist)
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
@@ -178,7 +178,7 @@ Puppet::Type.type(:user).provide :directoryservice do
|
|
178
178
|
# plist library doesn't read binary plists, so we need to
|
179
179
|
# extract the binary plist, convert it to XML, and return it.
|
180
180
|
def self.get_embedded_binary_plist(shadow_hash_data)
|
181
|
-
embedded_binary_plist = Array(shadow_hash_data[
|
181
|
+
embedded_binary_plist = Array(shadow_hash_data[0].delete(' ')).pack('H*')
|
182
182
|
convert_binary_to_hash(embedded_binary_plist)
|
183
183
|
end
|
184
184
|
|
@@ -58,7 +58,7 @@ Puppet::Type.type(:yumrepo).provide(:inifile) do
|
|
58
58
|
# @return [void]
|
59
59
|
def self.prefetch(resources)
|
60
60
|
repos = instances
|
61
|
-
resources.
|
61
|
+
resources.each_key do |name|
|
62
62
|
if provider = repos.find { |repo| repo.name == name }
|
63
63
|
resources[name].provider = provider
|
64
64
|
end
|
data/lib/puppet/resource.rb
CHANGED
@@ -31,7 +31,7 @@ class Puppet::Resource
|
|
31
31
|
TYPE_NODE = 'Node'.freeze
|
32
32
|
TYPE_SITE = 'Site'.freeze
|
33
33
|
|
34
|
-
def self.from_data_hash(data)
|
34
|
+
def self.from_data_hash(data, json_deserializer = nil)
|
35
35
|
raise ArgumentError, "No resource type provided in serialized data" unless type = data['type']
|
36
36
|
raise ArgumentError, "No resource title provided in serialized data" unless title = data['title']
|
37
37
|
|
@@ -41,6 +41,15 @@ class Puppet::Resource
|
|
41
41
|
params.each { |param, value| resource[param] = value }
|
42
42
|
end
|
43
43
|
|
44
|
+
if ext_params = data['ext_parameters']
|
45
|
+
raise Puppet::Error, 'Unable to deserialize non-Data type parameters unless a deserializer is provided' unless json_deserializer
|
46
|
+
reader = json_deserializer.reader
|
47
|
+
ext_params.each do |param, value|
|
48
|
+
reader.re_initialize([value])
|
49
|
+
resource[param] = json_deserializer.read
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
44
53
|
if sensitive_parameters = data['sensitive_parameters']
|
45
54
|
resource.sensitive_parameters = sensitive_parameters.map(&:to_sym)
|
46
55
|
end
|
@@ -62,7 +71,7 @@ class Puppet::Resource
|
|
62
71
|
"#{@type}[#{@title}]#{to_hash.inspect}"
|
63
72
|
end
|
64
73
|
|
65
|
-
def to_data_hash
|
74
|
+
def to_data_hash(json_serializer = nil)
|
66
75
|
data = ([:type, :title, :tags] + ATTRIBUTES).inject({}) do |hash, param|
|
67
76
|
next hash unless value = self.send(param)
|
68
77
|
hash[param.to_s] = value
|
@@ -71,23 +80,56 @@ class Puppet::Resource
|
|
71
80
|
|
72
81
|
data["exported"] ||= false
|
73
82
|
|
74
|
-
|
75
|
-
|
76
|
-
|
83
|
+
ext_params = {}
|
84
|
+
params = {}
|
85
|
+
self.to_hash.each_pair do |param, value|
|
77
86
|
# Don't duplicate the title as the namevar
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
87
|
+
unless param == namevar && value == title
|
88
|
+
value = Puppet::Resource.value_to_pson_data(value)
|
89
|
+
if is_json_type?(value)
|
90
|
+
params[param] = value
|
91
|
+
elsif json_serializer.nil?
|
92
|
+
Puppet.warning("Resource '#{to_s}' contains a #{value.class.name} value. It will be converted to the String '#{value}'")
|
93
|
+
params[param] = value
|
94
|
+
else
|
95
|
+
ext_params[param] = value
|
96
|
+
end
|
97
|
+
end
|
82
98
|
end
|
83
99
|
|
84
|
-
data[
|
100
|
+
data['parameters'] = params unless params.empty?
|
101
|
+
unless ext_params.empty?
|
102
|
+
writer = json_serializer.writer
|
103
|
+
ext_params.each_key do |key|
|
104
|
+
writer.clear_io
|
105
|
+
json_serializer.write(ext_params[key])
|
106
|
+
writer.finish
|
107
|
+
ext_params[key] = writer.to_a[0]
|
108
|
+
end
|
109
|
+
data['ext_parameters'] = ext_params
|
110
|
+
end
|
85
111
|
|
86
112
|
data["sensitive_parameters"] = sensitive_parameters unless sensitive_parameters.empty?
|
87
113
|
|
88
114
|
data
|
89
115
|
end
|
90
116
|
|
117
|
+
# @param [Object] value The value to test
|
118
|
+
# @return [Boolean] `true` if the value can be represented as JSON
|
119
|
+
# @api private
|
120
|
+
def is_json_type?(value)
|
121
|
+
case value
|
122
|
+
when NilClass, TrueClass, FalseClass, Integer, Float, String
|
123
|
+
true
|
124
|
+
when Array
|
125
|
+
value.all? { |elem| is_json_type?(elem) }
|
126
|
+
when Hash
|
127
|
+
value.all? { |key, val| key.is_a?(String) && is_json_type?(val) }
|
128
|
+
else
|
129
|
+
false
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
91
133
|
def self.value_to_pson_data(value)
|
92
134
|
if value.is_a? Array
|
93
135
|
value.map{|v| value_to_pson_data(v) }
|
@@ -252,7 +294,7 @@ class Puppet::Resource
|
|
252
294
|
# * a "classic" 3.x ruby plugin
|
253
295
|
# * a compatible implementation (e.g. loading from pcore metadata)
|
254
296
|
# * a resolved user defined type
|
255
|
-
#
|
297
|
+
#
|
256
298
|
# ...then, modify the parameters to the "old" (agent side compatible) way
|
257
299
|
# of describing the type/title with string/symbols.
|
258
300
|
#
|
@@ -319,7 +361,7 @@ class Puppet::Resource
|
|
319
361
|
# A resource is a capability (instance) if its underlying type is a
|
320
362
|
# capability type
|
321
363
|
def is_capability?
|
322
|
-
resource_type
|
364
|
+
!resource_type.nil? && resource_type.is_capability?
|
323
365
|
end
|
324
366
|
|
325
367
|
# Returns the value of the 'export' metaparam as an Array
|
@@ -26,7 +26,12 @@ module Puppet::Resource::CapabilityFinder
|
|
26
26
|
raise Puppet::DevError, 'PuppetDB is not available'
|
27
27
|
end
|
28
28
|
|
29
|
-
resources = search(
|
29
|
+
resources = search(nil, nil, cap)
|
30
|
+
|
31
|
+
if resources.size > 1
|
32
|
+
Puppet.debug "Found multiple resources when looking up capability #{cap}, filtering by environment #{environment}"
|
33
|
+
resources = resources.select { |r| r['tags'].any? { |t| t == "producer:#{environment}" } }
|
34
|
+
end
|
30
35
|
|
31
36
|
if resources.size > 1 && code_id
|
32
37
|
Puppet.debug "Found multiple resources when looking up capability #{cap}, filtering by code id #{code_id}"
|
@@ -41,6 +46,7 @@ module Puppet::Resource::CapabilityFinder
|
|
41
46
|
end
|
42
47
|
|
43
48
|
if resource_hash = resources.first
|
49
|
+
resource_hash['type'] = cap.resource_type
|
44
50
|
instantiate_resource(resource_hash)
|
45
51
|
else
|
46
52
|
Puppet.debug "Could not find capability resource #{cap} in PuppetDB"
|
@@ -53,9 +59,14 @@ module Puppet::Resource::CapabilityFinder
|
|
53
59
|
'and',
|
54
60
|
['=', 'type', cap.type.capitalize],
|
55
61
|
['=', 'title', cap.title.to_s],
|
56
|
-
['=', 'tag', "producer:#{environment}"]
|
57
62
|
]
|
58
63
|
|
64
|
+
if environment.nil?
|
65
|
+
query_terms << ['~', 'tag', "^producer:"]
|
66
|
+
else
|
67
|
+
query_terms << ['=', 'tag', "producer:#{environment}"]
|
68
|
+
end
|
69
|
+
|
59
70
|
unless code_id.nil?
|
60
71
|
query_terms << ['in', 'certname',
|
61
72
|
['extract', 'certname',
|
@@ -101,13 +112,8 @@ module Puppet::Resource::CapabilityFinder
|
|
101
112
|
private
|
102
113
|
|
103
114
|
def self.instantiate_resource(resource_hash)
|
104
|
-
|
105
|
-
|
106
|
-
real_type = Puppet::Type.type(resource.type)
|
107
|
-
if real_type.nil?
|
108
|
-
fail Puppet::ParseError,
|
109
|
-
"Could not find resource type #{resource.type} returned from PuppetDB"
|
110
|
-
end
|
115
|
+
real_type = resource_hash['type']
|
116
|
+
resource = Puppet::Resource.new(real_type, resource_hash['title'])
|
111
117
|
real_type.parameters.each do |param|
|
112
118
|
param = param.to_s
|
113
119
|
next if param == 'name'
|