-1
當文件內容沒有變化時,我想跳過某些exec和文件資源。其文件和業務組合...... 例如工作,當文件內容沒有變化時跳過傀儡函數
file { 'configfile.cfg':
ensure => file,
path => '/etc/configfile.cfg',
mode => '0644',
owner => 'root',
group => 'root',
content => template($template_file),
require => Package[$main_package],
notify => Service[$service],
}
service { $service:
ensure => $ensure,
enable => $enable,
hasrestart => true,
hasstatus => true,
require => [ Package[$main_package], File['configfile.cfg'] ],
}
上面的代碼工作正常。服務只有當它檢測到/etc/configfile.cfg任何變化重新啓動..
但我下面的文件和exec組合相同的方法,但它不工作....請看下面的代碼
exec { 'purge-config-files':
before => [File["${config_file_service}"], File["${config_file_host}"]],
command => "/bin/rm -f ${baseconfigdir}/*",
notify => Domain_ip_map[$domain_ip_map_titles],
}
file { 'deployconfig.cfg':
ensure => file,
path => '/home/path/deployconfig.cfg',
mode => '0644',
owner => 'root',
group => 'root',
content => "test",
notify => Exec['purge-config-files'],
}
此代碼不按預期方式工作。即使 /home/path/deployconfig.cfg中沒有更改,Exec ['purge-config-files']始終爲 正在執行......可能是因爲這個原因?