想知道是否可以从两个不同的资源通知同一服务:
让我们说我有两个配置文件:
file { "${conf_dir}/1.conf" :
content => template('1.conf.erb'),
owner => $owner,
group => $group,
mode => '0777',
}
~>file { "${conf_dir}/2.conf" :
content => template('2.conf.erb'),
owner => $owner,
group => $group,
mode => '0777',
}
~> service { 'some_service' :
enable => true,
}
我不确定上面的代码是否会执行(因为'〜>'文件资源之间)
答案 0 :(得分:1)
您可以使用notify选项通知您的服务。
用你的例子:
file { "${conf_dir}/1.conf" :
content => template('1.conf.erb'),
owner => $owner,
group => $group,
mode => '0777',
notify => Service['some_service'],
}
file { "${conf_dir}/2.conf" :
content => template('2.conf.erb'),
owner => $owner,
group => $group,
mode => '0777',
notify => Service['some_service'],
}
service { 'some_service' :
enable => true,
}
答案 1 :(得分:1)
使用此:
File {
owner => $owner,
group => $group,
mode => '0777',
notify => Service['some_service'],
}
file {
"${conf_dir}/1.conf":
content => template("${module_name}/1.conf.erb");
"${conf_dir}/2.conf":
content => template("${module_name}/2.conf.erb"),
}
service { 'some_service':
enable => true,
}