仅在输出文件已更改时才运行puppet exec命令

我正在使用exec命令来运行修改其他软件包的某些configuration文件的shell脚本。 只要input参数(如IP地址,端口或url)发生更改,或者shell脚本本身已更改,则会触发exec命令。

我必须使用shell脚本,因为软件包的configuration文件在版本之间略有不同。 我认为更新每个sed脚本的configuration文件比更简单,而不是为每个特定版本提供不同的puppet模板。

但是这个configuration不检测任何configuration文件在puppet之外被修改的时间。 木偶不知道shell脚本修改过的文件。

我正在寻找的是一种使exec命令依赖于任意其他文件的校验和的方法:

exec { "my_command.sh": only_if_file_has_changed => [ "/etc/mysoftware/config.xml", "/etc/othersoftware/defaults", ] } 

这可能吗? 请指教。

木偶可以通过审计元参数来解决这个问题。

 file { [ "/etc/mysoftware/config.xml", "/etc/othersoftware/defaults" ]: audit => 'content', notify => Exec['my_command'], } 

它会这样工作:

 exec { 'my_command.sh': command => '/bin/my_command.sh', subscribe => [ File['/etc/mysoftware/config.xml'], File['/etc/othersoftware/defaults'], ], refreshonly => true, } 

这里明显的约束是,文件/etc/mysoftware/config.xml/etc/othersoftware/defaults必须通过Puppet进行更改。
如果它们被别的东西(Puppet外部)所改变,请参阅Felix的答案。
当然你也可以订阅Package['xxx']或其他任何更合适的依赖关系。