puppet 4.4.2-universal-darwin → 4.5.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/CONTRIBUTING.md +5 -5
- data/Gemfile +2 -2
- data/LICENSE +2 -2
- data/README.md +5 -0
- data/ext/project_data.yaml +2 -0
- data/lib/hiera_puppet.rb +6 -14
- data/lib/puppet/application/agent.rb +2 -3
- data/lib/puppet/data_providers/hiera_config.rb +2 -4
- data/lib/puppet/data_providers/hiera_interpolate.rb +12 -154
- data/lib/puppet/data_providers/json_data_provider_factory.rb +0 -7
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -8
- data/lib/puppet/defaults.rb +70 -7
- data/lib/puppet/functions.rb +69 -0
- data/lib/puppet/functions/dig.rb +39 -0
- data/lib/puppet/functions/lest.rb +53 -0
- data/lib/puppet/functions/lookup.rb +40 -27
- data/lib/puppet/functions/new.rb +502 -0
- data/lib/puppet/functions/regsubst.rb +11 -10
- data/lib/puppet/functions/then.rb +74 -0
- data/lib/puppet/functions/type.rb +4 -4
- data/lib/puppet/functions/with.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +2 -0
- data/lib/puppet/indirector/resource_type/parser.rb +5 -0
- data/lib/puppet/indirector/rest.rb +5 -1
- data/lib/puppet/loaders.rb +2 -0
- data/lib/puppet/metatype/manager.rb +19 -2
- data/lib/puppet/module_tool/applications/application.rb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +6 -2
- data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +19 -4
- data/lib/puppet/module_tool/skeleton/templates/generator/{tests → examples}/init.pp.erb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +0 -1
- data/lib/puppet/network/http/api/master/v3/environment.rb +6 -2
- data/lib/puppet/parser/ast/pops_bridge.rb +20 -3
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +24 -2
- data/lib/puppet/parser/e4_parser_adapter.rb +13 -12
- data/lib/puppet/parser/environment_compiler.rb +2 -2
- data/lib/puppet/parser/resource.rb +14 -5
- data/lib/puppet/parser/scope.rb +18 -15
- data/lib/puppet/plugins/data_providers/data_provider.rb +19 -8
- data/lib/puppet/pops.rb +6 -0
- data/lib/puppet/pops/adapters.rb +5 -1
- data/lib/puppet/pops/evaluator/access_operator.rb +52 -14
- data/lib/puppet/pops/evaluator/compare_operator.rb +34 -4
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +75 -22
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +7 -6
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +13 -1
- data/lib/puppet/pops/evaluator/runtime3_support.rb +14 -4
- data/lib/puppet/pops/functions/dispatcher.rb +1 -1
- data/lib/puppet/pops/issues.rb +18 -2
- data/lib/puppet/pops/loader/base_loader.rb +48 -7
- data/lib/puppet/pops/loader/dependency_loader.rb +27 -2
- data/lib/puppet/pops/loader/loader.rb +12 -0
- data/lib/puppet/pops/loader/predefined_loader.rb +29 -0
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +57 -0
- data/lib/puppet/pops/loader/static_loader.rb +92 -5
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +25 -3
- data/lib/puppet/pops/loaders.rb +84 -14
- data/lib/puppet/pops/lookup/explainer.rb +38 -1
- data/lib/puppet/pops/lookup/interpolation.rb +115 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +86 -0
- data/lib/puppet/pops/model/ast_transformer.rb +8 -1
- data/lib/puppet/pops/model/factory.rb +31 -8
- data/lib/puppet/pops/model/model.rb +8 -0
- data/lib/puppet/pops/model/model_label_provider.rb +1 -0
- data/lib/puppet/pops/model/model_meta.rb +7 -1
- data/lib/puppet/pops/model/model_tree_dumper.rb +4 -0
- data/lib/puppet/pops/parser/egrammar.ra +24 -7
- data/lib/puppet/pops/parser/eparser.rb +863 -798
- data/lib/puppet/pops/parser/evaluating_parser.rb +4 -0
- data/lib/puppet/pops/parser/locator.rb +8 -4
- data/lib/puppet/pops/pcore.rb +30 -0
- data/lib/puppet/pops/types/class_loader.rb +2 -4
- data/lib/puppet/pops/types/implementation_registry.rb +146 -0
- data/lib/puppet/pops/types/iterable.rb +4 -4
- data/lib/puppet/pops/types/p_object_type.rb +846 -0
- data/lib/puppet/pops/types/p_runtime_type.rb +102 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +164 -0
- data/lib/puppet/pops/types/p_sem_ver_type.rb +113 -0
- data/lib/puppet/pops/types/puppet_object.rb +21 -0
- data/lib/puppet/pops/types/ruby_generator.rb +258 -0
- data/lib/puppet/pops/types/string_converter.rb +922 -0
- data/lib/puppet/pops/types/type_calculator.rb +29 -5
- data/lib/puppet/pops/types/type_conversion_error.rb +15 -0
- data/lib/puppet/pops/types/type_factory.rb +49 -16
- data/lib/puppet/pops/types/type_formatter.rb +335 -112
- data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -29
- data/lib/puppet/pops/types/type_parser.rb +205 -197
- data/lib/puppet/pops/types/types.rb +481 -103
- data/lib/puppet/pops/validation.rb +1 -1
- data/lib/puppet/pops/validation/checker4_0.rb +66 -4
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -0
- data/lib/puppet/pops/visitor.rb +3 -1
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +64 -20
- data/lib/puppet/provider/package/rpm.rb +112 -0
- data/lib/puppet/provider/package/yum.rb +7 -68
- data/lib/puppet/provider/service/daemontools.rb +3 -3
- data/lib/puppet/provider/service/init.rb +4 -2
- data/lib/puppet/provider/service/runit.rb +3 -3
- data/lib/puppet/provider/service/smf.rb +6 -3
- data/lib/puppet/provider/service/systemd.rb +59 -73
- data/lib/puppet/reference/providers.rb +1 -2
- data/lib/puppet/resource.rb +54 -37
- data/lib/puppet/resource/catalog.rb +31 -29
- data/lib/puppet/resource/type_collection.rb +23 -8
- data/lib/puppet/settings.rb +4 -2
- data/lib/puppet/settings/base_setting.rb +9 -3
- data/lib/puppet/settings/symbolic_enum_setting.rb +17 -0
- data/lib/puppet/test/test_helper.rb +0 -1
- data/lib/puppet/type.rb +9 -3
- data/lib/puppet/type/exec.rb +17 -17
- data/lib/puppet/type/file.rb +12 -0
- data/lib/puppet/type/file/content.rb +6 -6
- data/lib/puppet/type/file/ensure.rb +4 -4
- data/lib/puppet/type/file/source.rb +4 -4
- data/lib/puppet/type/file/target.rb +2 -2
- data/lib/puppet/type/mount.rb +18 -1
- data/lib/puppet/type/package.rb +3 -3
- data/lib/puppet/type/schedule.rb +4 -4
- data/lib/puppet/type/service.rb +15 -0
- data/lib/puppet/type/sshkey.rb +5 -3
- data/lib/puppet/type/tidy.rb +3 -3
- data/lib/puppet/type/zone.rb +5 -5
- data/lib/puppet/util/feature.rb +1 -1
- data/lib/puppet/util/monkey_patches.rb +8 -0
- data/lib/puppet/util/network_device/cisco/device.rb +16 -6
- data/lib/puppet/util/network_device/cisco/interface.rb +5 -6
- data/lib/puppet/util/plist.rb +3 -3
- data/lib/puppet/version.rb +1 -1
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +13 -0
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/lib/puppet/functions/abc/data.rb +2 -1
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/manifests/init.pp +2 -1
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/data/empty_key.json +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/data/empty_key.yaml +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/data/empty.yaml +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/lib/puppet/type/usee_type.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/manifests/init.pp +6 -0
- data/spec/fixtures/unit/provider/service/smf/svcs.out +4 -3
- data/spec/integration/module_tool/tar/mini_spec.rb +27 -27
- data/spec/integration/parser/catalog_spec.rb +14 -2
- data/spec/integration/parser/compiler_spec.rb +94 -3
- data/spec/integration/parser/resource_expressions_spec.rb +1 -1
- data/spec/integration/resource/type_collection_spec.rb +8 -0
- data/spec/lib/puppet_spec/compiler.rb +11 -4
- data/spec/shared_contexts/types_setup.rb +4 -0
- data/spec/unit/application/lookup_spec.rb +91 -9
- data/spec/unit/appmgmt_spec.rb +44 -35
- data/spec/unit/capability_spec.rb +33 -53
- data/spec/unit/data_providers/function_data_provider_spec.rb +19 -1
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +1 -1
- data/spec/unit/defaults_spec.rb +18 -0
- data/spec/unit/functions/assert_type_spec.rb +1 -1
- data/spec/unit/functions/dig_spec.rb +58 -0
- data/spec/unit/functions/lest_spec.rb +34 -0
- data/spec/unit/functions/lookup_spec.rb +108 -2
- data/spec/unit/functions/new_spec.rb +543 -0
- data/spec/unit/functions/regsubst_spec.rb +8 -0
- data/spec/unit/functions/then_spec.rb +40 -0
- data/spec/unit/functions4_spec.rb +78 -10
- data/spec/unit/hiera_puppet_spec.rb +49 -8
- data/spec/unit/indirector/resource_type/parser_spec.rb +5 -0
- data/spec/unit/indirector/rest_spec.rb +12 -0
- data/spec/unit/network/http/api/master/v3/environment_spec.rb +60 -0
- data/spec/unit/node/environment_spec.rb +10 -0
- data/spec/unit/parser/compiler_spec.rb +20 -1
- data/spec/unit/parser/functions/create_resources_spec.rb +2 -2
- data/spec/unit/parser/functions/shared.rb +1 -1
- data/spec/unit/parser/resource_spec.rb +8 -1
- data/spec/unit/parser/scope_spec.rb +45 -0
- data/spec/unit/pops/evaluator/access_ops_spec.rb +14 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +13 -5
- data/spec/unit/pops/loaders/static_loader_spec.rb +92 -1
- data/spec/unit/{data_providers/hiera_interpolation_spec.rb → pops/lookup/interpolation_spec.rb} +7 -5
- data/spec/unit/pops/parser/lexer2_spec.rb +2 -9
- data/spec/unit/pops/parser/parse_application_spec.rb +3 -8
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +19 -0
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +3 -10
- data/spec/unit/pops/parser/parse_site_spec.rb +19 -10
- data/spec/unit/pops/parser/parser_rspec_helper.rb +0 -4
- data/spec/unit/pops/types/enumeration_spec.rb +13 -12
- data/spec/unit/pops/types/iterable_spec.rb +2 -2
- data/spec/unit/pops/types/p_object_type_spec.rb +1060 -0
- data/spec/unit/pops/types/p_sem_ver_type_spec.rb +285 -0
- data/spec/unit/pops/types/recursion_guard_spec.rb +19 -17
- data/spec/unit/pops/types/ruby_generator_spec.rb +261 -0
- data/spec/unit/pops/types/string_converter_spec.rb +904 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +430 -406
- data/spec/unit/pops/types/type_factory_spec.rb +119 -104
- data/spec/unit/pops/types/type_formatter_spec.rb +73 -6
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +2 -2
- data/spec/unit/pops/types/type_parser_spec.rb +54 -15
- data/spec/unit/pops/types/types_spec.rb +113 -8
- data/spec/unit/pops/validator/validator_spec.rb +84 -10
- data/spec/unit/provider/package/pip3_spec.rb +9 -270
- data/spec/unit/provider/package/pip_spec.rb +85 -30
- data/spec/unit/provider/package/rpm_spec.rb +160 -3
- data/spec/unit/provider/package/yum_spec.rb +23 -134
- data/spec/unit/provider/service/smf_spec.rb +14 -2
- data/spec/unit/provider/service/systemd_spec.rb +33 -41
- data/spec/unit/resource/capability_finder_spec.rb +10 -2
- data/spec/unit/settings/file_setting_spec.rb +6 -0
- data/spec/unit/transaction/additional_resource_generator_spec.rb +80 -65
- data/spec/unit/type/mount_spec.rb +51 -10
- data/spec/unit/type/service_spec.rb +16 -0
- data/spec/unit/type_spec.rb +14 -0
- data/spec/unit/util/feature_spec.rb +1 -1
- data/spec/unit/util/monkey_patches_spec.rb +60 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
- metadata +63 -11
- data/lib/puppet/pops/types/types_meta.rb +0 -0
- data/spec/integration/provider/package_spec.rb +0 -35
data/CONTRIBUTING.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# How to contribute
|
2
2
|
|
3
|
-
Third-party patches are essential for keeping
|
3
|
+
Third-party patches are essential for keeping Puppet great. We simply can't
|
4
4
|
access the huge number of platforms and myriad configurations for running
|
5
|
-
|
5
|
+
Puppet. We want to keep it as easy as possible to contribute changes that
|
6
6
|
get things working in your environment. There are a few guidelines that we
|
7
7
|
need contributors to follow so that we can have a chance of keeping on
|
8
8
|
top of things.
|
@@ -90,7 +90,7 @@ a ticket number.
|
|
90
90
|
|
91
91
|
## Submitting Changes
|
92
92
|
|
93
|
-
* Sign the [Contributor License Agreement](http://links.
|
93
|
+
* Sign the [Contributor License Agreement](http://links.puppet.com/cla).
|
94
94
|
* Push your changes to a topic branch in your fork of the repository.
|
95
95
|
* Submit a pull request to the repository in the puppetlabs organization.
|
96
96
|
* Update your Jira ticket to mark that you have submitted code and are ready for it to be reviewed (Status: Ready for Merge).
|
@@ -106,9 +106,9 @@ a ticket number.
|
|
106
106
|
|
107
107
|
# Additional Resources
|
108
108
|
|
109
|
-
* [Puppet
|
109
|
+
* [Puppet community guidelines](https://docs.puppet.com/community/community_guidelines.html)
|
110
110
|
* [Bug tracker (Jira)](https://tickets.puppetlabs.com)
|
111
|
-
* [Contributor License Agreement](http://links.
|
111
|
+
* [Contributor License Agreement](http://links.puppet.com/cla)
|
112
112
|
* [General GitHub documentation](https://help.github.com/)
|
113
113
|
* [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
|
114
114
|
* #puppet-dev IRC channel on freenode.org ([Archive](https://botbot.me/freenode/puppet-dev/))
|
data/Gemfile
CHANGED
@@ -46,11 +46,11 @@ group(:development, :test) do
|
|
46
46
|
gem "multi_json", "1.7.7", :require => false, :platforms => [:ruby, :jruby]
|
47
47
|
gem "json-schema", "2.1.1", :require => false, :platforms => [:ruby, :jruby]
|
48
48
|
|
49
|
-
gem "rubocop", "~> 0.
|
49
|
+
gem "rubocop", "~> 0.39.0", :platforms => [:ruby]
|
50
50
|
|
51
51
|
gem 'rdoc', "~> 4.1", :platforms => [:ruby]
|
52
52
|
|
53
|
-
gem 'webmock'
|
53
|
+
gem 'webmock', '~> 1.24'
|
54
54
|
gem 'vcr', '~> 2.9'
|
55
55
|
end
|
56
56
|
|
data/LICENSE
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Puppet - Automating Configuration Management.
|
2
2
|
|
3
|
-
Copyright (C) 2005-
|
3
|
+
Copyright (C) 2005-2016 Puppet, Inc.
|
4
4
|
|
5
|
-
Puppet
|
5
|
+
Puppet, Inc. can be contacted at: info@puppet.com
|
6
6
|
|
7
7
|
Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
@@ -73,3 +73,8 @@ commercial customers. Please see the following page for more details:
|
|
73
73
|
|
74
74
|
[Puppet Enterprise Support Lifecycle](https://puppetlabs.com/misc/puppet-enterprise-lifecycle)
|
75
75
|
|
76
|
+
Maintainers
|
77
|
+
-------
|
78
|
+
|
79
|
+
* Kylo Ginsberg, kylo@puppet.com, github:kylog, jira:kylo
|
80
|
+
* Henrik Lindberg, henrik.lindberg@puppet.com, github:hlindberg, jira:henrik.lindberg
|
data/ext/project_data.yaml
CHANGED
@@ -14,6 +14,8 @@ gem_test_files: 'spec/**/*'
|
|
14
14
|
gem_executables: 'puppet'
|
15
15
|
gem_default_executables: 'puppet'
|
16
16
|
gem_forge_project: 'puppet'
|
17
|
+
gem_required_ruby_version: '>= 1.9.3'
|
18
|
+
gem_required_rubygems_version: '> 1.3.1'
|
17
19
|
gem_runtime_dependencies:
|
18
20
|
facter: ['> 2.0', '< 4']
|
19
21
|
hiera: ['>= 2.0', '< 4']
|
data/lib/hiera_puppet.rb
CHANGED
@@ -67,21 +67,13 @@ module HieraPuppet
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def hiera_config_file
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
elsif Puppet.settings[:confdir].is_a?(String)
|
78
|
-
expanded_config_file = File.expand_path(File.join(Puppet.settings[:confdir], '/hiera.yaml'))
|
79
|
-
if Puppet::FileSystem.exist?(expanded_config_file)
|
80
|
-
config_file = expanded_config_file
|
81
|
-
end
|
70
|
+
hiera_config = Puppet.settings[:hiera_config]
|
71
|
+
if Puppet::FileSystem.exist?(hiera_config)
|
72
|
+
hiera_config
|
73
|
+
else
|
74
|
+
Puppet.warning "Config file #{hiera_config} not found, using Hiera defaults"
|
75
|
+
nil
|
82
76
|
end
|
83
|
-
|
84
|
-
config_file
|
85
77
|
end
|
86
78
|
end
|
87
79
|
|
@@ -263,8 +263,8 @@ generated by running puppet agent with '--genconfig'.
|
|
263
263
|
|
264
264
|
* --test:
|
265
265
|
Enable the most common options used for testing. These are 'onetime',
|
266
|
-
'verbose', '
|
267
|
-
'
|
266
|
+
'verbose', 'no-daemonize', 'no-usecacheonfailure', 'detailed-exitcodes',
|
267
|
+
'no-splay', and 'show_diff'.
|
268
268
|
|
269
269
|
* --verbose:
|
270
270
|
Turn on verbose reporting.
|
@@ -373,7 +373,6 @@ Copyright (c) 2011 Puppet Labs, LLC Licensed under the Apache 2.0 License
|
|
373
373
|
|
374
374
|
# Enable all of the most common test options.
|
375
375
|
def setup_test
|
376
|
-
Puppet.settings.handlearg("--ignorecache")
|
377
376
|
Puppet.settings.handlearg("--no-usecacheonfailure")
|
378
377
|
Puppet.settings.handlearg("--no-splay")
|
379
378
|
Puppet.settings.handlearg("--show_diff")
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'pathname'
|
2
|
-
|
2
|
+
require 'puppet/pops/lookup/interpolation'
|
3
3
|
|
4
4
|
module Puppet::DataProviders
|
5
5
|
class HieraConfig
|
6
6
|
include Puppet::Plugins::DataProviders
|
7
|
-
include
|
7
|
+
include Puppet::Pops::Lookup::Interpolation
|
8
8
|
|
9
9
|
DEFAULT_CONFIG = {
|
10
10
|
'version' => 4,
|
@@ -27,8 +27,6 @@ module Puppet::DataProviders
|
|
27
27
|
Hash[struct.map { |k,v| [k.to_s, symkeys_to_string(v)] }]
|
28
28
|
when Array
|
29
29
|
struct.map { |v| symkeys_to_string(v) }
|
30
|
-
when nil
|
31
|
-
{}
|
32
30
|
else
|
33
31
|
struct
|
34
32
|
end
|
@@ -1,161 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Add support for Hiera-like interpolation expressions. The expressions may contain keys that uses dot-notation
|
4
|
-
# to further navigate into hashes and arrays
|
5
|
-
#
|
1
|
+
# @deprecated Moved to Puppet::Pops::Lookup::Interpolation
|
6
2
|
module Puppet::DataProviders::HieraInterpolate
|
7
|
-
|
8
|
-
case subject
|
9
|
-
when String
|
10
|
-
subject.index('%{').nil? ? subject : interpolate_string(subject, lookup_invocation, allow_methods)
|
11
|
-
when Array
|
12
|
-
subject.map { |element| interpolate(element, lookup_invocation, allow_methods) }
|
13
|
-
when Hash
|
14
|
-
Hash[subject.map { |k, v| [k, interpolate(v, lookup_invocation, allow_methods)] }]
|
15
|
-
else
|
16
|
-
subject
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
EMPTY_INTERPOLATIONS = {
|
23
|
-
'' => true,
|
24
|
-
'::' => true,
|
25
|
-
'""' => true,
|
26
|
-
"''" => true,
|
27
|
-
'"::"' => true,
|
28
|
-
"'::'" => true
|
29
|
-
}.freeze
|
30
|
-
|
31
|
-
# Matches a key that is quoted using a matching pair of either single or double quotes.
|
32
|
-
QUOTED_KEY = /^(?:"([^"]+)"|'([^']+)')$/
|
33
|
-
|
34
|
-
def interpolate_string(subject, lookup_invocation, allow_methods)
|
35
|
-
lookup_invocation.with(:interpolate, subject) do
|
36
|
-
subject.gsub(/%\{([^\}]*)\}/) do |match|
|
37
|
-
expr = $1
|
38
|
-
# Leading and trailing spaces inside an interpolation expression are insignificant
|
39
|
-
expr.strip!
|
40
|
-
unless EMPTY_INTERPOLATIONS[expr]
|
41
|
-
method_key, key = get_method_and_data(expr, allow_methods)
|
42
|
-
is_alias = method_key == 'alias'
|
43
|
-
|
44
|
-
# Alias is only permitted if the entire string is equal to the interpolate expression
|
45
|
-
raise Puppet::DataBinding::LookupError, "'alias' interpolation is only permitted if the expression is equal to the entire string" if is_alias && subject != match
|
46
|
-
|
47
|
-
segments = split_key(key) { |problem| Puppet::DataBinding::LookupError.new("#{problem} in string: #{subject}") }
|
48
|
-
value = interpolate_method(method_key).call(segments[0], lookup_invocation)
|
49
|
-
value = qualified_lookup(segments.drop(1), value) if segments.size > 1
|
50
|
-
value = lookup_invocation.check(key) { interpolate(value, lookup_invocation, allow_methods) }
|
51
|
-
|
52
|
-
# break gsub and return value immediately if this was an alias substitution. The value might be something other than a String
|
53
|
-
return value if is_alias
|
54
|
-
end
|
55
|
-
value || ''
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def interpolate_method(method_key)
|
61
|
-
@@interpolate_methods ||= begin
|
62
|
-
global_lookup = lambda { |key, lookup_invocation| Puppet::Pops::Lookup.lookup(key, nil, '', true, nil, lookup_invocation) }
|
63
|
-
scope_lookup = lambda do |key, lookup_invocation|
|
64
|
-
lookup_invocation.with(:scope, nil) do
|
65
|
-
ovr = lookup_invocation.override_values
|
66
|
-
if ovr.include?(key)
|
67
|
-
lookup_invocation.report_found_in_overrides(key, ovr[key])
|
68
|
-
else
|
69
|
-
scope = lookup_invocation.scope
|
70
|
-
if scope.include?(key)
|
71
|
-
lookup_invocation.report_found(key, scope[key])
|
72
|
-
else
|
73
|
-
defaults = lookup_invocation.default_values
|
74
|
-
if defaults.include?(key)
|
75
|
-
lookup_invocation.report_found_in_defaults(key, defaults[key])
|
76
|
-
else
|
77
|
-
nil
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
|
85
|
-
{
|
86
|
-
'lookup' => global_lookup,
|
87
|
-
'hiera' => global_lookup, # this is just an alias for 'lookup'
|
88
|
-
'alias' => global_lookup, # same as 'lookup' but expression must be entire string. The result that is not subject to string substitution
|
89
|
-
'scope' => scope_lookup,
|
90
|
-
'literal' => lambda { |key, _| key }
|
91
|
-
}.freeze
|
92
|
-
end
|
93
|
-
interpolate_method = @@interpolate_methods[method_key]
|
94
|
-
raise Puppet::DataBinding::LookupError, "Unknown interpolation method '#{method_key}'" unless interpolate_method
|
95
|
-
interpolate_method
|
96
|
-
end
|
3
|
+
include Puppet::Pops::Lookup::Interpolation
|
97
4
|
|
5
|
+
# For backward compatibility
|
6
|
+
# @deprecated
|
98
7
|
def qualified_lookup(segments, value)
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
107
|
-
throw :no_such_key unless segment < value.size
|
108
|
-
else
|
109
|
-
unless value.respond_to?(:'[]') && !(value.instance_of?(Array) || value.instance_of?(String))
|
110
|
-
raise Puppet::DataBinding::LookupError,
|
111
|
-
"Data provider type mismatch: Got #{value.class.name} when a hash-like object was expected to enable lookup using key '#{segment}'"
|
112
|
-
end
|
113
|
-
throw :no_such_key unless value.include?(segment)
|
114
|
-
end
|
115
|
-
value = value[segment]
|
116
|
-
end
|
117
|
-
value
|
118
|
-
end
|
119
|
-
|
120
|
-
def get_method_and_data(data, allow_methods)
|
121
|
-
if match = data.match(/^(\w+)\((?:["]([^"]+)["]|[']([^']+)['])\)$/)
|
122
|
-
raise Puppet::DataBinding::LoookupError, 'Interpolation using method syntax is not allowed in this context' unless allow_methods
|
123
|
-
key = match[1]
|
124
|
-
data = match[2] || match[3] # double or single qouted
|
125
|
-
else
|
126
|
-
key = 'scope'
|
127
|
-
end
|
128
|
-
[key, data]
|
129
|
-
end
|
130
|
-
|
131
|
-
# Split key into segments. A segment may be a quoted string (both single and double quotes can
|
132
|
-
# be used) and the segment separator is the '.' character. Whitespace will be trimmed off on
|
133
|
-
# both sides of each segment. Whitespace within quotes are not trimmed.
|
134
|
-
#
|
135
|
-
# If the key cannot be parsed, this method will yield a string describing the problem to a one
|
136
|
-
# parameter block. The block must return an exception instance.
|
137
|
-
#
|
138
|
-
# @param key [String] the string to split
|
139
|
-
# @return Array<String> the array of segments
|
140
|
-
# @yieldparam problem [String] the problem, i.e. 'Syntax error'
|
141
|
-
# @yieldreturn [Exception] the exception to raise
|
142
|
-
def split_key(key)
|
143
|
-
segments = key.split(/(\s*"[^"]+"\s*|\s*'[^']+'\s*|[^'".]+)/)
|
144
|
-
if segments.empty?
|
145
|
-
# Only happens if the original key was an empty string
|
146
|
-
''
|
147
|
-
elsif segments.shift == ''
|
148
|
-
count = segments.size
|
149
|
-
raise yield('Syntax error') unless count > 0
|
150
|
-
|
151
|
-
segments.keep_if { |seg| seg != '.' }
|
152
|
-
raise yield('Syntax error') unless segments.size * 2 == count + 1
|
153
|
-
segments.map! do |segment|
|
154
|
-
segment.strip!
|
155
|
-
segment.start_with?('"') || segment.start_with?("'") ? segment[1..-2] : segment
|
8
|
+
if Puppet[:strict] != :off
|
9
|
+
msg = 'Puppet::DataProviders::HieraInterpolate#qualified_lookup is deprecated, use Puppet::Pops::Lookup::SubLookup#sub_lookup'
|
10
|
+
case Puppet[:strict]
|
11
|
+
when :error
|
12
|
+
raise Puppet::DataBinding::LookupError.new(msg)
|
13
|
+
when :warning
|
14
|
+
Puppet.warn_once(:deprecation, 'HieraInterpolate#qualified_lookup', msg)
|
156
15
|
end
|
157
|
-
else
|
158
|
-
raise yield('Syntax error')
|
159
16
|
end
|
17
|
+
sub_lookup('<unknown key>', Puppet::Pops::Lookup::Invocation.new(nil), segments, value)
|
160
18
|
end
|
161
19
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# This file is loaded by the autoloader, and it does not find the data function support unless required relative
|
2
2
|
#
|
3
3
|
require 'json'
|
4
|
-
require_relative 'hiera_interpolate'
|
5
4
|
|
6
5
|
module Puppet::DataProviders
|
7
6
|
class JsonDataProviderFactory < Puppet::Plugins::DataProviders::FileBasedDataProviderFactory
|
@@ -15,17 +14,11 @@ module Puppet::DataProviders
|
|
15
14
|
end
|
16
15
|
|
17
16
|
class JsonDataProvider < Puppet::Plugins::DataProviders::PathBasedDataProvider
|
18
|
-
include HieraInterpolate
|
19
|
-
|
20
17
|
def initialize_data(path, lookup_invocation)
|
21
18
|
JSON.parse(Puppet::FileSystem.read(path, :encoding => 'utf-8'))
|
22
19
|
rescue JSON::ParserError => ex
|
23
20
|
# Filename not included in message, so we add it here.
|
24
21
|
raise Puppet::DataBinding::LookupError, "Unable to parse (#{path}): #{ex.message}"
|
25
22
|
end
|
26
|
-
|
27
|
-
def post_process(value, lookup_invocation)
|
28
|
-
interpolate(value, lookup_invocation, true)
|
29
|
-
end
|
30
23
|
end
|
31
24
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# This file is loaded by the autoloader, and it does not find the data function support unless required relative
|
2
2
|
#
|
3
3
|
require 'yaml'
|
4
|
-
require_relative 'hiera_interpolate'
|
5
4
|
|
6
5
|
module Puppet::DataProviders
|
7
6
|
class YamlDataProviderFactory < Puppet::Plugins::DataProviders::FileBasedDataProviderFactory
|
@@ -15,18 +14,13 @@ module Puppet::DataProviders
|
|
15
14
|
end
|
16
15
|
|
17
16
|
class YamlDataProvider < Puppet::Plugins::DataProviders::PathBasedDataProvider
|
18
|
-
include HieraInterpolate
|
19
|
-
|
20
17
|
def initialize_data(path, lookup_invocation)
|
21
|
-
|
18
|
+
data = YAML.load_file(path)
|
19
|
+
HieraConfig.symkeys_to_string(data.nil? ? {} : data)
|
22
20
|
rescue YAML::SyntaxError => ex
|
23
21
|
# Psych errors includes the absolute path to the file, so no need to add that
|
24
22
|
# to the message
|
25
23
|
raise Puppet::DataBinding::LookupError, "Unable to parse #{ex.message}"
|
26
24
|
end
|
27
|
-
|
28
|
-
def post_process(value, lookup_invocation)
|
29
|
-
interpolate(value, lookup_invocation, true)
|
30
|
-
end
|
31
25
|
end
|
32
26
|
end
|
data/lib/puppet/defaults.rb
CHANGED
@@ -115,12 +115,36 @@ module Puppet
|
|
115
115
|
* `undefined_variables` --- disables warnings about non existing variables.",
|
116
116
|
:hook => proc do |value|
|
117
117
|
values = munge(value)
|
118
|
-
valid = %w[deprecations undefined_variables]
|
118
|
+
valid = %w[deprecations undefined_variables undefined_resources]
|
119
119
|
invalid = values - (values & valid)
|
120
120
|
if not invalid.empty?
|
121
121
|
raise ArgumentError, "Cannot disable unrecognized warning types #{invalid.inspect}. Valid values are #{valid.inspect}."
|
122
122
|
end
|
123
123
|
end
|
124
|
+
},
|
125
|
+
:strict => {
|
126
|
+
:default => :warning,
|
127
|
+
:type => :symbolic_enum,
|
128
|
+
:values => [:off, :warning, :error],
|
129
|
+
:desc => "The strictness level of puppet. Allowed values are:
|
130
|
+
|
131
|
+
* off - do not perform extra validation, do not report
|
132
|
+
* warning - perform extra validation, report as warning (default)
|
133
|
+
* error - perform extra validation, fail with error
|
134
|
+
|
135
|
+
The strictness level is for both language semantics and runtime
|
136
|
+
evaluation validation. In addition to controlling the behavior with
|
137
|
+
this master switch some individual warnings may also be controlled
|
138
|
+
by the disable_warnings setting.
|
139
|
+
|
140
|
+
No new validations will be added to a micro (x.y.z) release,
|
141
|
+
but may be added in minor releases (x.y.0). In major releases
|
142
|
+
it expected that most (if not all) strictness validation become
|
143
|
+
standard behavior.",
|
144
|
+
:hook => proc do |value|
|
145
|
+
munge(value)
|
146
|
+
value.to_sym
|
147
|
+
end
|
124
148
|
}
|
125
149
|
)
|
126
150
|
|
@@ -290,7 +314,13 @@ module Puppet
|
|
290
314
|
:always_cache_features => {
|
291
315
|
:type => :boolean,
|
292
316
|
:default => false,
|
317
|
+
:hook => proc { |value|
|
318
|
+
Puppet.deprecation_warning "Setting 'always_cache_features' is
|
319
|
+
deprecated and has been replaced by 'always_retry_plugins'."
|
320
|
+
},
|
293
321
|
:desc => <<-'EOT'
|
322
|
+
This setting is deprecated and has been replaced by always_retry_plugins.
|
323
|
+
|
294
324
|
Affects how we cache attempts to load Puppet 'features'. If false, then
|
295
325
|
calls to `Puppet.features.<feature>?` will always attempt to load the
|
296
326
|
feature (which can be an expensive operation) unless it has already been
|
@@ -306,6 +336,27 @@ module Puppet
|
|
306
336
|
improvement for features that are checked frequently.
|
307
337
|
EOT
|
308
338
|
},
|
339
|
+
:always_retry_plugins => {
|
340
|
+
:type => :boolean,
|
341
|
+
:default => true,
|
342
|
+
:desc => <<-'EOT'
|
343
|
+
Affects how we cache attempts to load Puppet resource types and features. If
|
344
|
+
true, then calls to `Puppet.type.<type>?` `Puppet.feature.<feature>?`
|
345
|
+
will always attempt to load the type or feature (which can be an
|
346
|
+
expensive operation) unless it has already been loaded successfully.
|
347
|
+
This makes it possible for a single agent run to, e.g., install a
|
348
|
+
package that provides the underlying capabilities for a type or feature,
|
349
|
+
and then later load that type or feature during the same run (even if
|
350
|
+
the type or feature had been tested earlier and had not been available).
|
351
|
+
|
352
|
+
If this setting is set to false, then types and features will only be
|
353
|
+
checked once, and if they are not available, the negative result is
|
354
|
+
cached and returned for all subsequent attempts to load the type or
|
355
|
+
feature. This behavior is almost always appropriate for the server,
|
356
|
+
and can result in a significant performance improvement for types and
|
357
|
+
features that are checked frequently.
|
358
|
+
EOT
|
359
|
+
},
|
309
360
|
:diff_args => {
|
310
361
|
:default => lambda { default_diffargs },
|
311
362
|
:desc => "Which arguments to pass to the diff command when printing differences between
|
@@ -370,7 +421,16 @@ module Puppet
|
|
370
421
|
:desc => "Where to retrive information about data.",
|
371
422
|
},
|
372
423
|
:hiera_config => {
|
373
|
-
:default =>
|
424
|
+
:default => lambda do
|
425
|
+
config = nil
|
426
|
+
codedir = Puppet.settings[:codedir]
|
427
|
+
if codedir.is_a?(String)
|
428
|
+
config = File.expand_path(File.join(codedir, 'hiera.yaml'))
|
429
|
+
config = nil unless Puppet::FileSystem.exist?(config)
|
430
|
+
end
|
431
|
+
config = File.expand_path(File.join(Puppet.settings[:confdir], 'hiera.yaml')) if config.nil?
|
432
|
+
config
|
433
|
+
end,
|
374
434
|
:desc => "The hiera configuration file. Puppet only reads this file on startup, so you must restart the puppet master every time you edit it.",
|
375
435
|
:type => :file,
|
376
436
|
},
|
@@ -546,6 +606,10 @@ module Puppet
|
|
546
606
|
:default => false,
|
547
607
|
:type => :boolean,
|
548
608
|
:desc => "Whether the application management feature is on or off. You must restart Puppet Server after changing this setting.",
|
609
|
+
:hook => proc do |value|
|
610
|
+
# Statically loaded resource types differ depending on setting
|
611
|
+
Puppet::Pops::Loaders.clear
|
612
|
+
end
|
549
613
|
}
|
550
614
|
)
|
551
615
|
|
@@ -955,7 +1019,8 @@ EOT
|
|
955
1019
|
},
|
956
1020
|
:req_bits => {
|
957
1021
|
:default => 4096,
|
958
|
-
:desc => "
|
1022
|
+
:desc => "This setting has no effect and will be removed in a future Puppet version.",
|
1023
|
+
:deprecated => :completely,
|
959
1024
|
},
|
960
1025
|
:keylength => {
|
961
1026
|
:default => 4096,
|
@@ -1441,10 +1506,8 @@ EOT
|
|
1441
1506
|
:ignorecache => {
|
1442
1507
|
:default => false,
|
1443
1508
|
:type => :boolean,
|
1444
|
-
:desc => "
|
1445
|
-
|
1446
|
-
fact be stale even if the timestamps are up to date - if the facts
|
1447
|
-
change or if the server changes.",
|
1509
|
+
:desc => "This setting has no effect and will be removed in a future Puppet version.",
|
1510
|
+
:deprecated => :completely,
|
1448
1511
|
},
|
1449
1512
|
:splaylimit => {
|
1450
1513
|
:default => "$runinterval",
|