只是提供一些细节 - 在 AWS 上构建,使用 Puppet 处理 DSC,并引导 Puppet 以便它在新配置的节点上配置和安装 Puppet。
我已经使用 Puppet 工作了一段时间,我发现自己想编写一个仅在创建 vm 时执行的模块。
我的特定用例是我想通过 Puppet 自动将防病毒软件(特别是 Trend Micro Deep Security)安装到新配置的节点上。
运行它的脚本只需要下载、运行和几个 TMDS 特定命令来激活自身等。
如果我使用 Puppet,它会在每次运行时执行此操作(下载、尝试安装、尝试激活),这绝对不是我想要的。
但是,我不认为 Puppet“知道”趋势科技,或者如何获取它,或者 URL 等。所以我不能使用类似的东西:
service { "trend micro":
ensure => running,
ensure => present,
}
做一些研究,看看博客文章,我知道我的代码结构应该是这样的(我知道这是不正确的):
exec {'function_name':
# the script that downloads/installs/activates etc.
command => '/path/to/script.sh',
onlyif => systemctl service_trendmicro,
# which system should return 0 or 1 for pass/fail - I only want it to exec on 0 ofc.
}
因此,我的问题是:我如何把它放在一起?