我在我创建的木偶模块上有一个问题。该模块没有检索我的yaml文件中包含的变量值。
问题似乎是从任何情况下都没有读取params.pp文件的原因...
它们位于正确的目录中,与变量名称中的内容匹配。
您可以有任何想法吗?
我的类:
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:InterfaceOfferImport","D:BSIC_DATAOfferImport"]:
ensure => directory
}
-> file {["${interface_input_path}",
"${temp_path}",
"${rejects_path}",
"${logs_path}",
"${done_path}",]:
ensure => directory
}
}
我的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 {
}
我的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'),
}
}
我的yaml
bluesky::components::webapp::offerimport::app_name: OfferImport
bluesky::components::webapp::offerimport::pkg_prefix: OfferImportOfferImport_
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:InterfaceOfferImportInput
bluesky::components::webapp::offerimport::params::temp_path: D:BSIC_DATAOfferImportTemp
bluesky::components::webapp::offerimport::params::rejects_path: D:BSIC_DATAOfferImportRejects
bluesky::components::webapp::offerimport::params::logs_path: D:BSIC_DATAOfferImportLogs
bluesky::components::webapp::offerimport::params::done_path: D:BSIC_DATAOfferImportDone
bluesky::components::webapp::offerimport::params::output_path: D:BSIC_DATAOfferImportOutput
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
我的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
谢谢!
问题似乎是从任何情况下都没有读取params.pp文件的原因...
这似乎不太可能。bluesky::components::webapp::offerimport
类从bluesky::components::webapp::offerimport::params
类继承,因此Puppet将确保在前者之前对后者进行评估。自史前木偶以来,这是完全可靠的。
但是,您似乎确实有不正确的期望。主要类可以从参数类继承是没有用的,因为参数类别不声明资源(我也不是间接地认为(,并且主要类不使用其任何变量。主要类声明几个参数,其名称与参数类的参数相同,但是这些是单独的变量,并且由于它们是主要类的本地变量,因此它们隐藏了父类范围中的类似命名的变量。
。 。在常规参数类模式中,人们将参数类的变量用作主要类参数的默认值。确实,这样做的能力是在这种情况下涉及阶级继承的唯一原因。示例:
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}.": }
}
然后,一个人可以通过各种方式将替代值绑定到主要类的参数。
。通过数据绑定设置参数级数据是非典型的,因为只能将数据直接绑定到目标类的参数更简单。我可以想象为此的场景,但是您的情况似乎并不是其中之一。我建议完全摆脱参数类,并修改HIERA数据以将值直接绑定到(仅(目标类。
您的文件结构是如何的。
应该是:
bluesky/
├── components
│ └── webapp
│ └── offerimport
│ └── manifests
│ └── params.pp
└── resources
└── webapps
└── manifests
└── params.pp