在运行木偶期间,节点上的事件查看器出现以下错误。我怀疑问题出在我的个人资料中的查询功能不正确。
Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement,Scconfig::Coserveradmin[SomeSettings]:
parameter 'parameterA' expects a String value,got Undef
parameter 'parameterB' expects a String value,got Undef
parameter 'parameterC' expects a String value,got Undef
parameter 'parameterD' expects a String value,got Undef
coserveradmin
是具有所有字符串参数的define
资源。我想从Json文件中查找值
{
"SASettings" : {
"Watchdog" : {
"ParameterA" : "somevalue","ParameterB" : "somevalue"
},"Serversettings" : {
"ParameterC" : "somevalue","ParameterD" : "somevalue",},"GeneralSettings" : {
"ParameterE" : "somevalue","ParameterF" : "somevalue","customsettings_prod" : {
"ParameterG" :"somevalue","ParameterH" : "%{facts.hostname}.example-cloud.com"
},"customsettings_dev" : {
"ParameterI" :"","ParameterK" : "%{facts.hostname}.example.net"
}
}
}
在我的hiera.yaml文件中,我定义了json文件的名称和路径。
- name: "Desired Some Settings"
path: "default/serveradmin.json"
在个人资料中,我有以下代码。
class profile::scconfig_someprofile_a {
.
.
.
$hname= $::facts['hostname']
$mac= "${facts['macaddress'].delete(':')}"
$adminpropeties = lookup('SASettings')
if $hname=~someregex {
scconfig::coserveradmin{ 'SomeSettings':
property1 => $adminpropeties['customsettings_prod.ParameterG'],property2 => $adminproperties['Watchdog.ParameterA'],property3 => $adminproperties['Watchdog.ParameterB'],property4 => $adminproperties['Serversettings.ParameterC'],.
.
.
.
and so on
.
macaddress => $mac,}
elsif $hname=~someregex {
scconfig::coserveradmin{ 'SomeSettings':
property1 => $adminpropeties['customsettings_dev.ParameterI'],}
还根据要求添加“定义”资源的代码。
define scconfig::coserveradmin(
String $Property1,String $Property2,String $Property3,String $Property4,.
.
.
String $macaddress,) {
$dscmoduleversion = lookup('requires.modules.codsc.version')
if $dscmoduleversion != '' {
$module = {
'name' => 'codsc','version' => $dscmoduleversion,}
}else{
$module = 'codsc'
}
$configname1='someconfig1'
$configname2='someconfig2'
$configname3='someconfig3'
dsc { 'someconfig1':
require => lookup('requires.cloudopssoftware'),resource_name => 'Someresourcename',module => $module,properties => {
configname => $configname1,Prop1 => $Property1,Prop2 => $Property2,Prop3 =>$Property3,}
dsc { 'someconfig2':
require => lookup('requires.cloudopssoftware'),resource_name => 'someresourcename2',properties => {
configname => $configname2,Prop1 => $Property4,Prop2 => $Property5,Prop3 =>$Property6,}
dsc { 'someconfig3':
require => lookup('requires.cloudopssoftware'),resource_name => 'someresourcename3',properties => {
configname => $configname3,Prop1 => $Property6,Prop2 => $Property7,Prop3 =>$Property8,.
.
.
Propn => $macaddress
},}
请注意,最后一个属性即macaddress是在配置文件类中评估的,因此我看不到任何错误。
任何想法可能是什么问题。