gpt4 book ai didi

amazon-web-services - Cloudformation 堆栈在执行所有用户数据之前显示为完整

转载 作者:行者123 更新时间:2023-12-03 23:15:52 25 4
gpt4 key购买 nike

在我的cloudformation堆栈中,我有一个启动配置,它在用户数据中运行ansible脚本。这里的问题是,即使 ansible 脚本尚未完成执行,我的堆栈状态也显示 CREATE_COMPLETE 。在我 ssh 进入 ec2 实例后,我看到日志显示 ansible 执行仍在进行中。我的示例 cloudformation 堆栈 json 是这样的:

"OpenShiftMasterASLaunchConfig": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Metadata": {
"AWS::CloudFormation::Init": {
"configSets": {
"quickstart": ["GetPublicKey", "AddPublicKey", "rpms", "ConfigSSHD", "DockerGroup", "DockerSecurity", "InstallAWSCLI", "SetPrivateKey", "StartServices"]
},
"rpms": {
"packages": {
"yum": {
"epel-release": [],
"NetworkManager": [],
"ansible": [],
"docker": [],
"git": [],
"python-boto": [],
"python-cryptography": [],
"python-lxml": [],
"python-pip": [],
"origin-docker-excluder": [],
"centos-release-openshift-origin": [],
"atomic-openshift-utils": [],
"origin-clients": [],
"awslogs" : []
}
}
},
"Properties": {
"AssociatePublicIpAddress" : "true",
"KeyName": {
"Ref": "KeyPairName"
},
"ImageId": {
"Fn::FindInMap": [
"AWSAMIRegionMap",
{
"Ref": "AWS::Region"
},
"CENTOS7HVM"
]
},
"BlockDeviceMappings": [{
"DeviceName": "/dev/sda1",
"Ebs": {
"VolumeSize": "100"
}
}],
"InstanceMonitoring": "true",
"IamInstanceProfile": {
"Ref": "SetupRoleProfile"
},
"InstanceType": {
"Ref": "MasterInstanceType"
},
"SecurityGroups": [{
"Ref": "OpenShiftSecurityGroup"
}],
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"", [
"bash /local/scripts/openshift-origin-bootstrap-master.sh\n",

"ansible-playbook -i /local/ansible/inventory/hosts.cluster /local/openshift-ansible/playbooks/prerequisites.yml >> /local/prereq.log\n",

"ansible-playbook -i /local/ansible/inventory/hosts.cluster /local/openshift-ansible/playbooks/deploy_cluster.yml -vvv > /local/cluster.log\n",

"bash /local/scripts/configure_openebs.sh\n"
]
]
}
}
}

这只是一个示例来说明。当堆栈显示已完成时,此处的 ansible-playbook 命令仍在执行中。有什么方法可以延迟堆栈上的创建条件,以确保首先执行所有用户数据。我尝试使用等待条件,但它没有给出所需的结果。

最佳答案

关联 CreationPolicy与您的资源进行交互,以防止其状态达到“创建完成”,直到您的用户数据脚本向 CloudFormation 发出信号(在用户数据末尾)。这是 example .

关于amazon-web-services - Cloudformation 堆栈在执行所有用户数据之前显示为完整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50877978/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com