我不能让我的木偶清单以我期望的方式找到模板,所以我想有人可能会有一个快速的答案。我是puppet的新手,所以我只是想了解所有东西的所有位置,以及如何正确地引用文件。如果我遗漏了一些非常明显的东西,我道歉。
这是可行的:
file {
$zabbix_agent_conf:
owner => root,
group => root,
mode => 0644,
content => template("/etc/puppet/templates/zabbix/files/zabbix_agent_conf.erb"),
require => Package["zabbix-agent"];
}这不会:
file {
$zabbix_agent_conf:
owner => root,
group => root,
mode => 0644,
content => template("puppet:///templates/zabbix/zabbix_agent_conf.erb"),
require => Package["zabbix-agent"];
}我的/etc/puppet/puppet.conf:
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
templatedir=/etc/puppet/templates
prerun_command=/etc/puppet/etckeeper-commit-pre
postrun_command=/etc/puppet/etckeeper-commit-post
[master]
# These are needed when the puppetmaster is run by passenger
# and can safely be removed if webrick is used.
ssl_client_header = SSL_CLIENT_S_DN
ssl_client_verify_header = SSL_CLIENT_VERIFY发布于 2013-10-15 00:46:19
到目前为止,您还不能将puppet URI方案与模板函数结合使用。根据文档:
注意,指向模板的路径并不使用与puppet:/ URL中的路径相同的语义。很抱歉造成了不一致。(Source)
此外:
(如果在任何模块中都找不到文件,模板函数将回退到相对于Puppet的templatedir中的路径进行搜索。但是,不再推荐使用此设置。) (Source)
这意味着为了使用templatedir,模板函数需要一个简单的相对路径:
template("zabbix/zabbix_agent_conf.erb")不建议使用templatedir。这是有充分理由的。最好是在module的共同标准下将文件分组在一起,否则事情很快就会变得非常混乱。可以把模块看作是对属于彼此的所有傀儡资源进行分组的好方法:清单、文件、模板、扩展和测试。
因此,我建议创建一个zabbix模块。将您的傀儡代码放在zabbix模块清单目录中的init.pp内的zabbix类中。然后,您可以将模板放在zabbix模块的模板目录中,并且可以通过以下方式引用它:
template("zabbix/zabbix_agent_conf.erb")希望这能有所帮助。祝好运!
发布于 2017-01-06 20:37:40
在模块中,使用
模板(“${module_name}/xxx.erb”)
引用模板文件(适用于puppet 4.x.对于以前的版本不确定)。
https://stackoverflow.com/questions/19364126
复制相似问题