【发布时间】:2019-09-14 01:05:47
【问题描述】:
我在 init.pp 中有一个共享的 puppet 重启块,并且还希望有一个 $autorestart 的全局参数,默认为 false,因此重启是全局选择的。在一个子类中,我有一些资源,例如 file_line 更改设置,这些设置通常在重新启动之前不会生效,但这些不会设置需要重新启动的操作系统标志(例如写入 audit.rules 或 sysctl.conf),所以将这些设置为通知 => Reboot[after_run]。
我知道某些子类功能可以在服务重新启动时生效,但这不是我在这里尝试做的,例如 auditd 是受保护的服务。
我尝试将全局重新启动资源放在“if $autorestart”块中,但是如果全局 $autorestart 设置为 false,则子类资源上的通知无法编译。我试图让这个尽可能灵活而简单。
init.pp:
Boolean $autorestart = false,
…
if $autorestart {
reboot { 'after_run':
apply => 'finished',
timeout => 60,
}
}
子类.pp:
file_line { 'net.ipv6.conf.all.disable_ipv6':
path => '/etc/sysctl.conf',
line => 'net.ipv6.conf.all.disable_ipv6 = 1',
match => '^net.ipv6.conf.all.disable_ipv6.*',
notify => Reboot['after_run'],
}
错误
Could not find resource 'Reboot[after_run]' in parameter 'notify'
我也尝试过 puppet-reboot 'onlyif' 参数,但它只接受某些条件并且不测试参数的值。 https://forge.puppet.com/puppetlabs/reboot#reboot-when-certain-conditions-are-met
任何帮助表示赞赏。
【问题讨论】:
标签: if-statement puppet reboot