diff --git a/CHANGELOG.md b/CHANGELOG.md index b2b8774..1d78757 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## 3.10.3 +- Fix warnings + ## 3.10.2 - Fixed options param in tp::conf where use_v4 is false diff --git a/README.md b/README.md index 2547299..4da3d07 100644 --- a/README.md +++ b/README.md @@ -155,14 +155,14 @@ Here follows an example of tp resources used inside a custom profile where the c # Configuration of sshd_config server configuration file (main config file) tp::conf { 'openssh': - template => $server_template, - options_hash => $options, + template => $server_template, + my_options => $options, } # Configuration of ssh_config client configuration file tp::conf { 'openssh::ssh_config': - template => $client_template, - options_hash => $options, + template => $client_template, + my_options => $options, } } @@ -191,11 +191,11 @@ Install an application with default settings (package installed, service started tp::install { 'redis': } -Configure the application main configuration file a custom erb template which uses data from a custom $options_hash: +Configure the application main configuration file a custom erb template which uses data from a custom $my_options: tp::conf { 'rsyslog': - template => 'site/rsyslog/rsyslog.conf.erb', - options_hash => lookup('rsyslog::options_hash'), + template => 'site/rsyslog/rsyslog.conf.erb', + my_options => lookup('rsyslog::my_options'), } Populate any custom directory from a Git repository (it requires Puppet Labs' vcsrepo module): @@ -225,7 +225,7 @@ Other parameters are available to manage integrations: - **puppi_enable** Default: false. Installs [Puppi](https://github.com/example42/puppi) and enables puppi integration. - **test_enable** Default: false. If to enable automatic testing of the managed application. - **test_template** Default: undef. If provided, the provided erb template is used to test the application (instead of default tests). -- **options_hash** Default: {}. An optional hash where to set variable to use in test_template. +- **my_options** Default: {}. An optional hash where to set variable to use in test_template. Some specific params are to handle repos: @@ -239,7 +239,7 @@ These parameters allow to skip management of packages or services: Some parameters allow to configure tp::conf and tp::dir resources directly from tp::install (inheriting the same settings and options): -- **conf_hash**. Default: { }. A hash of tp::conf resources to create. These resources will refer to the same application specified in the tp::install $title and inherits the settings ensure, settings_hash, options_hash and data_module +- **conf_hash**. Default: { }. A hash of tp::conf resources to create. These resources will refer to the same application specified in the tp::install $title and inherits the settings ensure, settings_hash, my_options and data_module - **dir_hash**. Default: { }. A hash of tp::dir resources to create, as for the conf one. Parameters are also available to customise the tiny data settings which affect package and service names, repos settings, file paths and so on. The params are common to all the tp defines, check [Updating tiny data and using alternative data sources](#Updating-tiny-data-and-using-alternative-data-sources) section for details. @@ -253,7 +253,7 @@ An example with a custom test for the rabbitmq service: cli_enable => true, test_enable => true, test_template => 'profile/rabbitmb/tp_test.erb', - options_hash => { 'server' => "rabbitmq.${::domain}" } + my_options => { 'server' => "rabbitmq.${::domain}" } } It's possible to specify the version of the package to install (the provided version must be available in the configured repos): @@ -294,8 +294,8 @@ It's possible to manage files with different methods, for example directly provi or providing a custom template with custom options: tp::conf { 'openssh::ssh_config': - template => 'profile/openssh/ssh_config.erb', - options_hash => { + template => 'profile/openssh/ssh_config.erb', + my_options => { UsePAM => 'yes', X11Forwarding => 'no', } @@ -303,7 +303,7 @@ or providing a custom template with custom options: Via the template parameter with can both specify files .erb suffix (used as `content => template($template)`) or with .epp suffix (used as `content => epp($template)`). If not .erb or .epp suffix is present in the template value, then it's treates as and erb (`content => template($template)`). -In the profile/templates/openssh/ssh_config.erb template you will have the contents you want and use the above options with something like (note you can use both the @options and the @options_hash variable): +In the profile/templates/openssh/ssh_config.erb template you will have the contents you want and use the above options with something like (note you can use both the @options and the @my_options variable): [...] UsePAM <%= @options['UsePAM'] %> @@ -323,10 +323,10 @@ also it's possible to provide the source to use, instead of managing it with the 'puppet:///modules/site/redis/redis.conf' ] , } -For applications for which it exists the setting 'config_file_format' you can just pass the hash of options_hash of settings to configure and tp::conf creates a valid configuration file for the application: +For applications for which it exists the setting 'config_file_format' you can just pass the hash of my_options of settings to configure and tp::conf creates a valid configuration file for the application: tp::conf { 'filebeat': - options_hash => { + my_options => { filebeat.modules => ['module: system'] syslog => { enabled => true, @@ -339,7 +339,7 @@ This example makes much more sense if based on Hiera data (see [Configuring tp r tp::conf_hash: filebeat: - options_hash: + my_options: filebeat.modules: - module: system syslog: @@ -530,15 +530,15 @@ Or you can use a specific `tp::test` define: tp::test { 'rabbitmq': template => 'profile/rabbimq/tptest.erb', - options_hash => { + my_options => { port => '11111', host => 'localhost', }, } -All the keys set via the $options_hash parameter can be used in the erb template with sopmething like: +All the keys set via the $my_options parameter can be used in the erb template with sopmething like: - port_to_check=<%= @options_hash['port'] > + port_to_check=<%= @my_options['port'] > The `tp::test` define has the following parameters to manage the content of the test script (placed under `/etc/tp/test/$title`): diff --git a/data/common.yaml b/data/common.yaml index 05b119b..60280c8 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -9,7 +9,6 @@ tp::check_package_command: 'puppet resource package' tp::check_repo_path: 'echo "Check repo not supported on this OS"' tp::check_repo_path_post: '' tp::info_package_command': 'puppet resource package' -tp::options_hash: {} tp::install_hash: {} tp::install_hash_merge_behaviour: 'first' tp::install_defaults: {} diff --git a/docs/conf.md b/docs/conf.md index 311e08a..6a25b09 100644 --- a/docs/conf.md +++ b/docs/conf.md @@ -11,15 +11,15 @@ Given the above example, we can edit the referenced file with: [root@centos7-p4 ~]# mkdir -p /vagrant/modules_local/site/templates/nginx [root@centos7-p4 ~]# vi /vagrant/modules_local/site/templates/nginx/nginx.conf.erb -You can pass an hash of custom key/values using the ```options_hash``` parameter: +You can pass an hash of custom key/values using the ```my_options``` parameter: $nginx_options = { 'worker_processes' => '12', 'worker_connections' => '512', } tp::conf { 'nginx': - template => 'site/nginx/nginx.conf.erb', - options_hash => $nginx_options, + template => 'site/nginx/nginx.conf.erb', + my_options => $nginx_options, } An then, in your ```$modulepath/site/templates/ningx/nginx.conf.erb``` have something like: @@ -35,7 +35,7 @@ An then, in your ```$modulepath/site/templates/ningx/nginx.conf.erb``` have some multi_accept on; } -Some explanations are needed here. Your ```options_hash``` parameter is accessed, in the erb file, via the ```@options``` variable (You can use also ```@options_hash```) because in ```tp::conf``` we plan to merge the values from @options_hash to a set of default options (compliant with the underlying OS). +Some explanations are needed here. Your ```my_options``` parameter is accessed, in the erb file, via the ```@options``` variable (You can use also ```@my_options```) because in ```tp::conf``` we plan to merge the values from @my_options to a set of default options (compliant with the underlying OS). You have at disposal also the ```@settings``` hash which contains OS specific data for the managed application. To have an idea of what kind of data we provide for each supported application check in [```data/nginx/default.yaml```](https://github.com/example42/puppet-tp/blob/master/data/nginx/default.yaml). There are many options in ```tp::conf``` that let you manage every aspect of your configurations, for example we can manage its permissions, how to populate its content (with static source, epp or erb templates, plain content...), if to trigger a service restart when the files changes (by default the relevant service, if present, is restarted) and so on. diff --git a/docs/hiera.md b/docs/hiera.md index a444235..3b9a46a 100644 --- a/docs/hiera.md +++ b/docs/hiera.md @@ -32,8 +32,10 @@ On hiera yaml files then you can have somethig as follows (not actually recommen template: "site/apache/mime.types.erb" mysql: template: "site/mysql/my.cnf.erb" - options_hash: - + my_options: + 'innodb_buffer_pool_size': 512M + 'innodb_log_file_size': 128M + 'innodb_flush_log_at_trx_commit': 2 tp::dir_hash: apache::certs: diff --git a/lib/puppet/parser/functions/tp_lookup.rb b/lib/puppet/parser/functions/tp_lookup.rb index 8a9220f..d1f2663 100644 --- a/lib/puppet/parser/functions/tp_lookup.rb +++ b/lib/puppet/parser/functions/tp_lookup.rb @@ -22,7 +22,7 @@ module Puppet::Parser::Functions hiera_file_path = mp.path + '/data/' + app + '/hiera.yaml' unless File.exist?(hiera_file_path) - function_warning(["No tinydata found for: #{app} in #{hiera_file_path}. Trying to install package #{app}"]) + function_notice(["No tinydata found for: #{app} in #{hiera_file_path}. Trying to install package #{app}"]) default_fallback = true hiera_file_path = mp.path + '/data/default/hiera.yaml' end diff --git a/lib/puppet/parser/functions/tp_lookup4.rb b/lib/puppet/parser/functions/tp_lookup4.rb index 7d88d9f..3096f6e 100644 --- a/lib/puppet/parser/functions/tp_lookup4.rb +++ b/lib/puppet/parser/functions/tp_lookup4.rb @@ -22,7 +22,7 @@ module Puppet::Parser::Functions hiera_file_path = mp.path + '/data/' + app + '/hiera.yaml' unless File.exist?(hiera_file_path) - function_warning(["No tinydata found for: #{app} in #{hiera_file_path}. Trying to install package #{app}"]) + function_notice(["No tinydata found for: #{app} in #{hiera_file_path}. Trying to install package #{app}"]) default_fallback = true hiera_file_path = mp.path + '/data/default/hiera.yaml' end diff --git a/manifests/conf.pp b/manifests/conf.pp index f1da403..be164fb 100644 --- a/manifests/conf.pp +++ b/manifests/conf.pp @@ -181,7 +181,7 @@ # app that can be used in the provided erb or epp templates respectively as # @options_hash['key'] or $options_hash['key'], # -# @param settings_hash An hash that can override the application settings tp +# @param my_settings An hash that can override the application settings tp # returns, according to the underlying Operating System and the default # behaviour. # @@ -256,10 +256,10 @@ ) { # Deprecations if $settings_hash != {} { - deprecation('settings_hash', 'Replace with my_settings') + tp::fail($on_missing_data, "Module ${caller_module_name} needs updates: Parameter settings_hash in tp::conf is deprecated, replace it with my_settings") } if $options_hash != {} { - deprecation('options_hash', 'Replace with my_options') + tp::fail($on_missing_data, "Module ${caller_module_name} needs updates: Parameter options_hash in tp::conf is deprecated, replace it with my_options") } if $use_v4 { @@ -442,7 +442,7 @@ $upstream_repo = getparam(Tp::Install[$app],'upstream_repo') } $tp_settings = tp_lookup($app,'settings',$data_module,'merge') - $settings = $tp_settings + $settings_hash + $settings = deep_merge($tp_settings,$settings_hash,$my_settings) $tp_options = tp_lookup($app,"options::${base_file}",$data_module,'merge') $options = deep_merge($tp_options,$options_hash,$my_options,) diff --git a/manifests/debug.pp b/manifests/debug.pp index 4972165..d63f9f4 100644 --- a/manifests/debug.pp +++ b/manifests/debug.pp @@ -12,7 +12,10 @@ Variant[Undef,String] $epp = undef, Variant[Undef,String] $content = undef, + Hash $my_options = {}, Hash $options_hash = {}, + + Hash $my_settings = {}, Hash $settings_hash = {}, String[1] $data_module = 'tinydata', @@ -24,9 +27,17 @@ Boolean $cli_enable = pick($tp::cli_enable, true), ) { + # Deprecations + if $settings_hash != {} { + tp::fail('notify', "Module ${caller_module_name} needs updates: Parameter settings_hash in tp::debug is deprecated, replace it with my_settings") + } + if $options_hash != {} { + tp::fail('notify', "Module ${caller_module_name} needs updates: Parameter options_hash in tp::debug is deprecated, replace it with my_options") + } + # Settings evaluation $tp_settings=tp_lookup($title,'settings',$data_module,'deep_merge') - $settings = $tp_settings + $settings_hash + $settings = deep_merge($tp_settings,$settings_hash,$my_settings) include tp @@ -35,7 +46,7 @@ debug_command => $debug_command, } - $options = merge($options_defaults, $options_hash) + $options = deep_merge($options_defaults, $options_hash, $my_options) $array_package_name=any2array($settings['package_name']) $array_service_name=any2array($settings['service_name']) diff --git a/manifests/dir.pp b/manifests/dir.pp index 6bb4c97..9f3f555 100644 --- a/manifests/dir.pp +++ b/manifests/dir.pp @@ -175,7 +175,7 @@ ) { # Deprecations if $settings_hash != {} { - deprecation('settings_hash', 'Replace with my_settings') + tp::fail($on_missing_data, "Module ${caller_module_name} needs updates: Parameter settings_hash in tp::dir is deprecated, replace it with my_settings") } if $use_v4 { @@ -344,7 +344,7 @@ $title_path = undef } - $settings = $tp_settings + $settings_hash + $settings = deep_merge($tp_settings,$settings_hash,$my_settings) $prefix = $scope ? { 'global' => '', 'user' => 'user_', diff --git a/manifests/info.pp b/manifests/info.pp index 16a929e..5d5cb63 100644 --- a/manifests/info.pp +++ b/manifests/info.pp @@ -12,7 +12,10 @@ Variant[Undef,String] $epp = undef, Variant[Undef,String] $content = undef, + Hash $my_options = {}, Hash $options_hash = {}, + + Hash $my_settings = {}, Hash $settings_hash = {}, String[1] $data_module = 'tinydata', @@ -24,9 +27,17 @@ Boolean $cli_enable = pick($tp::cli_enable, true), ) { + # Deprecations + if $settings_hash != {} { + tp::fail('notify', 'Parameter settings_hash in tp::info is deprecated, replace it with my_settings') + } + if $options_hash != {} { + tp::fail('notify', 'Parameter options_hash in tp::info is deprecated, replace it with my_options') + } + # Settings evaluation $tp_settings=tp_lookup($title,'settings',$data_module,'deep_merge') - $settings = $tp_settings + $settings_hash + $settings = deep_merge($tp_settings,$settings_hash,$my_settings) include tp @@ -35,7 +46,7 @@ info_command => $info_command, } - $options = merge($options_defaults, $options_hash) + $options = deep_merge($options_defaults, $options_hash, $my_options) $array_package_name=any2array($settings['package_name']) $array_service_name=any2array($settings['service_name']) diff --git a/manifests/init.pp b/manifests/init.pp index f11777c..05e0243 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -105,28 +105,25 @@ } if $conf_hash != {} { - deprecation('conf_hash', 'Replace with confs') + tp::fail('notify', 'Parameter conf_hash in class tp is deprecated, replace it with confs') } if $dir_hash != {} { - deprecation('dir_hash', 'Replace with dirs') + tp::fail('notify', 'Parameter dir_hash in class tp is deprecated, replace it with dirs') } if $install_hash != {} { - deprecation('install_hash', 'Replace with installs') + tp::fail('notify', 'Parameter install_hash in class tp is deprecated, replace it with installs') } if $concat_hash != {} { - deprecation('concat_hash', 'No more supported') + tp::fail('notify', 'Parameter concat_hash in class tp is no more supported') } if $stdmod_hash != {} { - deprecation('stdmod__hash', 'No more supported') + tp::fail('notify', 'Parameter stdmod_hash in class tp is no more supported') } if $puppi_hash != {} { - deprecation('puppi_hash', 'No more supported') + tp::fail('notify', 'Parameter puppi_hash in class tp is no more supported') } if $repo_hash != {} { - deprecation('repo_hash', 'Replace with repos') - } - if $options_hash != {} { - deprecation('options_hash', 'Replace with options') + tp::fail('notify', 'Parameter repo_hash in class tp is no more supported') } if 'identity' in $facts { diff --git a/manifests/install.pp b/manifests/install.pp index 1f657e1..afd69dd 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -35,12 +35,12 @@ # upstream_repo => true, # } # -# @example installation and configuration via an options_hash +# @example installation and configuration via an my_options # Note: this works when auto_conf is true (as default) AND when # is defined $settings['config_file_template'] with a valid template # in the used data module (default: tinydata) # tp::install { 'puppetserver': -# options_hash => lookup('puppetserver::options', {merge => deep}), +# my_options => lookup('puppetserver::options', {merge => deep}), # } # # @example installation and configuration via a custom hash of tp::conf @@ -54,7 +54,7 @@ # # @example installation with custom settings # tp::install { 'apache': -# settings_hash => { +# my_settings => { # package_name => 'opt_apache', # service_enable => false, # config_file_path => '/opt/apache/conf/httpd.conf', @@ -104,11 +104,13 @@ # These resources will refer to the same application specified in the $title. # Deprecated, use dirs instead. # -# @param options An hash of options to pass to the tp::conf defines set in confs # usable as key/values in custom templates (use the $options var to access them). +# @param my_options An hash of options to pass to the tp::conf defines set in confs +# usable as key/values in custom templates (use the $options var to access them). # Replaces the deprecated options_hash parameter. # -# @param options_hash An hash of options to pass to the tp::conf defines set in confs # usable as key/values in custom templates (use the $options var to access them). -# Deprecated, use options instead. +# @param options_hash An hash of options to pass to the tp::conf defines set in confs +# usable as key/values in custom templates (use the $options var to access them). +# Deprecated, use my_options instead. # # @param my_settings An hash of settings to override the ones coming from tinydata # This is useful to override the default settings for the application. @@ -169,7 +171,7 @@ # @param auto_conf Boolean to enable automatic configuration of the application. # If true and there's are valid values for tinydata $settings['config_file_template'] # and $settings['init_file_template'] then the relevant -# file is managed according to tinydata defaults and user's $options_hash. +# file is managed according to tinydata defaults and user's $my_options. # # @param cli_enable Enable cli integration. # If true, tp commands to query apps installed via tp are added to the system. @@ -208,7 +210,7 @@ Hash $confs = {}, Hash $dirs = {}, - Hash $options = {}, + Hash $my_options = {}, Hash $my_settings = {}, @@ -260,22 +262,22 @@ $sane_app = regsubst($app, '/', '_', 'G') if $conf_hash != {} { - deprecation('conf_hash', 'Replace with confs') + tp::fail('notify', 'Parameter conf_hash in tp::conf is deprecated, replace it with confs') } $all_confs = $conf_hash + $confs if $dir_hash != {} { - deprecation('dir_hash', 'Replace with dirs') + tp::fail('notify', 'Parameter dir_hash in tp::conf is deprecated, replace it with dirs') } $all_dirs = $dir_hash + $dirs if $options_hash != {} { - deprecation('options_hash', 'Replace with options') + tp::fail('notify', 'Parameter options_hash in tp::conf is deprecated, replace it with my_options') } - $all_options = $options_hash + $options + $all_options = $options_hash + $my_options if $settings_hash != {} { - deprecation('settings_hash', 'Replace with my_settings') + tp::fail('notify', 'Parameter settings_hash in tp::conf is deprecated, replace it with my_settings') } # Settings evaluation @@ -430,10 +432,10 @@ # Additional confs and dirs $conf_defaults = { - 'ensure' => tp::ensure2file($ensure), - 'settings_hash' => $settings, - 'options_hash' => $all_options, - 'data_module' => $data_module, + 'ensure' => tp::ensure2file($ensure), + 'my_settings' => $settings, + 'my_options' => $all_options, + 'data_module' => $data_module, } $all_confs.each |$k,$v| { tp::conf { $k: @@ -447,9 +449,9 @@ } } $dir_defaults = { - 'ensure' => tp::ensure2dir($ensure), - 'settings_hash' => $settings, - 'data_module' => $data_module, + 'ensure' => tp::ensure2dir($ensure), + 'my_settings' => $settings, + 'data_module' => $data_module, } $all_dirs.each |$k,$v| { tp::dir { $k: @@ -517,7 +519,7 @@ before => Package[$settings[package_name]], data_module => $data_module, repo => $repo, - settings_hash => $settings_hash, + my_settings => $settings_hash, exec_environment => $repo_exec_environment, upstream_repo => $use_upstream_repo, apt_safe_trusted_key => $apt_safe_trusted_key, @@ -528,7 +530,7 @@ } if $auto_prerequisites { - deprecation('auto_prerequisites','Ignored. Parameter renamed to auto_prereq. s/auto_prerequisites/auto_prereq') + tp::fail('notify', 'Parameter auto_prerequisites in tp::install is ignored, Use auto_prereq') } # Automatic dependencies management, if data defined @@ -678,10 +680,10 @@ # Manage additional tp::conf as in conf_hash $conf_defaults = { - 'ensure' => tp::ensure2file($ensure), - 'settings_hash' => $settings, - 'options_hash' => $all_options, - 'data_module' => $data_module, + 'ensure' => tp::ensure2file($ensure), + 'my_settings' => $settings, + 'my_options' => $all_options, + 'data_module' => $data_module, } $all_confs.each |$k,$v| { @@ -698,9 +700,9 @@ # Manage additional tp::dir as in dir_hash $dir_defaults = { - 'ensure' => tp::ensure2dir($ensure), - 'settings_hash' => $settings, - 'data_module' => $data_module, + 'ensure' => tp::ensure2dir($ensure), + 'my_settings' => $settings, + 'data_module' => $data_module, } $all_dirs.each |$k,$v| { @@ -711,28 +713,28 @@ # Automatically manage config files and any Puppet resource, if tinydata defined if $auto_conf and $settings['config_file_template'] { - ::tp::conf { $app: - template => $settings['config_file_template'], - options_hash => $all_options, - data_module => $data_module, + tp::conf { $app: + template => $settings['config_file_template'], + my_options => $all_options, + data_module => $data_module, } } if $auto_conf and $settings['init_file_template'] { - ::tp::conf { "${app}::init": - template => $settings['init_file_template'], - options_hash => $all_options, - base_file => 'init', - data_module => $data_module, + tp::conf { "${app}::init": + template => $settings['init_file_template'], + my_options => $all_options, + base_file => 'init', + data_module => $data_module, } } # Optional test automation integration if $test_enable and $test_template { tp::test { $app: - settings_hash => $settings, - options_hash => $all_options, - template => $test_template, - data_module => $data_module, + my_settings => $settings, + my_options => $all_options, + template => $test_template, + data_module => $data_module, } } diff --git a/manifests/install/package.pp b/manifests/install/package.pp index 22da01d..09b5b33 100644 --- a/manifests/install/package.pp +++ b/manifests/install/package.pp @@ -29,12 +29,12 @@ # upstream_repo => true, # } # -# @example installation and configuration via an options_hash +# @example installation and configuration via an my_options # Note: this works when auto_conf is true (as default) AND when # is defined $settings['config_file_template'] with a valid template # in the used data module (default: tinydata) # tp::install { 'puppetserver': -# options_hash => lookup('puppetserver::options', {merge => deep}), +# my_options => lookup('puppetserver::options', {merge => deep}), # } # # @example installation and configuration via a custom hash of tp::conf @@ -167,7 +167,7 @@ } if $auto_prerequisites { - deprecation('auto_prerequisites','Ignored. Parameter renamed to auto_prereq. s/auto_prerequisites/auto_prereq') + tp::fail('notify', 'Parameter auto_prerequisites in tp::install is ignored, Use auto_prereq') } # Automatic dependencies management, if data defined diff --git a/manifests/repo.pp b/manifests/repo.pp index 7884949..65a7698 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -6,6 +6,8 @@ define tp::repo ( Boolean $enabled = true, + + Hash $my_settings = {}, Hash $settings_hash = {}, Variant[Undef,String] $repo = undef, @@ -43,6 +45,11 @@ String[1] $data_module = 'tinydata', ) { + # Deprecations + if $settings_hash != {} { + tp::fail('notify', 'Parameter settings_hash in tp::repo is deprecated, replace it with my_settings') + } + # Settings evaluation $enabled_num = bool2num($enabled) $ensure = bool2ensure($enabled) @@ -62,7 +69,7 @@ zypper_repofile_url => $zypper_repofile_url, } $user_settings_clean = delete_undef_values($user_settings) - $settings = $tp_settings + $settings_hash + $user_settings_clean + $settings = deep_merge($tp_settings,$settings_hash,$my_settings,$user_settings_clean) $manage_yum_gpgcheck = $yum_gpgcheck ? { undef => $settings[key_url] ? { diff --git a/manifests/test.pp b/manifests/test.pp index 1296179..2c0a946 100644 --- a/manifests/test.pp +++ b/manifests/test.pp @@ -11,8 +11,10 @@ Variant[Undef,String,Array] $template = undef, Variant[Undef,String] $epp = undef, Variant[Undef,String] $content = undef, - + Hash $my_options = {}, Hash $options_hash = {}, + + Hash $my_settings = {}, Hash $settings_hash = {}, String[1] $data_module = 'tinydata', @@ -20,9 +22,17 @@ Boolean $verbose = false, ) { + # Deprecations + if $settings_hash != {} { + tp::fail('notify', 'Parameter settings_hash in tp::test is deprecated, replace it with my_settings') + } + if $options_hash != {} { + tp::fail('notify', 'Parameter options_hash in tp::test is deprecated, replace it with my_options') + } + # Settings evaluation $tp_settings=tp_lookup($title,'settings',$data_module,'deep_merge') - $settings = $tp_settings + $settings_hash + $settings = deep_merge($tp_settings,$settings_hash,$my_settings) include tp @@ -44,15 +54,15 @@ check_port_host => '127.0.0.1', } - $options = merge($options_defaults, $options_hash) + $options = deep_merge($options_defaults, $options_hash, $my_options) $array_package_name=any2array($settings['package_name']) $array_service_name=any2array($settings['service_name']) $array_tcp_port=any2array($settings['tcp_port']) $epp_params = { - options => $options, - options_hash => $options_hash, + options => $options, + my_options => $my_options, } # Find out the file's content value if $content { diff --git a/metadata.json b/metadata.json index 478137a..43bff61 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "example42-tp", - "version": "3.10.2", + "version": "3.10.3", "author": "example42", "summary": "Tiny Puppet", "license": "Apache-2.0", diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index a6f8ab5..c093b53 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -43,63 +43,63 @@ let(:params) { { 'source' => 'puppet:///modules/tp/spec' } } it { is_expected.to contain_file(appdata['config_file_path']).only_with(default_file_params.merge('source' => 'puppet:///modules/tp/spec')) } end - context 'with template => tp/spec/sample.erb and sample options_hash' do + context 'with template => tp/spec/sample.erb and sample my_options' do let(:params) do { - 'template' => 'tp/spec/sample.erb', - 'options_hash' => sample_options, + 'template' => 'tp/spec/sample.erb', + 'my_options' => sample_options, } end it { is_expected.to contain_file(appdata['config_file_path']).only_with(default_file_params.merge('content' => sample_erb)) } end - context 'with template => tp/spec/sample.epp and sample options_hash' do + context 'with template => tp/spec/sample.epp and sample my_options' do let(:params) do { - 'template' => 'tp/spec/sample.epp', - 'options_hash' => sample_options, + 'template' => 'tp/spec/sample.epp', + 'my_options' => sample_options, } end it { is_expected.to contain_file(appdata['config_file_path']).only_with(default_file_params.merge('content' => sample_epp)) } end - context 'with epp => tp/spec/sample.epp and sample options_hash' do + context 'with epp => tp/spec/sample.epp and sample my_options' do let(:params) do { - 'epp' => 'tp/spec/sample.epp', - 'options_hash' => sample_options, + 'epp' => 'tp/spec/sample.epp', + 'my_options' => sample_options, } end it { is_expected.to contain_file(appdata['config_file_path']).only_with(default_file_params.merge('content' => sample_epp)) } end context 'with content => sampletext' do let(:params) do { - 'content' => 'sampletext', + 'content' => 'sampletext', } end it { is_expected.to contain_file(appdata['config_file_path']).only_with(default_file_params.merge('content' => 'sampletext')) } end context 'with content => sampletext and template => tp/spec/sample.erb' do let(:params) do { - 'content' => 'sampletext', - 'template' => 'tp/spec/sample.erb', - 'options_hash' => sample_options, + 'content' => 'sampletext', + 'template' => 'tp/spec/sample.erb', + 'my_options' => sample_options, } end it { is_expected.to contain_file(appdata['config_file_path']).only_with(default_file_params.merge('content' => 'sampletext')) } end context 'with content => sampletext and epp => tp/spec/sample.epp' do let(:params) do { - 'content' => 'sampletext', - 'epp' => 'tp/spec/sample.epp', - 'options_hash' => sample_options, + 'content' => 'sampletext', + 'epp' => 'tp/spec/sample.epp', + 'my_options' => sample_options, } end it { is_expected.to contain_file(appdata['config_file_path']).only_with(default_file_params.merge('content' => 'sampletext')) } end context 'with content => sampletext, template => tp/spec/sample.erb and epp => tp/spec/sample.epp' do let(:params) do { - 'content' => 'sampletext', - 'template' => 'tp/spec/sample.erb', - 'epp' => 'tp/spec/sample.epp', - 'options_hash' => sample_options, + 'content' => 'sampletext', + 'template' => 'tp/spec/sample.erb', + 'epp' => 'tp/spec/sample.epp', + 'my_options' => sample_options, } end it { is_expected.to contain_file(appdata['config_file_path']).only_with(default_file_params.merge('content' => 'sampletext')) } end context 'with template => tp/spec/sample.erb and epp => tp/spec/sample.epp' do let(:params) do { - 'template' => 'tp/spec/sample.erb', - 'epp' => 'tp/spec/sample.epp', - 'options_hash' => sample_options, + 'template' => 'tp/spec/sample.erb', + 'epp' => 'tp/spec/sample.epp', + 'my_options' => sample_options, } end it { is_expected.to contain_file(appdata['config_file_path']).only_with(default_file_params.merge('content' => sample_erb)) } end @@ -111,14 +111,14 @@ context "with title => #{app}::sample.conf and path => /tmp/sample.conf" do let(:title) { "#{app}::sample.conf" } let(:params) do { - 'path' => '/tmp/sample.conf', + 'path' => '/tmp/sample.conf', } end expected_path = '/tmp/sample.conf' it { is_expected.to contain_file(expected_path).only_with(default_file_params.merge('path' => expected_path)) } end context "with base_file => init" do let(:params) do { - 'base_file' => 'init', + 'base_file' => 'init', } end expected_path = appdata['init_file_path'] it { is_expected.to contain_file(expected_path).only_with(default_file_params.merge('path' => expected_path)) } @@ -126,7 +126,7 @@ context "with title => #{app}::sample.conf and base_file => init" do let(:title) { "#{app}::sample.conf" } let(:params) do { - 'base_file' => 'init', + 'base_file' => 'init', } end expected_path = appdata['init_file_path'] it { is_expected.to contain_file(expected_path).only_with(default_file_params.merge('path' => expected_path)) } @@ -134,7 +134,7 @@ context "with title => #{app}::sample.conf and base_dir => data" do let(:title) { "#{app}::sample.conf" } let(:params) do { - 'base_dir' => 'data', + 'base_dir' => 'data', } end expected_path = "#{appdata['data_dir_path']}/sample.conf" it { is_expected.to contain_file(expected_path).only_with(default_file_params.merge('path' => expected_path)) } diff --git a/spec/defines/info_spec.rb b/spec/defines/info_spec.rb index 21c68b6..d625988 100644 --- a/spec/defines/info_spec.rb +++ b/spec/defines/info_spec.rb @@ -55,30 +55,30 @@ let(:params) { { 'source' => 'puppet:///modules/tp/spec' } } it { is_expected.to contain_file("/etc/tp/info/#{app}").only_with(default_file_params.merge('source' => 'puppet:///modules/tp/spec')) } end - context 'with template => tp/spec/sample.erb and sample options_hash' do + context 'with template => tp/spec/sample.erb and sample my_options' do let(:params) do { - 'template' => 'tp/spec/sample.erb', - 'options_hash' => sample_options, + 'template' => 'tp/spec/sample.erb', + 'my_options' => sample_options, } end it { is_expected.to contain_file("/etc/tp/info/#{app}").only_with(default_file_params.merge('content' => sample_erb)) } end - context 'with template => tp/spec/sample.epp and sample options_hash' do + context 'with template => tp/spec/sample.epp and sample my_options' do let(:params) do { - 'template' => 'tp/spec/sample.epp', - 'options_hash' => sample_options, + 'template' => 'tp/spec/sample.epp', + 'my_options' => sample_options, } end it { is_expected.to contain_file("/etc/tp/info/#{app}").only_with(default_file_params.merge('content' => sample_epp)) } end - context 'with epp => tp/spec/sample.epp and sample options_hash' do + context 'with epp => tp/spec/sample.epp and sample my_options' do let(:params) do { - 'epp' => 'tp/spec/sample.epp', - 'options_hash' => sample_options, + 'epp' => 'tp/spec/sample.epp', + 'my_options' => sample_options, } end it { is_expected.to contain_file("/etc/tp/info/#{app}").only_with(default_file_params.merge('content' => sample_epp)) } end context 'with content => sample' do let(:params) do { - 'content' => 'sample', + 'content' => 'sample', } end it { is_expected.to contain_file("/etc/tp/info/#{app}").only_with(default_file_params.merge('content' => 'sample')) } end diff --git a/spec/defines/test_spec.rb b/spec/defines/test_spec.rb index 4cdbc60..3f66012 100644 --- a/spec/defines/test_spec.rb +++ b/spec/defines/test_spec.rb @@ -53,30 +53,30 @@ let(:params) { { 'source' => 'puppet:///modules/tp/spec' } } it { is_expected.to contain_file("/etc/tp/test/#{app}").only_with(default_file_params.merge('source' => 'puppet:///modules/tp/spec')) } end - context 'with template => tp/spec/sample.erb and sample options_hash' do + context 'with template => tp/spec/sample.erb and sample my_options' do let(:params) do { - 'template' => 'tp/spec/sample.erb', - 'options_hash' => sample_options, + 'template' => 'tp/spec/sample.erb', + 'my_options' => sample_options, } end it { is_expected.to contain_file("/etc/tp/test/#{app}").only_with(default_file_params.merge('content' => sample_erb)) } end - context 'with template => tp/spec/sample.epp and sample options_hash' do + context 'with template => tp/spec/sample.epp and sample my_options' do let(:params) do { - 'template' => 'tp/spec/sample.epp', - 'options_hash' => sample_options, + 'template' => 'tp/spec/sample.epp', + 'my_options' => sample_options, } end it { is_expected.to contain_file("/etc/tp/test/#{app}").only_with(default_file_params.merge('content' => sample_epp)) } end - context 'with epp => tp/spec/sample.epp and sample options_hash' do + context 'with epp => tp/spec/sample.epp and sample my_options' do let(:params) do { - 'epp' => 'tp/spec/sample.epp', - 'options_hash' => sample_options, + 'epp' => 'tp/spec/sample.epp', + 'my_options' => sample_options, } end it { is_expected.to contain_file("/etc/tp/test/#{app}").only_with(default_file_params.merge('content' => sample_epp)) } end context 'with content => sample' do let(:params) do { - 'content' => 'sample', + 'content' => 'sample', } end it { is_expected.to contain_file("/etc/tp/test/#{app}").only_with(default_file_params.merge('content' => 'sample')) } end diff --git a/templates/spec/sample.epp b/templates/spec/sample.epp index a1c2176..ccb0505 100644 --- a/templates/spec/sample.epp +++ b/templates/spec/sample.epp @@ -1,4 +1,4 @@ # Sample template used in spec tests. DO NOT MODIFY! # A rendered version used to tests is in spec/tpdata/sample.epp -host = <%= $options_hash['host'] %> +host = <%= $my_options['host'] %> port = <%= $options['port'] %> diff --git a/templates/spec/sample.erb b/templates/spec/sample.erb index 121b24a..06bf84e 100644 --- a/templates/spec/sample.erb +++ b/templates/spec/sample.erb @@ -1,4 +1,4 @@ # Sample template used in spec tests. DO NOT MODIFY! # A rendered version used to tests is in spec/tpdata/sample.erb -host = <%= @options_hash['host'] %> +host = <%= @my_options['host'] %> port = <%= @options['port'] %>