-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set default values for different puppet versions #202
Conversation
features/puppet/defaults.pan
Outdated
}else{ | ||
version = PUPPET_VERSION; | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be neater:
variable PUPPET_VERSION ?= '3.0.0';
'/software/components/puppet' = {
version = PUPPET_VERSION;
version = replace('^([0-9]+)$', '$1.0', version); #Pad single to double
version = replace('^([0-9]+\.[0-9]+)$', '$1.0', version); # Pad double to triple
…etc…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact this shouldn't be necessary if you are only using if for the comparisons later on, pkg_compare_version
should handle this for you.
features/puppet/config.pan
Outdated
|
||
'/software/packages/{puppet}' ?= nlist(); | ||
'/software/packages/{puppet}' ?= dict(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg_repl()
is preferred.
'/software/packages' = pkg_repl('puppet');
features/puppet/defaults.pan
Outdated
|
||
# Defaults for version > 4 | ||
if(pkg_compare_version(version, '4.0.0') != PKG_VERSION_LESS){ | ||
SELF['hieraconf_file'] = '/etc/puppetlabs/code/environments/production/hiera.yaml'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to avoid operating on SELF
like this. It might actually be nicer to adapt this to instead include a defaults file for each major version, but it's up to you.
Perhaps something like:
include if (pkg_compare_version(PUPPET_VERSION, '4.0.0') != PKG_VERSION_LESS) 'features/puppet/defaults_4+';
include if (pkg_compare_version(PUPPET_VERSION, '5.0.0') != PKG_VERSION_LESS) 'features/puppet/defaults_5+';
template features/puppet/defaults_4+;
include 'components/puppet/config';
prefix '/software/components/puppet';
'hieraconf_file' = '/etc/puppetlabs/code/environments/production/hiera.yaml';
'puppet_cmd' = '/opt/puppetlabs/bin/puppet';
'puppetconf_file' = '/etc/puppetlabs/puppet/puppet.conf';
template features/puppet/defaults_5+;
include 'components/puppet/config';
prefix '/software/components/puppet';
'nodefiles/{quattor_default.pp}/contents' = "lookup('classes', Array[String], 'unique').include",
'modulepath' = '/etc/puppetlabs/code/environments/production/modules';
'nodefiles_path' = '/etc/puppetlabs/code/environments/production/manifests';
"hieraconf" = dict(
"version", 5,
"hierarchy", list(
dict(
"name", "quattor",
"path", "quattor.yaml",
)
),
"defaults", dict(
"datadir", "/etc/puppetlabs/code/environments/production/data",
"data_hash", "yaml_data",
),
);
'hieradata_file' = '/etc/puppetlabs/code/environments/production/data/quattor.yaml';
Hi James, I've tried to implement all your recommendations. Actually I cannot define to a standard value PUPPET_VERSION in the defaults template as it seems that this template is called one first time before the site's defaults are set (and fixing the variable would imply that the sites cannot have a define+fallback setup). Changing this would require touching a lot of other stuff and I'd prefer not to. Thus I've implemented this in a slightly different way wrt what you suggested. |
features/puppet/defaults.pan
Outdated
|
||
include 'components/puppet/config'; | ||
|
||
variable PUPPET_4_INCLUDE = is_defined(PUPPET_VERSION) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be acceptable to provide a default Puppet version to avoid having to check for it being defined?
For example:
variable PUPPET_VERSION ?= '3.0.0';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I see your comment, nevermind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I presume you've tested this!
Sorry, I had to add a modification. It seems that pkg_compare_version does not handle comparing versions which are not in the X.Y.Z format. So I've re-introduced the PUPPET_VERSION formatting in the default template. |
Ok, my apologies, my testing seemed to indicate that it worked! |
This PR goes with quattor/configuration-modules-core#1201 the components and schema have been updated to be compliant with the most recent versions of puppet. I've just introduced a default.pan template managing the different default values corresponding to different versions.