Puppet 仅当另一个Exec运行时才运行Exec
如何将一个Exec配置为仅在另一个Exec运行时运行 我有这样一份清单:Puppet 仅当另一个Exec运行时才运行Exec,puppet,Puppet,如何将一个Exec配置为仅在另一个Exec运行时运行 我有这样一份清单: file { $target: ensure => directory } exec { "unzip foobar.zip -C ${target}": unless => "file ${target}/some-file-form-archive" } exec { "chown -R $user ${target}": onlyif => ??? } exec {
file { $target:
ensure => directory
}
exec { "unzip foobar.zip -C ${target}":
unless => "file ${target}/some-file-form-archive"
}
exec { "chown -R $user ${target}":
onlyif => ???
}
exec { 'fix archive':
command => "chown -R ${user} ${target}",
path => '/bin',
unless => "test 0 -eq $(find ${target} \\! -user ${user} | wc -l)"
}
我希望chown仅在解压缩foobar.zip时运行。当然,我可以开始检查归档文件中的某些文件是否已归$user所有,但不知何故,它似乎并不正确。这里已经有了答案: 像这样更改清单可以解决我的问题:
exec { 'unpack file':
command => "unzip foobar.zip -C ${target}",
path => '/usr/bin',
creates => "${target}/some-file-form-archive",
require => File[$target, '<archive>'],
notify => Exec[fix archive],
}
exec { 'fix archive':
command => "chown -R ${user} ${target}",
path => '/bin',
refreshonly => true,
}
通过这种方式,即使在解包文件运行后更改了$user,也可以确保所有者是$user。这里已经有了答案: 像这样更改清单可以解决我的问题:
exec { 'unpack file':
command => "unzip foobar.zip -C ${target}",
path => '/usr/bin',
creates => "${target}/some-file-form-archive",
require => File[$target, '<archive>'],
notify => Exec[fix archive],
}
exec { 'fix archive':
command => "chown -R ${user} ${target}",
path => '/bin',
refreshonly => true,
}
这样,即使在解包文件运行后更改了$user,所有者也将被确保为$user。是,尽管与您的直觉相反,通过除非检查权限实际上更干净。是,尽管与您的直觉相反,通过除非检查权限实际上更干净。