我正在使用 exec 命令运行一个 shell 脚本,该脚本修改其他包的某些配置文件。每当输入参数如 ip 地址、端口或 url 更改时,或者当 shell 脚本本身已更改时,都会触发 exec 命令。
我必须使用 shell 脚本,因为软件包的配置文件在不同版本之间略有不同。我认为更容易更新每个 sed 脚本的配置文件,而不是为每个特定版本提供不同的 puppet 模板。
但是此配置不会检测何时在 puppet 之外修改了任何配置文件。Puppet 不知道 shell 脚本修改过的文件。
我正在寻找的是一种使 exec 命令依赖于任意其他文件的校验和的方法:
exec { "my_command.sh":
only_if_file_has_changed => [
"/etc/mysoftware/config.xml",
"/etc/othersoftware/defaults",
]
}
Run Code Online (Sandbox Code Playgroud)
这可能吗?请指教。
fak*_*ker 11
它会像这样工作:
exec { 'my_command.sh':
command => '/bin/my_command.sh',
subscribe => [
File['/etc/mysoftware/config.xml'],
File['/etc/othersoftware/defaults'],
],
refreshonly => true,
}
Run Code Online (Sandbox Code Playgroud)
这里明显的限制是,文件/etc/mysoftware/config.xml
和 也/etc/othersoftware/defaults
必须通过 Puppet 进行更改。
如果它们被其他东西(Puppet 外部)改变,请参阅 Felix 的回答。
当然,您也可以订阅Package['xxx']
或任何其他更合适的依赖项。
Puppet 可以通过它的审计元参数来解决这个问题。
file { [ "/etc/mysoftware/config.xml",
"/etc/othersoftware/defaults" ]:
audit => 'content',
notify => Exec['my_command'],
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16124 次 |
最近记录: |