【发布时间】:2019-05-17 20:56:50
【问题描述】:
我想知道以下 CloudFormation 代码的 bash 等效项。
ServerLaunchConfiguration:
Type: AWS::AutoScaling::LaunchConfiguration
Metadata:
AWS::CloudFormation::Init:
configSets:
install_all:
- install_cfn
install_cfn:
..some important staff..
services:
sysvinit:
cfn-hup:
enabled: 'true'
ensureRunning: 'true'
files:
- /etc/cfn/cfn-hup.conf
- /etc/cfn/hooks.d/cfn-auto-reloader.conf
我希望 services 部分由 bash 脚本完成,因为在它执行时,文件 /etc/cfn/cfn-hup.conf 和 / etc/cfn/hooks.d/cfn-auto-reloader.conf 不存在。我将它们创建为 UserData 的一部分。我知道它们可以并且可能应该由 Init 中的 files 创建。
当我运行命令时:
systemctl status cfn-hup.service
我明白了:
已加载:已加载(/etc/rc.d/init.d/cfn-hup;坏;供应商预设: 禁用)活动:失败(结果:退出代码)
这是可以预见的,因为这些文件在尝试时不存在。但我实际上可以稍后使用service cfn-hup start 成功启动此服务。
问题:
当我将这些 服务 保留原样,然后在创建 .conf 文件后,我将调用:service cfn-hup start?
【问题讨论】:
标签: amazon-ec2 amazon-cloudformation