我正在尝试在ubuntu中安装aws-cfn-bootstrap,但是在运行update-rc.d时出现了错误
“ insserv:警告:脚本'K01cfn-hup'缺少LSB标签和替代 insserv:警告:脚本'cfn-hup'缺少LSB标签和替代”。 还有一个问题是,即使创建了计划的操作,在创建堆栈后我也看不到它。
Resources:
LConfig:
Type: "AWS::AutoScaling::LaunchConfiguration"
Metadata:
AWS::CloudFormation::Init:
configSets:
c_install: [cfn_installation, check_instance_health]
cfn_installation:
files:
/etc/cfn/cfn-hup.conf:
content: !Sub |
[main]
stack=${AWS::StackId}
region=${AWS::Region}
mode: '000400'
owner: root
group: root
/etc/cfn/hooks.d/cfn-auto-reloader.conf:
content: !Sub |
[cfn-auto-reloader-hook]
triggers=post.update
path=Resources.LConfig.Metadata.AWS::CloudFormation::Init
action=/usr/local/bin/cfn-init -v --stack ${AWS::StackName} --resource LConfig --configsets c_install --region ${AWS::Region}
runas=root
#systemd service
/etc/systemd/system/cfn-hup.service:
content: |
[Unit]
Description=CloudFormation Helper Daemon
After=syslog.target network.target
ConditionPathExists=/usr/local/bin/cfn-hup
[Service]
ExecStart=/usr/local/bin/cfn-hup
Restart=on-failure
Type=simple
# output goes to /var/log/syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=cfnhelper
[Install]
WantedBy=multi-user.target
commands:
enable-cfn-hup:
command: "systemctl enable cfn-hup.service"
start-cfn-hup:
command: "systemctl start cfn-hup.service"
check_instance_health:
commands:
SayHello:
command: "echo hello"
files:
/tmp/test.txt:
content: Hello world!
mode: '0755'
owner: root
group: root
Properties:
AssociatePublicIpAddress: yes
EbsOptimized: false
ImageId:
Ref: AMI
InstanceMonitoring: false
InstanceType:
Ref: IType
KeyName:
Ref: SSHKey
LaunchConfigurationName: !Sub '${ENVNAME}'
SecurityGroups:
- Ref: SGIDEC2
- Ref: SGIDRDS
- Ref: SGIDELB
UserData:
'Fn::Base64': !Sub |
#!/bin/bash -xe
PROMPTNAME=${ENVNAME}
apt-get update -y
apt-get -y install python-pip
pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
ln -s /usr/local/bin/cfn-hup /etc/init.d/cfn-hup
update-rc.d cfn-hup defaults
/usr/local/bin/cfn-init -v --stack ${AWS::StackName} --resource LConfig --configsets c_install --region ${AWS::Region}
/usr/local/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource ASGroup --region ${AWS::Region}
ASGroup:
Type: "AWS::AutoScaling::AutoScalingGroup"
CreationPolicy:
AutoScalingCreationPolicy:
MinSuccessfulInstancesPercent: 50
ResourceSignal:
Timeout: PT10M
Count: '1'
UpdatePolicy:
AutoScalingReplacingUpdates:
WillReplace: 'true'
AutoScalingRollingUpdates:
MinInstancesInService: 1
MaxBatchSize: 1
PauseTime: PT10M
WaitOnResourceSignals: 'true'
Properties:
AutoScalingGroupName: !Sub '${ENVNAME}'
Cooldown: 10
DesiredCapacity:
Ref: DESIRED
HealthCheckGracePeriod: 600
HealthCheckType:
Ref: HEALTHTYPE
LaunchConfigurationName: !Ref 'LConfig'
MaxSize:
Ref: MAXIMUM
MinSize:
Ref: MINIMUM
TerminationPolicies:
- OldestInstance
- OldestLaunchConfiguration
- Default
VPCZoneIdentifier:
- !Ref SUBNET1
- !Ref SUBNET2
- !Ref SUBNET3
Tags:
- Key: Name
Value:
Ref: AWS::StackName
PropagateAtLaunch: 'true'
ScheduledActionDown:
Type: "AWS::AutoScaling::ScheduledAction"
Properties:
AutoScalingGroupName: !Ref "ASGroup"
MaxSize: !Ref ScheduledDownMaxSize
MinSize: !Ref ScheduledDownMinSize
Recurrence: !Ref ScheduledDownRecurrence
ScheduledActionUp:
Type: "AWS::AutoScaling::ScheduledAction"
Properties:
AutoScalingGroupName: !Ref "ASGroup"
MaxSize: !Ref ScheduledUpMaxSize
MinSize: !Ref ScheduledUpMinSize
Recurrence: !Ref ScheduledUpRecurrence