我该如何configuration“init.pp”文件才能在同一个类中发送多个文件? 我所做的是这样的:
class nagios { file { ['/usr/lib64/nagios/plugins/']: path => '/usr/lib64/nagios/plugins/', ensure => directory, notify => Service['nrpe'], source => ["puppet:///modules/mymodule/check_mem.sh", 'puppet:///modules/mymodule/check_mountpoint.sh'], sourceselect => all, } service { 'nrpe': ensure => 'running', enable => true, } }
我正在尝试发送两个不同的文件到同一个远程文件夹,然后重新启动服务。
但是,当我在客户端运行puppet时,出现这些错误:
[...] Error: Could not set 'file' on ensure: Is a directory - (/usr/lib64/nagios/plugins20170306-28992-j54k6x, /usr/lib64/nagios/plugins) at 153:/etc/puppet/modules/mymodule/manifests/init.pp [...] Error: /Stage[main]/Nagios/File[/usr/lib64/nagios/plugins/]/ensure: change from directory to file failed: Could not set 'file' on ensure: Is a directory - (/usr/lib64/nagios/plugins20170306-28992-j54k6x, /usr/lib64/nagios/plugins) at 153:/etc/puppet/modules/mymodule/manifests/init.pp
我的错误在哪里?
谢谢。
sourceselect参数只影响recursion目录副本。 对于单个文件,您需要多个file资源,因为在这种情况下,只有第一个文件将被复制。
或者,recursion地提供目录时,可以通过将sourceselect属性设置为all来组合多个源。
( 来源 )
你的第二个问题是你告诉Puppet确保目标是一个目录。 在这种情况下,给源文件没有任何意义 – 你不能将文件保存为目录。 您需要将其设置为file或file 。
重申你的评论:像这样的东西应该工作:
file { ['/usr/lib64/nagios/plugins/check_mem.sh']: ensure => "file", notify => Service['nrpe'], source => "puppet:///modules/mymodule/check_mem.sh", } file { ['/usr/lib64/nagios/plugins/check_mountpoint.sh']: ensure => "file", notify => Service['nrpe'], source => "puppet:///modules/mymodule/check_mountpoint.sh", }