我编写了一个 Puppet 模块,该模块用于创建一个目录、将文件复制到该目录并更改文件的所有权。模块名称为“workspace”。模块的清单文件夹中有三个文件:
-rw-r--r-- 1 root root 9578 2015-03-25 05:03 config.pp
-rw-r--r-- 1 root root 668 2015-03-25 04:37 init.pp
-rw-r--r-- 1 root root 519 2015-03-25 04:27 params.pp
init.pp的内容为:
class workspace (
$debug_mode = $workspace::params::_debug_mode,
$jdk_enable = $workspace::params::_jdk_enable,
$jdk_ver = $workspace::params::_jdk_ver,
$tomcat_enable = $workspace::params::_tomcat_enable,
$tomcat_ver = $workspace::params::_tomcat_ver,
$component_ver = $workspace::params::_component_ver,
$component_filename = $workspace::params::_component_filename,
$components_locations = $workspace::params::_components_locations,
$app_user = $workspace::params::_app_user,
$app_group = $workspace::params::_app_group,
) inherits workspace::params {
include workspace::config
}
config.pp 的相关部分:
class workspace::config {
## Default permissions
File {
owner => ${::workspace::app_user},
group => ${::workspace::app_group},
}
params.pp的内容:
class workspace::params {
$_debug_mode = hiera("debug_mode", false)
$_jdk_enable = hiera("jdk_enable", true)
$_jdk_ver = hiera("jdk_ver", "")
$_tomcat_enable = hiera("tomcat_enable", false)
$_tomcat_ver = "6.0.29"
$_component_ver = hiera("component_ver", "")
$_component_filename = hiera("component_filename", "")
$_components_locations = "/nfs/software/RC-FROM-IL/newJarRepos/v3.13/"
$_app_user = "peeradmin"
$_app_group = "company_peeradmin_linux_policy"
}
问题是,当我运行时puppet agent -t
,出现以下错误:
[root@pnd01 ~]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not match ${::workspace::app_user}, at /etc/puppet/environments/production/modules/workspace/manifests/config.pp:5 on node pnd01.company.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
我找不到错误的原因。我尝试像这样编辑“所有者”:
owner => ${app_user},
owner => ${::workspace::params:_app_user}
owner => ${::workspace::params:app_user}
但都不起作用...你能尝试找出原因吗?
答案1
似乎添加" "
所有者和组变量可以解决问题。我已更改此内容:
## Default permissions
File {
owner => ${::workspace::app_user},
group => ${::workspace::app_group},
}
变成这样:
## Default permissions
File {
owner => "${::workspace::app_user}",
group => "${::workspace::app_group}",
}
感谢您的帮助。