阅读背景:

等待条件Heat / CloudFormation和实例启动顺序

来源:互联网 

I have a OpenStack Heat template which borrows heavily from the CloudFormation parameters, which is why I added the CF tag.

我有一个OpenStack Heat模板,它大量借用了CloudFormation参数,这就是我添加CF标签的原因。

My template contains two instances which should be started (or at least configured through user-data) in a specific order. I thought I would use WaitCondition to make that happen but it looks like he doesn't fully work, or at least doesn't do what I expect.

我的模板包含两个应按特定顺序启动(或至少通过用户数据配置)的实例。我以为我会使用WaitCondition来实现这一点,但看起来他没有完全工作,或者至少没有做到我期望的事情。

Here's a snippet:

这是一个片段:

resources:
  first:
    type: OS::Nova::Server
    properties:
      key_name: { get_param: key_name }
      image: fedora19
      flavor: { get_param: instance_type }
      user_data:
        str_replace:
          template: |
              #!/bin/bash
              [configuration code here]
              curl -X PUT -H 'Content-Type:application/json' -d '{"Status" : "SUCCES", "Data" : "Application has completed configuration."}' "$wait_handle$"
          params:
            $wait_handle$: {get_resource: my_wait_handle}

  first_wait_handle:
    type: AWS::CloudFormation::WaitConditionHandle

  first_wait:
    type: AWS::CloudFormation::WaitCondition
    depends_on: first
    properties:
      Handle:
    get_resource: first_wait_handle
      Timeout: 1000

second:
    type: OS::Nova::Server
    depends_on: first_wait
    properties:
      key_name: { get_param: key_name }
      image: fedora19
      flavor: { get_param: instance_type }
      user_data: |
        #!/bin/bash
        [configuration code 2]

Currently the stack is correctly stuck on "create in progress" state while Heat hasn't received the curl signal back, which is correct. Problem is that the 'second' instance is created as soon as the stack is launched and configuration runs automatically.

目前堆栈正确地停留在“正在创建”状态,而Heat没有收到卷曲信号,这是正确的。问题是,一旦启动堆栈并且配置自动运行,就会创建“第二个”实例。

I added a depends_on in the second instance but it looks like it has no effect (or, again, not the effect I thought).

我在第二个实例中添加了一个depends_on,但看起来它没有效果(或者,再次,不是我认为的效果)。

Is it possible to do this instance startup order configuration with Heat/Cloud Formation? What am I missing?

是否可以使用Heat / Cloud Formation执行此实例启动顺序配置?我错过了什么?

Thanks!

谢谢!

2 个解决方案

#1


3  

Read this blog given here and he has given a correct explanation to your question. Because this functionality doesn't actually works. There is a work-around which you can make use of.

阅读此处提供的博客,他已经对您的问题给出了正确的解释。因为此功能实际上不起作用。您可以使用一种解决方法。

#2


1  

I'm not at all familiar with Heat templates, but the thing that immediately stood out is your curl command.

我对热模板并不熟悉,但立刻突出的是你的curl命令。

Change the curl command

更改curl命令

curl -X PUT -H 'Content-Type:' --data-binary '{"Status" : ....

I've had all sorts of problems signalling AWS with what's ostensibly JSON but doesn't accept a header with content-type: application/json

我有各种各样的问题,用表面上的JSON表示AWS,但是不接受带有内容类型的头文件:application / json


分享到: