Puppet Exec不会仅在刷新时运行



我有一个测试程序

$oracle_gi_home = '/opt/gi/19.14'
$listener_name = 'LISTENER'
concat { '/tmp/test/tmp.file':
ensure => present,
}
concat::fragment { 'Add tmp file':
target  => '/tmp/test/tmp.file',
content => 'This is a new test 2',
notify => Exec['Restart listener'],
}
exec { 'Restart listener':
command     => "${oracle_gi_home}/bin/srvctl status ${listener_name}",
user        => 'oracle',
group       => 'oinstall',
cwd         => $oracle_base,
environment => ["ORACLE_HOME=${oracle_gi_home}"],
timeout     => 0,
logoutput   => true,
refreshonly => true,
}

我在调试中收到一条奇怪的消息,说Exec不会因为refreshonly失败而执行?文件已更新??

Notice: /Stage[main]/Main/Concat[/tmp/test/tmp.file]/File[/tmp/test/tmp.file]/content: content changed '{md5}f4378e6270895e6f3549c314c70c47e3' to '{md5}b46e769a18b468bdf1b60166ed4d5548'
Debug: /Stage[main]/Main/Concat[/tmp/test/tmp.file]/File[/tmp/test/tmp.file]: The container Concat[/tmp/test/tmp.file] will propagate my refresh event
Debug: /Stage[main]/Main/Concat[/tmp/test/tmp.file]/File[/tmp/test/tmp.file]: The container /tmp/test/tmp.file will propagate my refresh event
Debug: /tmp/test/tmp.file: The container Concat[/tmp/test/tmp.file] will propagate my refresh event
Debug: Concat[/tmp/test/tmp.file]: The container Class[Main] will propagate my refresh event
Debug: /Stage[main]/Main/Exec[Restart listener]: '/opt/gi/19.14/bin/srvctl status LISTENER' won't be executed because of failed check 'refreshonly'
Debug: Class[Main]: The container Stage[main] will propagate my refresh event

我尝试订阅,通知

Concat资源表示整个文件。通常,应该建立关系的是这种资源,而不是任何贡献的Concat::Fragment。从语义上来说,这通常是正确的做法,因为很少只与较大文件的一个部分建立关系。从技术角度来看,由于Concat模块的实现细节,它也变得更加可靠。

在这种特殊情况下,这意味着将notify置于Concat[/tmp/test/tmp.file]上。在碎片上也有一个并不一定是错误的,但这是多余的。结果:

concat { '/tmp/test/tmp.file':
ensure => present,
notify => Exec['Restart listener'],
}
concat::fragment { 'Add tmp file':
target  => '/tmp/test/tmp.file',
content => 'This is a new test 2',
}
exec { 'Restart listener':
command     => "${oracle_gi_home}/bin/srvctl status ${listener_name}",
user        => 'oracle',
group       => 'oinstall',
cwd         => $oracle_base,
environment => ["ORACLE_HOME=${oracle_gi_home}"],
timeout     => 0,
logoutput   => true,
refreshonly => true,
}

最新更新