Reputation: 21
I have an issue on a Puppet module I'm creating. This module is not retrieving the variables value included into my YAML file.
The problem seems to come from that it's not reading the params.pp file in any case...
They are located in the right directories, matching what's in the variable name.
May you please have any idea ?
My class :
class bluesky::components::webapp::offerimport (
$temp_path = undef,
$rejects_path = undef,
$logs_path = undef,
$done_path = undef,
$app_name = undef,
$app_version = undef,
$pkg_prefix = undef,
$archiver = undef,
$pkg_repos = undef,
$interface_input_path = undef,
) inherits bluesky::components::webapp::offerimport::params {
$tmp_dir = "D:\\Temp\\${app_name}_${app_version}"
$install_dir = "D:\\BSIC\\${pkg_prefix}${app_version}"
$pkg = "${pkg_repos}\\CoreLibScripts\\${app_name}_${app_version}.zip"
$inner_zip = "$tmp_dir\\${app_name}.zip"
$output_inner_zip = "$tmp_dir\\Cab"
bluesky::resources::extract { "Extract ${app_name}":
pkg => $pkg,
archiver => $archiver,
output => $tmp_dir,
}
-> bluesky::resources::extract { "Extract InnerZIP ${app_name}":
pkg => $inner_zip,
archiver => $archiver,
output => $output_inner_zip,
}
-> bluesky::resources::copydir { "Copy ${app_name}":
source => $output_inner_zip,
target => $install_dir,
}
-> class {'bluesky::components::webapp::offerimport::configtemplates':
install_dir => $install_dir
}
-> file {["D:\Interface","D:\Interface\OfferImport","D:\BSIC_DATA\OfferImport"]:
ensure => directory
}
-> file {["${interface_input_path}",
"${temp_path}",
"${rejects_path}",
"${logs_path}",
"${done_path}",]:
ensure => directory
}
}
My Params.pp :
class bluesky::components::webapp::offerimport::params (
String $interface_input_path = undef,
String $temp_path = undef,
String $rejects_path = undef,
String $logs_path = undef,
String $done_path = undef,
String $output_path = undef,
String $om_servername = undef,
String $om_dbname = undef,
String $om_login = undef,
String $om_pwd = undef,
String $name_cfg_ptnametopitype = undef,
String $name_cfg_pttors = undef,
String $name_cfg_suppponametotype = undef,
String $mn_schema_file = undef,
String $name_pivot_tmp = undef,
String $name_rejects_nopitype = undef,
String $name_rejects_norstype = undef,
String $name_rejects_piwithoutrs = undef,
String $name_rejects_powithoutpi = undef,
String $name_rejects_rswithoutre = undef,
String $name_warning_productoffering = undef,
String $mn_helper_dll = undef,
String $archiver = lookup('bluesky::params::global::archiver'),
String $pkg_repos = lookup('bluesky::params::global::pkg_repos'),
) inherits bluesky::resources::webapp::params {
}
My ConfigTemplates.pp :
class bluesky::components::webapp::offerimport::configtemplates(
# $title = undef,
$install_dir = undef,
) inherits bluesky::components::webapp::offerimport::params {
file { "${title} Parameters.ini":
ensure => 'file',
path => "${install_dir}\\Config\\Parameters.ini",
content => template('bluesky/offerimport/config/Parameters.ini.erb'),
}
}
My YAML
bluesky::components::webapp::offerimport::app_name: OfferImport
bluesky::components::webapp::offerimport::pkg_prefix: OfferImport\OfferImport_
bluesky::components::webapp::offerimport::signal_file: BlueSky.BSIC.DA.UI.dll
bluesky::components::webapp::offerimport::configfolder: config
##
bluesky::components::webapp::offerimport::params::interface_input_path: D:\Interface\OfferImport\Input
bluesky::components::webapp::offerimport::params::temp_path: D:\BSIC_DATA\OfferImport\Temp
bluesky::components::webapp::offerimport::params::rejects_path: D:\BSIC_DATA\OfferImport\Rejects
bluesky::components::webapp::offerimport::params::logs_path: D:\BSIC_DATA\OfferImport\Logs
bluesky::components::webapp::offerimport::params::done_path: D:\BSIC_DATA\OfferImport\Done
bluesky::components::webapp::offerimport::params::output_path: D:\BSIC_DATA\OfferImport\Output
bluesky::components::webapp::offerimport::params::om_servername: Servername
bluesky::components::webapp::offerimport::params::om_dbname: DatabaseName
bluesky::components::webapp::offerimport::params::om_login: DatabaseLogin
bluesky::components::webapp::offerimport::params::om_pwd: DatabasePassword
bluesky::components::webapp::offerimport::params::name_cfg_ptnametopitype: PTNameToPIType.csv
bluesky::components::webapp::offerimport::params::name_cfg_pttors: PTtoREandRS.csv
bluesky::components::webapp::offerimport::params::name_cfg_suppponametotype: SuppPONameToType.csv
bluesky::components::webapp::offerimport::params::mn_schema_file: ProductCatalogtoBIver7.6.0.xsd
bluesky::components::webapp::offerimport::params::name_pivot_tmp: OFFER_IMPORT_PIVOT_TMP.csv
bluesky::components::webapp::offerimport::params::name_rejects_nopitype: OFFER_IMPORT_REJECTS_NoPIType.csv
bluesky::components::webapp::offerimport::params::name_rejects_norstype: OFFER_IMPORT_REJECTS_NoRSorREType.csv
bluesky::components::webapp::offerimport::params::name_rejects_piwithoutrs: OFFER_IMPORT_REJECTS_PIWithoutRS.csv
bluesky::components::webapp::offerimport::params::name_rejects_powithoutpi: OFFER_IMPORT_REJECTS_POWithoutPI.csv
bluesky::components::webapp::offerimport::params::name_rejects_rswithoutre: OFFER_IMPORT_REJECTS_RSWithoutRE.csv
bluesky::components::webapp::offerimport::params::name_warning_productoffering OFFER_IMPORT_ProductOffering_Warning.csv
bluesky::components::webapp::offerimport::params::mn_helper_dll: BlueSky.BSIC.Com.MetraNet.dll
My hiera.yaml :
hierarchy:
- name: "Per-node data"
path: "nodes/%{trusted.certname}.yaml"
- name: Common
path: common.yaml
- name: OfferImport
path: offerimport.yaml
defaults:
data_hash: yaml_data
datadir: data
Thank you !
Upvotes: 0
Views: 590
Reputation: 180093
The problem seems to come from that it's not reading the params.pp file in any case...
This seems highly unlikely. Class bluesky::components::webapp::offerimport
inherits from class bluesky::components::webapp::offerimport::params
, so Puppet will ensure that the latter is evaluated before the former. This has been completely reliable since prehistoric Puppet.
You do seem to have incorrect expectations, however. It is useless for the primary class to inherit from the params class because the params class declares no resources (I assume not indirectly, either), and the primary class does not use any of its variables. The primary class declares several parameters with the same names as parameters of the params class, but these are separate variables, and because they are local to the primary class, they hide the like-named ones in the parent class scope.
In the conventional params class pattern, one uses variables of the params class as default values for the primary class's parameters. Indeed, the ability to do so is the only reason for involving class inheritance in this case. Example:
class foo::params {
$default_env = 'GUE'
$default_greeting = 'Hello, Sailor!'
$default_menace = 'grue'
}
class foo::messages (
$env = $foo::params::default_env,
$greeting = $foo::params::default_greeting,
$menace = $foo::params::menace,
) inherits foo::params {
notify { "In the ${env}, we say '${greeting}' Try not to be eaten by a ${menace}.": }
}
One can then bind alternative values to the primary class's parameters by various means, including Hiera data.
It is atypical to set params-class data via data binding, because it's simpler to just bind data directly to the target class's parameters. I can imagine scenarios for it, but yours doesn't appear to be one of them. I suggest getting rid of the params class altogether, and modifying your Hiera data to bind values directly to (only) the target class.
Upvotes: 2
Reputation: 532
How is your file structure for this Params.pp (bluesky::components::webapp::offerimport::params) class?
it should be something like:
bluesky/
├── components
│ └── webapp
│ └── offerimport
│ └── manifests
│ └── params.pp
└── resources
└── webapps
└── manifests
└── params.pp
Upvotes: 0