puppet 3.0.2 → 3.1.0.rc1
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 +13 -11
- data/README.md +9 -7
- data/README_DEVELOPER.md +21 -30
- data/bin/extlookup2hiera +0 -0
- data/conf/auth.conf +42 -26
- data/conf/fileserver.conf +41 -0
- data/conf/tagmail.conf +16 -0
- data/examples/hiera/modules/data/manifests/common.pp +2 -1
- data/examples/hiera/modules/ntp/manifests/config.pp +4 -3
- data/examples/hiera/modules/ntp/manifests/data.pp +2 -1
- data/examples/hiera/modules/users/manifests/common.pp +2 -1
- data/examples/hiera/modules/users/manifests/dc1.pp +2 -1
- data/examples/hiera/modules/users/manifests/development.pp +2 -1
- data/examples/hiera/site.pp +1 -1
- data/ext/debian/fileserver.conf +39 -15
- data/ext/envpuppet +2 -0
- data/ext/gentoo/puppet/fileserver.conf +41 -12
- data/ext/ips/puppet-agent +1 -6
- data/ext/ips/puppetagent.xml +0 -4
- data/ext/osx/postflight.erb +109 -0
- data/ext/project_data.yaml +2 -2
- data/ext/redhat/fileserver.conf +41 -12
- data/ext/redhat/puppet.spec.erb +8 -13
- data/install.rb +2 -5
- data/lib/puppet.rb +30 -13
- data/lib/puppet/application.rb +34 -16
- data/lib/puppet/application/agent.rb +4 -4
- data/lib/puppet/application/master.rb +25 -5
- data/lib/puppet/defaults.rb +11 -7
- data/lib/puppet/dsl.rb +7 -3
- data/lib/puppet/dsl/actions.rb +283 -0
- data/lib/puppet/dsl/blank_slate.rb +55 -0
- data/lib/puppet/dsl/context.rb +393 -0
- data/lib/puppet/dsl/parser.rb +57 -0
- data/lib/puppet/dsl/resource_decorator.rb +56 -0
- data/lib/puppet/dsl/resource_reference.rb +95 -0
- data/lib/puppet/dsl/type_reference.rb +102 -0
- data/lib/puppet/error.rb +1 -1
- data/lib/puppet/face/help.rb +2 -4
- data/lib/puppet/face/man.rb +8 -2
- data/lib/puppet/feature/pson.rb +1 -3
- data/lib/puppet/indirector/catalog/active_record.rb +3 -0
- data/lib/puppet/indirector/catalog/compiler.rb +1 -2
- data/lib/puppet/indirector/catalog/queue.rb +4 -0
- data/lib/puppet/indirector/catalog/static_compiler.rb +30 -0
- data/lib/puppet/indirector/catalog/store_configs.rb +3 -0
- data/lib/puppet/indirector/certificate_request/rest.rb +1 -0
- data/lib/puppet/indirector/certificate_revocation_list/rest.rb +1 -0
- data/lib/puppet/indirector/certificate_status/file.rb +4 -0
- data/lib/puppet/indirector/certificate_status/rest.rb +1 -0
- data/lib/puppet/indirector/facts/active_record.rb +3 -0
- data/lib/puppet/indirector/facts/couch.rb +3 -0
- data/lib/puppet/indirector/facts/inventory_active_record.rb +4 -0
- data/lib/puppet/indirector/facts/store_configs.rb +3 -0
- data/lib/puppet/indirector/file_metadata/rest.rb +2 -0
- data/lib/puppet/indirector/instrumentation_data/local.rb +3 -0
- data/lib/puppet/indirector/instrumentation_data/rest.rb +3 -0
- data/lib/puppet/indirector/instrumentation_listener/local.rb +3 -0
- data/lib/puppet/indirector/instrumentation_listener/rest.rb +3 -0
- data/lib/puppet/indirector/instrumentation_probe/local.rb +3 -0
- data/lib/puppet/indirector/instrumentation_probe/rest.rb +3 -0
- data/lib/puppet/indirector/node/active_record.rb +3 -0
- data/lib/puppet/indirector/node/rest.rb +2 -2
- data/lib/puppet/indirector/node/store_configs.rb +3 -0
- data/lib/puppet/indirector/node/write_only_yaml.rb +32 -0
- data/lib/puppet/indirector/queue.rb +0 -1
- data/lib/puppet/indirector/request.rb +1 -2
- data/lib/puppet/indirector/resource/active_record.rb +4 -0
- data/lib/puppet/indirector/resource/ral.rb +3 -0
- data/lib/puppet/indirector/resource/rest.rb +3 -0
- data/lib/puppet/indirector/resource/store_configs.rb +3 -0
- data/lib/puppet/indirector/run/local.rb +3 -0
- data/lib/puppet/indirector/ssl_file.rb +16 -14
- data/lib/puppet/indirector/status/local.rb +3 -0
- data/lib/puppet/indirector/status/rest.rb +4 -0
- data/lib/puppet/interface.rb +78 -3
- data/lib/puppet/interface/action.rb +39 -3
- data/lib/puppet/interface/action_builder.rb +74 -1
- data/lib/puppet/interface/action_manager.rb +33 -3
- data/lib/puppet/interface/documentation.rb +116 -5
- data/lib/puppet/interface/face_collection.rb +6 -7
- data/lib/puppet/interface/option.rb +10 -1
- data/lib/puppet/interface/option_builder.rb +29 -1
- data/lib/puppet/interface/option_manager.rb +21 -6
- data/lib/puppet/metatype/manager.rb +47 -9
- data/lib/puppet/module_tool.rb +0 -1
- data/lib/puppet/network/formats.rb +0 -2
- data/lib/puppet/node.rb +2 -3
- data/lib/puppet/node/environment.rb +14 -1
- data/lib/puppet/parameter.rb +309 -44
- data/lib/puppet/parameter/package_options.rb +5 -0
- data/lib/puppet/parameter/path.rb +26 -3
- data/lib/puppet/parameter/value.rb +30 -6
- data/lib/puppet/parameter/value_collection.rb +82 -20
- data/lib/puppet/parser.rb +3 -0
- data/lib/puppet/parser/ast/definition.rb +2 -5
- data/lib/puppet/parser/ast/hostclass.rb +2 -3
- data/lib/puppet/parser/ast/node.rb +2 -5
- data/lib/puppet/parser/ast/resourceparam.rb +1 -1
- data/lib/puppet/parser/compiler.rb +10 -0
- data/lib/puppet/parser/functions.rb +111 -7
- data/lib/puppet/parser/functions/create_resources.rb +23 -2
- data/lib/puppet/parser/functions/defined.rb +1 -1
- data/lib/puppet/parser/functions/extlookup.rb +2 -1
- data/lib/puppet/parser/functions/fail.rb +1 -1
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/fqdn_rand.rb +1 -1
- data/lib/puppet/parser/functions/generate.rb +1 -1
- data/lib/puppet/parser/functions/hiera.rb +1 -1
- 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 +1 -1
- data/lib/puppet/parser/functions/inline_template.rb +1 -1
- data/lib/puppet/parser/functions/md5.rb +1 -1
- data/lib/puppet/parser/functions/realize.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +54 -57
- data/lib/puppet/parser/functions/require.rb +1 -0
- data/lib/puppet/parser/functions/search.rb +1 -1
- data/lib/puppet/parser/functions/sha1.rb +1 -1
- data/lib/puppet/parser/functions/shellquote.rb +1 -1
- data/lib/puppet/parser/functions/split.rb +1 -2
- data/lib/puppet/parser/functions/sprintf.rb +7 -10
- data/lib/puppet/parser/functions/tag.rb +1 -1
- data/lib/puppet/parser/functions/tagged.rb +1 -1
- data/lib/puppet/parser/functions/template.rb +1 -1
- data/lib/puppet/parser/functions/versioncmp.rb +1 -5
- data/lib/puppet/parser/parser_support.rb +11 -27
- data/lib/puppet/parser/scope.rb +48 -4
- data/lib/puppet/parser/type_loader.rb +31 -7
- data/lib/puppet/property.rb +304 -70
- data/lib/puppet/property/ensure.rb +14 -1
- data/lib/puppet/property/keyvalue.rb +17 -8
- data/lib/puppet/property/list.rb +3 -0
- data/lib/puppet/property/ordered_list.rb +7 -0
- data/lib/puppet/provider.rb +275 -53
- data/lib/puppet/provider/augeas/augeas.rb +17 -3
- data/lib/puppet/provider/confiner.rb +30 -1
- data/lib/puppet/provider/group/pw.rb +2 -2
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkgin.rb +2 -0
- data/lib/puppet/provider/service/bsd.rb +1 -1
- data/lib/puppet/provider/service/freebsd.rb +10 -6
- data/lib/puppet/provider/service/init.rb +1 -1
- data/lib/puppet/provider/service/service.rb +1 -1
- data/lib/puppet/provider/user/pw.rb +2 -2
- data/lib/puppet/provider/user/useradd.rb +2 -3
- data/lib/puppet/reference/configuration.rb +6 -0
- data/lib/puppet/reports.rb +44 -4
- data/lib/puppet/reports/tagmail.rb +1 -1
- data/lib/puppet/resource.rb +38 -25
- data/lib/puppet/resource/type.rb +14 -6
- data/lib/puppet/settings.rb +66 -142
- data/lib/puppet/settings/config_file.rb +99 -0
- data/lib/puppet/settings/file_setting.rb +92 -24
- data/lib/puppet/settings/value_translator.rb +15 -0
- data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
- data/lib/puppet/test/test_helper.rb +8 -3
- data/lib/puppet/transaction.rb +1 -2
- data/lib/puppet/transaction/report.rb +122 -13
- data/lib/puppet/type.rb +763 -150
- data/lib/puppet/type/augeas.rb +4 -0
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/group.rb +1 -1
- data/lib/puppet/type/file/mode.rb +2 -0
- data/lib/puppet/type/file/selcontext.rb +1 -0
- data/lib/puppet/type/group.rb +12 -0
- data/lib/puppet/type/mount.rb +2 -2
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/router.rb +1 -1
- data/lib/puppet/type/service.rb +1 -0
- data/lib/puppet/type/ssh_authorized_key.rb +3 -1
- data/lib/puppet/type/user.rb +8 -1
- data/lib/puppet/util.rb +8 -0
- data/lib/puppet/util/autoload.rb +7 -10
- data/lib/puppet/util/classgen.rb +58 -33
- data/lib/puppet/util/command_line.rb +120 -77
- data/lib/puppet/util/constant_inflector.rb +2 -0
- data/lib/puppet/util/execution.rb +63 -33
- data/lib/puppet/util/filetype.rb +1 -1
- data/lib/puppet/util/manifest_filetype_helper.rb +22 -0
- data/lib/puppet/util/methodhelper.rb +19 -0
- data/lib/puppet/util/monkey_patches.rb +46 -0
- data/lib/puppet/util/plugins.rb +2 -2
- data/lib/puppet/util/provider_features.rb +24 -8
- data/lib/puppet/util/rubygems.rb +8 -1
- data/lib/puppet/util/zaml.rb +1 -1
- data/lib/puppet/version.rb +74 -3
- data/spec/integration/application/apply_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +1 -0
- data/spec/integration/dsl/classes_spec.rb +191 -0
- data/spec/integration/dsl/defaults_spec.rb +38 -0
- data/spec/integration/dsl/definitions_spec.rb +73 -0
- data/spec/integration/dsl/functions_spec.rb +95 -0
- data/spec/integration/dsl/nodes_spec.rb +96 -0
- data/spec/integration/dsl/params_spec.rb +146 -0
- data/spec/integration/dsl/relationships_spec.rb +46 -0
- data/spec/integration/dsl/resources_spec.rb +202 -0
- data/spec/integration/dsl/type_loading_spec.rb +64 -0
- data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
- data/spec/integration/network/formats_spec.rb +32 -45
- data/spec/integration/parser/collector_spec.rb +105 -25
- data/spec/integration/parser/scope_spec.rb +64 -1
- data/spec/integration/resource/catalog_spec.rb +2 -4
- data/spec/integration/type/package_spec.rb +1 -1
- data/spec/lib/matchers/catalog.rb +50 -0
- data/spec/lib/puppet_spec/compiler.rb +11 -0
- data/spec/lib/puppet_spec/dsl.rb +29 -0
- data/spec/spec_helper.rb +17 -3
- data/spec/unit/application/agent_spec.rb +0 -1
- data/spec/unit/application/apply_spec.rb +1 -1
- data/spec/unit/application/face_base_spec.rb +11 -4
- data/spec/unit/application/indirection_base_spec.rb +4 -8
- data/spec/unit/application/kick_spec.rb +5 -2
- data/spec/unit/application/master_spec.rb +0 -6
- data/spec/unit/application_spec.rb +38 -14
- data/spec/unit/dsl/actions_spec.rb +402 -0
- data/spec/unit/dsl/blank_slate_spec.rb +27 -0
- data/spec/unit/dsl/context_spec.rb +678 -0
- data/spec/unit/dsl/parser_spec.rb +56 -0
- data/spec/unit/dsl/resource_decorator_spec.rb +94 -0
- data/spec/unit/dsl/resource_reference_spec.rb +150 -0
- data/spec/unit/dsl/type_reference_spec.rb +164 -0
- data/spec/unit/face/help_spec.rb +5 -7
- data/spec/unit/indirector/certificate_request/rest_spec.rb +4 -0
- data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +4 -0
- data/spec/unit/indirector/certificate_status/rest_spec.rb +4 -0
- data/spec/unit/indirector/file_metadata/rest_spec.rb +5 -0
- data/spec/unit/indirector/hiera_spec.rb +3 -1
- data/spec/unit/indirector/queue_spec.rb +1 -7
- data/spec/unit/indirector/ssl_file_spec.rb +66 -39
- data/spec/unit/module_spec.rb +1 -1
- data/spec/unit/network/authstore_spec.rb +22 -1
- data/spec/unit/network/formats_spec.rb +1 -1
- data/spec/unit/node/environment_spec.rb +13 -0
- data/spec/unit/parser/collector_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +26 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +12 -1
- data/spec/unit/parser/functions/extlookup_spec.rb +4 -4
- 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/regsubst_spec.rb +4 -4
- data/spec/unit/parser/functions/split_spec.rb +4 -4
- data/spec/unit/parser/functions/sprintf_spec.rb +2 -2
- data/spec/unit/parser/functions/versioncmp_spec.rb +4 -4
- data/spec/unit/parser/functions_spec.rb +51 -1
- data/spec/unit/parser/parser_spec.rb +0 -14
- data/spec/unit/parser/type_loader_spec.rb +15 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +31 -0
- data/spec/unit/provider/package/apt_spec.rb +0 -2
- data/spec/unit/provider/package/pip_spec.rb +12 -2
- data/spec/unit/provider/service/freebsd_spec.rb +8 -0
- data/spec/unit/provider/service/gentoo_spec.rb +20 -20
- data/spec/unit/provider/service/openrc_spec.rb +20 -20
- data/spec/unit/provider/service/src_spec.rb +4 -4
- data/spec/unit/provider/service/systemd_spec.rb +0 -8
- data/spec/unit/provider/service/windows_spec.rb +1 -1
- data/spec/unit/provider/user/useradd_spec.rb +2 -9
- data/spec/unit/relationship_spec.rb +2 -2
- data/spec/unit/resource/catalog_spec.rb +2 -2
- data/spec/unit/resource/type_spec.rb +49 -25
- data/spec/unit/resource_spec.rb +34 -2
- data/spec/unit/settings/config_file_spec.rb +100 -0
- data/spec/unit/settings/file_setting_spec.rb +87 -84
- data/spec/unit/settings/value_translator_spec.rb +77 -0
- data/spec/unit/settings_spec.rb +96 -29
- data/spec/unit/type/file/ensure_spec.rb +75 -36
- data/spec/unit/type/file_spec.rb +0 -68
- data/spec/unit/type/group_spec.rb +10 -0
- data/spec/unit/util/autoload_spec.rb +6 -0
- data/spec/unit/util/command_line_spec.rb +54 -62
- data/spec/unit/util/manifest_filetype_helper_spec.rb +29 -0
- data/spec/unit/util/metric_spec.rb +0 -9
- data/spec/unit/util/posix_spec.rb +0 -4
- data/spec/unit/util/rdoc_spec.rb +0 -12
- data/spec/unit/util/zaml_spec.rb +188 -130
- data/spec/unit/version_spec.rb +42 -0
- metadata +123 -90
- data/README_HIERA.md +0 -148
- data/conf/epm.list +0 -8
- data/conf/namespaceauth.conf +0 -20
- data/conf/puppet-queue.conf +0 -10
- data/examples/allatonce +0 -13
- data/examples/assignments +0 -11
- data/examples/components +0 -73
- data/examples/etc/init.d/sleeper +0 -70
- data/examples/etc/otherfile +0 -0
- data/examples/etc/puppet/fileserver.conf +0 -13
- data/examples/etc/puppet/namespaceauth.conf +0 -20
- data/examples/etc/puppet/puppet.conf +0 -10
- data/examples/etc/puppet/tagmail.conf +0 -1
- data/examples/execs +0 -16
- data/examples/file.bl +0 -11
- data/examples/filedefaults +0 -10
- data/examples/fileparsing +0 -116
- data/examples/filerecursion +0 -15
- data/examples/functions +0 -3
- data/examples/groups +0 -7
- data/examples/head +0 -30
- data/examples/importing +0 -8
- data/examples/mac_dscl.pp +0 -28
- data/examples/mac_dscl_revert.pp +0 -26
- data/examples/mac_pkgdmg.pp +0 -7
- data/examples/modules/sample_module.pp +0 -10
- data/examples/modules/sample_module/lib/puppet/parser/functions/hostname_to_dn.rb +0 -36
- data/examples/modules/sample_module/manifests/init.pp +0 -12
- data/examples/modules/sample_module/templates/sample.erb +0 -5
- data/examples/nodes +0 -20
- data/examples/one +0 -8
- data/examples/relationships +0 -34
- data/examples/selectors +0 -28
- data/examples/simpletests +0 -11
- data/examples/svncommit +0 -13
- data/lib/puppet/dsl/resource_api.rb +0 -120
- data/lib/puppet/dsl/resource_type_api.rb +0 -34
- data/spec/integration/parser/ruby_manifest_spec.rb +0 -127
- data/spec/unit/dsl/resource_api_spec.rb +0 -180
- data/spec/unit/dsl/resource_type_api_spec.rb +0 -53
data/lib/puppet/settings.rb
CHANGED
@@ -11,6 +11,8 @@ require 'puppet/settings/path_setting'
|
|
11
11
|
require 'puppet/settings/boolean_setting'
|
12
12
|
require 'puppet/settings/terminus_setting'
|
13
13
|
require 'puppet/settings/duration_setting'
|
14
|
+
require 'puppet/settings/config_file'
|
15
|
+
require 'puppet/settings/value_translator'
|
14
16
|
|
15
17
|
# The class for handling configuration files.
|
16
18
|
class Puppet::Settings
|
@@ -61,6 +63,35 @@ class Puppet::Settings
|
|
61
63
|
"puppet.conf"
|
62
64
|
end
|
63
65
|
|
66
|
+
# Create a new collection of config settings.
|
67
|
+
def initialize
|
68
|
+
@config = {}
|
69
|
+
@shortnames = {}
|
70
|
+
|
71
|
+
@created = []
|
72
|
+
@searchpath = nil
|
73
|
+
|
74
|
+
# Mutex-like thing to protect @values
|
75
|
+
@sync = Sync.new
|
76
|
+
|
77
|
+
# Keep track of set values.
|
78
|
+
@values = Hash.new { |hash, key| hash[key] = {} }
|
79
|
+
|
80
|
+
# Hold parsed metadata until run_mode is known
|
81
|
+
@metas = {}
|
82
|
+
|
83
|
+
# And keep a per-environment cache
|
84
|
+
@cache = Hash.new { |hash, key| hash[key] = {} }
|
85
|
+
|
86
|
+
# The list of sections we've used.
|
87
|
+
@used = []
|
88
|
+
|
89
|
+
@hooks_to_call_on_application_initialization = []
|
90
|
+
|
91
|
+
@translate = Puppet::Settings::ValueTranslator.new
|
92
|
+
@config_file_parser = Puppet::Settings::ConfigFile.new(@translate)
|
93
|
+
end
|
94
|
+
|
64
95
|
# Retrieve a config value
|
65
96
|
def [](param)
|
66
97
|
value(param)
|
@@ -208,7 +239,6 @@ class Puppet::Settings
|
|
208
239
|
end
|
209
240
|
|
210
241
|
def initialize_app_defaults(app_defaults)
|
211
|
-
raise Puppet::DevError, "Attempting to initialize application default settings more than once!" if app_defaults_initialized?
|
212
242
|
REQUIRED_APP_SETTINGS.each do |key|
|
213
243
|
raise SettingsError, "missing required app default setting '#{key}'" unless app_defaults.has_key?(key)
|
214
244
|
end
|
@@ -220,6 +250,7 @@ class Puppet::Settings
|
|
220
250
|
set_value(key, value, :application_defaults)
|
221
251
|
end
|
222
252
|
end
|
253
|
+
apply_metadata
|
223
254
|
call_hooks_deferred_to_application_initialization
|
224
255
|
|
225
256
|
@app_defaults_initialized = true
|
@@ -301,7 +332,7 @@ class Puppet::Settings
|
|
301
332
|
value = "true"
|
302
333
|
end
|
303
334
|
|
304
|
-
value &&=
|
335
|
+
value &&= @translate[value]
|
305
336
|
str = opt.sub(/^--/,'')
|
306
337
|
|
307
338
|
bool = true
|
@@ -332,29 +363,6 @@ class Puppet::Settings
|
|
332
363
|
@shortnames.include?(short)
|
333
364
|
end
|
334
365
|
|
335
|
-
# Create a new collection of config settings.
|
336
|
-
def initialize
|
337
|
-
@config = {}
|
338
|
-
@shortnames = {}
|
339
|
-
|
340
|
-
@created = []
|
341
|
-
@searchpath = nil
|
342
|
-
|
343
|
-
# Mutex-like thing to protect @values
|
344
|
-
@sync = Sync.new
|
345
|
-
|
346
|
-
# Keep track of set values.
|
347
|
-
@values = Hash.new { |hash, key| hash[key] = {} }
|
348
|
-
|
349
|
-
# And keep a per-environment cache
|
350
|
-
@cache = Hash.new { |hash, key| hash[key] = {} }
|
351
|
-
|
352
|
-
# The list of sections we've used.
|
353
|
-
@used = []
|
354
|
-
|
355
|
-
@hooks_to_call_on_application_initialization = []
|
356
|
-
end
|
357
|
-
|
358
366
|
# Prints the contents of a config file with the available config settings, or it
|
359
367
|
# prints a single value of a config setting.
|
360
368
|
def print_config_options
|
@@ -465,19 +473,8 @@ class Puppet::Settings
|
|
465
473
|
|
466
474
|
# Parse the configuration file. Just provides thread safety.
|
467
475
|
def parse_config_files
|
468
|
-
# we are able to support multiple config files; the "main" config file will
|
469
|
-
# be the one located in /etc/puppet (or overridden $confdir)... but we can
|
470
|
-
# also look for a config file in the user's home directory. We only load
|
471
|
-
# one configuration file in order to present a simple and consistent
|
472
|
-
# configuration model to the end user. It should also be noted we decided
|
473
|
-
# to merge in the user puppet.conf with the system puppet.conf for a time
|
474
|
-
# (e.g. load two configuration files) as a small part of #7749 but then
|
475
|
-
# decided to reverse this decision in #15337 to return to a disjoint
|
476
|
-
# configuration file model.
|
477
|
-
config_files = [which_configuration_file]
|
478
|
-
|
479
476
|
@sync.synchronize do
|
480
|
-
unsafe_parse(
|
477
|
+
unsafe_parse(which_configuration_file)
|
481
478
|
end
|
482
479
|
|
483
480
|
call_hooks_deferred_to_application_initialization :ignore_interpolation_dependency_errors => true
|
@@ -518,13 +515,10 @@ class Puppet::Settings
|
|
518
515
|
private :config_file_name
|
519
516
|
|
520
517
|
# Unsafely parse the file -- this isn't thread-safe and causes plenty of problems if used directly.
|
521
|
-
def unsafe_parse(
|
522
|
-
raise Puppet::DevError unless files.length > 0
|
523
|
-
|
518
|
+
def unsafe_parse(file)
|
524
519
|
# build up a single data structure that contains the values from all of the parsed files.
|
525
520
|
data = {}
|
526
|
-
|
527
|
-
next unless FileTest.exist?(file)
|
521
|
+
if FileTest.exist?(file)
|
528
522
|
begin
|
529
523
|
file_data = parse_file(file)
|
530
524
|
|
@@ -537,7 +531,6 @@ class Puppet::Settings
|
|
537
531
|
data[key] = file_data[key]
|
538
532
|
end
|
539
533
|
end
|
540
|
-
|
541
534
|
rescue => detail
|
542
535
|
Puppet.log_exception(detail, "Could not parse #{file}: #{detail}")
|
543
536
|
return
|
@@ -552,9 +545,8 @@ class Puppet::Settings
|
|
552
545
|
unsafe_clear(false, false)
|
553
546
|
|
554
547
|
# And now we can repopulate with the values from our last parsing of the config files.
|
555
|
-
metas = {}
|
556
548
|
data.each do |area, values|
|
557
|
-
metas[area] = values.delete(:_meta)
|
549
|
+
@metas[area] = values.delete(:_meta)
|
558
550
|
values.each do |key,value|
|
559
551
|
set_value(key, value, area, :dont_trigger_handles => true, :ignore_bad_settings => true )
|
560
552
|
end
|
@@ -582,19 +574,24 @@ class Puppet::Settings
|
|
582
574
|
end
|
583
575
|
end
|
584
576
|
|
577
|
+
# Take a best guess at metadata based on uninitialized run_mode
|
578
|
+
apply_metadata
|
579
|
+
end
|
580
|
+
private :unsafe_parse
|
581
|
+
|
582
|
+
def apply_metadata
|
585
583
|
# We have to do it in the reverse of the search path,
|
586
584
|
# because multiple sections could set the same value
|
587
585
|
# and I'm too lazy to only set the metadata once.
|
588
586
|
searchpath.reverse.each do |source|
|
589
587
|
source = preferred_run_mode if source == :run_mode
|
590
588
|
source = @name if (@name && source == :name)
|
591
|
-
if meta = metas[source]
|
589
|
+
if meta = @metas[source]
|
592
590
|
set_metadata(meta)
|
593
591
|
end
|
594
592
|
end
|
595
593
|
end
|
596
|
-
private :
|
597
|
-
|
594
|
+
private :apply_metadata
|
598
595
|
|
599
596
|
# Create a new setting. The value is passed in because it's used to determine
|
600
597
|
# what kind of setting we're creating, but the value itself might be either
|
@@ -710,11 +707,25 @@ class Puppet::Settings
|
|
710
707
|
def service_user_available?
|
711
708
|
return @service_user_available if defined?(@service_user_available)
|
712
709
|
|
713
|
-
|
710
|
+
if self[:user]
|
711
|
+
user = Puppet::Type.type(:user).new :name => self[:user], :audit => :ensure
|
712
|
+
|
713
|
+
@service_user_available = user.exists?
|
714
|
+
else
|
715
|
+
@service_user_available = false
|
716
|
+
end
|
717
|
+
end
|
714
718
|
|
715
|
-
|
719
|
+
def service_group_available?
|
720
|
+
return @service_group_available if defined?(@service_group_available)
|
716
721
|
|
717
|
-
|
722
|
+
if self[:group]
|
723
|
+
group = Puppet::Type.type(:group).new :name => self[:group], :audit => :ensure
|
724
|
+
|
725
|
+
@service_group_available = group.exists?
|
726
|
+
else
|
727
|
+
@service_group_available = false
|
728
|
+
end
|
718
729
|
end
|
719
730
|
|
720
731
|
# Allow later inspection to determine if the setting was set on the
|
@@ -1098,98 +1109,9 @@ Generated on #{Time.now}.
|
|
1098
1109
|
@config.values.find_all { |setting| setting.has_hook? }
|
1099
1110
|
end
|
1100
1111
|
|
1101
|
-
# Extract extra setting information for files.
|
1102
|
-
def extract_fileinfo(string)
|
1103
|
-
result = {}
|
1104
|
-
value = string.sub(/\{\s*([^}]+)\s*\}/) do
|
1105
|
-
params = $1
|
1106
|
-
params.split(/\s*,\s*/).each do |str|
|
1107
|
-
if str =~ /^\s*(\w+)\s*=\s*([\w\d]+)\s*$/
|
1108
|
-
param, value = $1.intern, $2
|
1109
|
-
result[param] = value
|
1110
|
-
raise ArgumentError, "Invalid file option '#{param}'" unless [:owner, :mode, :group].include?(param)
|
1111
|
-
|
1112
|
-
if param == :mode and value !~ /^\d+$/
|
1113
|
-
raise ArgumentError, "File modes must be numbers"
|
1114
|
-
end
|
1115
|
-
else
|
1116
|
-
raise ArgumentError, "Could not parse '#{string}'"
|
1117
|
-
end
|
1118
|
-
end
|
1119
|
-
''
|
1120
|
-
end
|
1121
|
-
result[:value] = value.sub(/\s*$/, '')
|
1122
|
-
result
|
1123
|
-
end
|
1124
|
-
|
1125
|
-
# Convert arguments into booleans, integers, or whatever.
|
1126
|
-
def munge_value(value)
|
1127
|
-
# Handle different data types correctly
|
1128
|
-
return case value
|
1129
|
-
when /^false$/i; false
|
1130
|
-
when /^true$/i; true
|
1131
|
-
when /^\d+$/i; Integer(value)
|
1132
|
-
when true; true
|
1133
|
-
when false; false
|
1134
|
-
else
|
1135
|
-
value.gsub(/^["']|["']$/,'').sub(/\s+$/, '')
|
1136
|
-
end
|
1137
|
-
end
|
1138
|
-
|
1139
1112
|
# This method just turns a file in to a hash of hashes.
|
1140
1113
|
def parse_file(file)
|
1141
|
-
|
1142
|
-
|
1143
|
-
result = Hash.new { |names, name|
|
1144
|
-
names[name] = {}
|
1145
|
-
}
|
1146
|
-
|
1147
|
-
count = 0
|
1148
|
-
|
1149
|
-
# Default to 'main' for the section.
|
1150
|
-
section = :main
|
1151
|
-
result[section][:_meta] = {}
|
1152
|
-
text.split(/\n/).each do |line|
|
1153
|
-
count += 1
|
1154
|
-
case line
|
1155
|
-
when /^\s*\[(\w+)\]\s*$/
|
1156
|
-
section = $1.intern # Section names
|
1157
|
-
#disallow application_defaults in config file
|
1158
|
-
if section == :application_defaults
|
1159
|
-
raise Puppet::Error, "Illegal section 'application_defaults' in config file #{file} at line #{line}"
|
1160
|
-
end
|
1161
|
-
# Add a meta section
|
1162
|
-
result[section][:_meta] ||= {}
|
1163
|
-
when /^\s*#/; next # Skip comments
|
1164
|
-
when /^\s*$/; next # Skip blanks
|
1165
|
-
when /^\s*(\w+)\s*=\s*(.*?)\s*$/ # settings
|
1166
|
-
var = $1.intern
|
1167
|
-
|
1168
|
-
# We don't want to munge modes, because they're specified in octal, so we'll
|
1169
|
-
# just leave them as a String, since Puppet handles that case correctly.
|
1170
|
-
if var == :mode
|
1171
|
-
value = $2
|
1172
|
-
else
|
1173
|
-
value = munge_value($2)
|
1174
|
-
end
|
1175
|
-
|
1176
|
-
# Check to see if this is a file argument and it has extra options
|
1177
|
-
begin
|
1178
|
-
if value.is_a?(String) and options = extract_fileinfo(value)
|
1179
|
-
value = options[:value]
|
1180
|
-
options.delete(:value)
|
1181
|
-
result[section][:_meta][var] = options
|
1182
|
-
end
|
1183
|
-
result[section][var] = value
|
1184
|
-
rescue Puppet::Error => detail
|
1185
|
-
raise ParseError.new(detail.message, file, line, detail)
|
1186
|
-
end
|
1187
|
-
else
|
1188
|
-
raise ParseError.new("Could not match line #{line}", file, line)
|
1189
|
-
end
|
1190
|
-
end
|
1191
|
-
|
1192
|
-
result
|
1114
|
+
@config_file_parser.parse_file(file, read_file(file))
|
1193
1115
|
end
|
1194
1116
|
|
1195
1117
|
# Read the file in.
|
@@ -1207,7 +1129,9 @@ Generated on #{Time.now}.
|
|
1207
1129
|
def set_metadata(meta)
|
1208
1130
|
meta.each do |var, values|
|
1209
1131
|
values.each do |param, value|
|
1210
|
-
@
|
1132
|
+
@sync.synchronize do # yay, thread-safe
|
1133
|
+
@config[var].send(param.to_s + "=", value)
|
1134
|
+
end
|
1211
1135
|
end
|
1212
1136
|
end
|
1213
1137
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'puppet/settings/errors'
|
2
|
+
|
3
|
+
##
|
4
|
+
# @api private
|
5
|
+
#
|
6
|
+
# Parses puppet configuration files
|
7
|
+
#
|
8
|
+
class Puppet::Settings::ConfigFile
|
9
|
+
|
10
|
+
##
|
11
|
+
# @param value_converter [Proc] a function that will convert strings into ruby types
|
12
|
+
#
|
13
|
+
def initialize(value_converter)
|
14
|
+
@value_converter = value_converter
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse_file(file, text)
|
18
|
+
result = {}
|
19
|
+
count = 0
|
20
|
+
|
21
|
+
# Default to 'main' for the section.
|
22
|
+
section_name = :main
|
23
|
+
result[section_name] = empty_section
|
24
|
+
text.split(/\n/).each do |line|
|
25
|
+
count += 1
|
26
|
+
case line
|
27
|
+
when /^\s*\[(\w+)\]\s*$/
|
28
|
+
section_name = $1.intern
|
29
|
+
fail_when_illegal_section_name(section_name, file, line)
|
30
|
+
if result[section_name].nil?
|
31
|
+
result[section_name] = empty_section
|
32
|
+
end
|
33
|
+
when /^\s*#/; next # Skip comments
|
34
|
+
when /^\s*$/; next # Skip blanks
|
35
|
+
when /^\s*(\w+)\s*=\s*(.*?)\s*$/ # settings
|
36
|
+
var = $1.intern
|
37
|
+
|
38
|
+
# We don't want to munge modes, because they're specified in octal, so we'll
|
39
|
+
# just leave them as a String, since Puppet handles that case correctly.
|
40
|
+
if var == :mode
|
41
|
+
value = $2
|
42
|
+
else
|
43
|
+
value = @value_converter[$2]
|
44
|
+
end
|
45
|
+
|
46
|
+
# Check to see if this is a file argument and it has extra options
|
47
|
+
begin
|
48
|
+
if value.is_a?(String) and options = extract_fileinfo(value)
|
49
|
+
value = options[:value]
|
50
|
+
options.delete(:value)
|
51
|
+
result[section_name][:_meta][var] = options
|
52
|
+
end
|
53
|
+
result[section_name][var] = value
|
54
|
+
rescue Puppet::Error => detail
|
55
|
+
raise Puppet::Settings::ParseError.new(detail.message, file, line, detail)
|
56
|
+
end
|
57
|
+
else
|
58
|
+
raise Puppet::Settings::ParseError.new("Could not match line #{line}", file, line)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
result
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def empty_section
|
68
|
+
{ :_meta => {} }
|
69
|
+
end
|
70
|
+
|
71
|
+
def fail_when_illegal_section_name(section, file, line)
|
72
|
+
if section == :application_defaults or section == :global_defaults
|
73
|
+
raise Puppet::Error, "Illegal section '#{section}' in config file #{file} at line #{line}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def extract_fileinfo(string)
|
78
|
+
result = {}
|
79
|
+
value = string.sub(/\{\s*([^}]+)\s*\}/) do
|
80
|
+
params = $1
|
81
|
+
params.split(/\s*,\s*/).each do |str|
|
82
|
+
if str =~ /^\s*(\w+)\s*=\s*([\w\d]+)\s*$/
|
83
|
+
param, value = $1.intern, $2
|
84
|
+
result[param] = value
|
85
|
+
raise ArgumentError, "Invalid file option '#{param}'" unless [:owner, :mode, :group].include?(param)
|
86
|
+
|
87
|
+
if param == :mode and value !~ /^\d+$/
|
88
|
+
raise ArgumentError, "File modes must be numbers"
|
89
|
+
end
|
90
|
+
else
|
91
|
+
raise ArgumentError, "Could not parse '#{string}'"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
''
|
95
|
+
end
|
96
|
+
result[:value] = value.sub(/\s*$/, '')
|
97
|
+
result
|
98
|
+
end
|
99
|
+
end
|
@@ -2,47 +2,110 @@ require 'puppet/settings/string_setting'
|
|
2
2
|
|
3
3
|
# A file.
|
4
4
|
class Puppet::Settings::FileSetting < Puppet::Settings::StringSetting
|
5
|
-
AllowedOwners = %w{root service}
|
6
|
-
AllowedGroups = %w{root service}
|
7
|
-
|
8
5
|
class SettingError < StandardError; end
|
9
6
|
|
7
|
+
# An unspecified user or group
|
8
|
+
#
|
9
|
+
# @api private
|
10
|
+
class Unspecified
|
11
|
+
def value
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# A "root" user or group
|
17
|
+
#
|
18
|
+
# @api private
|
19
|
+
class Root
|
20
|
+
def value
|
21
|
+
"root"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# A "service" user or group that picks up values from settings when the
|
26
|
+
# referenced user or group is safe to use (it exists or will be created), and
|
27
|
+
# uses the given fallback value when not safe.
|
28
|
+
#
|
29
|
+
# @api private
|
30
|
+
class Service
|
31
|
+
# @param name [Symbol] the name of the setting to use as the service value
|
32
|
+
# @param fallback [String, nil] the value to use when the service value cannot be used
|
33
|
+
# @param settings [Puppet::Settings] the puppet settings object
|
34
|
+
# @param available_method [Symbol] the name of the method to call on
|
35
|
+
# settings to determine if the value in settings is available on the system
|
36
|
+
#
|
37
|
+
def initialize(name, fallback, settings, available_method)
|
38
|
+
@settings = settings
|
39
|
+
@available_method = available_method
|
40
|
+
@name = name
|
41
|
+
@fallback = fallback
|
42
|
+
end
|
43
|
+
|
44
|
+
def value
|
45
|
+
if safe_to_use_settings_value?
|
46
|
+
@settings[@name]
|
47
|
+
else
|
48
|
+
@fallback
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
def safe_to_use_settings_value?
|
54
|
+
@settings[:mkusers] or @settings.send(@available_method)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
10
58
|
attr_accessor :mode, :create
|
11
59
|
|
60
|
+
def initialize(args)
|
61
|
+
@group = Unspecified.new
|
62
|
+
@owner = Unspecified.new
|
63
|
+
super(args)
|
64
|
+
end
|
65
|
+
|
12
66
|
# Should we create files, rather than just directories?
|
13
67
|
def create_files?
|
14
68
|
create
|
15
69
|
end
|
16
70
|
|
71
|
+
# @param value [String] the group to use on the created file (can only be "root" or "service")
|
72
|
+
# @api public
|
17
73
|
def group=(value)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
74
|
+
@group = case value
|
75
|
+
when "root"
|
76
|
+
Root.new
|
77
|
+
when "service"
|
78
|
+
# Group falls back to `nil` because we cannot assume that a "root" group exists.
|
79
|
+
# Some systems have root group, others have wheel, others have something else.
|
80
|
+
Service.new(:group, nil, @settings, :service_group_available?)
|
81
|
+
else
|
82
|
+
unknown_value(':group', value)
|
83
|
+
end
|
28
84
|
end
|
29
85
|
|
86
|
+
# @param value [String] the owner to use on the created file (can only be "root" or "service")
|
87
|
+
# @api public
|
30
88
|
def owner=(value)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
89
|
+
@owner = case value
|
90
|
+
when "root"
|
91
|
+
Root.new
|
92
|
+
when "service"
|
93
|
+
Service.new(:user, "root", @settings, :service_user_available?)
|
94
|
+
else
|
95
|
+
unknown_value(':owner', value)
|
96
|
+
end
|
36
97
|
end
|
37
98
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@
|
99
|
+
# @return [String, nil] the name of the group to use for the file or nil if the group should not be managed
|
100
|
+
# @api public
|
101
|
+
def group
|
102
|
+
@group.value
|
42
103
|
end
|
43
104
|
|
44
|
-
|
45
|
-
|
105
|
+
# @return [String, nil] the name of the user to use for the file or nil if the user should not be managed
|
106
|
+
# @api public
|
107
|
+
def owner
|
108
|
+
@owner.value
|
46
109
|
end
|
47
110
|
|
48
111
|
def munge(value)
|
@@ -116,4 +179,9 @@ class Puppet::Settings::FileSetting < Puppet::Settings::StringSetting
|
|
116
179
|
end
|
117
180
|
}
|
118
181
|
end
|
182
|
+
|
183
|
+
private
|
184
|
+
def unknown_value(parameter, value)
|
185
|
+
raise SettingError, "The #{parameter} parameter for the setting '#{name}' must be either 'root' or 'service', not '#{value}'"
|
186
|
+
end
|
119
187
|
end
|