The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com
https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:
"Could not find value for $confdir" regression when using $confdir in puppet.conf
|Affected Puppet version:||Branch:||https://github.com/puppetlabs/puppet/pull/2127|
This is a regression from 3.3.x to 3.4.0-rc1.
When puppet.conf contains the following:
[main] autosign = $confdir/autosign.conf
All puppet commands fail as the $confdir can’t be interpolated.
# puppet --version 3.3.2 # puppet apply --configprint autosign /etc/puppet/autosign.conf # yum upgrade --enablerepo=puppetlabs-devel puppet [snip, updated to 3.4.0-rc1] # rpm -q puppet puppet-3.4.0-0.1rc1.el6.noarch # puppet apply --configprint autosign Error: Could not intialize global default settings: Error converting value for param 'autosign': Could not find value for $confdir # puppet --version Error: Could not intialize global default settings: Error converting value for param 'autosign': Could not find value for $confdir
#2 Updated by Adrien Thebo over 2 years ago
- Status changed from Unreviewed to Accepted
The reason this is occurring is that defining a hook on a setting can force that value to be interpolated before all settings are loaded, which can cause interpolation to fail.
Settings with hooks have their hooks invoked every time that setting is parsed
Puppet::Settings#unsafe_parse. Invoking a hook requires that the setting value is interpolated, which means that all values to interpolate must be loaded when the hook is invoked. Lastly we evaluate global settings before application settings
Puppet.do_initialize_settings_for_run_mode, which means that global settings that interpolate application settings can only be evaluated after application settings have been initialized. There is functionality to defer the evaluation of settings hooks after application initialization
Puppet::Settings#define_settings but this only occurs when settings are defined; every time a setting is parsed all hooks are unconditionally run. This means that if a global setting like autosign interpolates an application setting (
autosign = $confdir/autosign.conf) and defines a hook, the hook will be called too early and fail to interpolate.
This issue should be fixed in a few ways. First off, setting hooks should not be used to perform validation. Settings validation is generally handled by the
Puppet::Settings::BaseSetting#munge method that’s overridden by childen, so we should move the validation to the
#munge method. Secondly, settings need to be able to defer hooks from parse time to post application initialization so that the values can safely be interpolated.