Revision history [back]

click to hide/show revision 1
initial version

OpenStack heat get ResourceGroup ip address and set to params

0

Create 1 master instance node and 2 minion instances from heat template.

I want to write minion_group all instances ip addresses into master instance ip.txt file.

The minion group ip addresses get from {get_attr: [minion_group, first_address] }

but this type return was not string.

So it can't use str_replace.

Does anyone have ideas?

Here is my template about resource section:

resources:
  master:
    type: OS::Nova::Server
    depends_on: minion_group
    properties:
      flavor: {get_param: master_flavor}
      image: {get_param: image}
      key_name: {get_param: key}
      networks: 
        - port: {get_param: network}
      user_data_format: SOFTWARE_CONFIG      

  minion_group:
    type: OS::Heat::ResourceGroup
    properties:
      count: 2
      resource_def:
        type: OS::Nova::Server
        properties:
         name: 
           list_join:
             - '-'
             - [{ get_param: 'OS::stack_name' }, 'minion', '%index%']
         flavor: {get_param: minion_flavor}
         image: {get_param: image}
         key_name: {get_param: key}
         networks:
           - network: {get_param: network}

 get_ip:
    type: OS::Heat::SoftwareConfig
    properties:
      group: script
      config: 
        str_replace:
          template: |
            #!/bin/bash
            echo ${minion_group_ip} > /opt/ip.txt
          params:
            $minion_group_ip: {get_attr: [minion_group, first_address] }

 deployment:
    type: OS::Heat::SoftwareDeployment
    properties:
      signal_transport: HEAT_SIGNAL
      config: {get_resource: get_ip}
      server: {get_resource: master}

OpenStack heat get ResourceGroup ip address and set to params

0

Create 1 master instance node and 2 minion instances from heat template.

I want to write minion_group all instances ip addresses into master instance ip.txt file.

The minion group ip addresses get from {get_attr: [minion_group, first_address] }

but this type return was not string.

So it can't use str_replace.

Does anyone have ideas?

Here is my template about resource section:

resources:
  master:
    type: OS::Nova::Server
    depends_on: minion_group
    properties:
      flavor: {get_param: master_flavor}
      image: {get_param: image}
      key_name: {get_param: key}
      networks: 
        - port: {get_param: network}
      user_data_format: SOFTWARE_CONFIG      

  minion_group:
    type: OS::Heat::ResourceGroup
    properties:
      count: 2
      resource_def:
        type: OS::Nova::Server
        properties:
         name: 
           list_join:
             - '-'
             - [{ get_param: 'OS::stack_name' }, 'minion', '%index%']
         flavor: {get_param: minion_flavor}
         image: {get_param: image}
         key_name: {get_param: key}
         networks:
           - network: {get_param: network}

 get_ip:
    type: OS::Heat::SoftwareConfig
    properties:
      group: script
      config: 
        str_replace:
          template: |
            #!/bin/bash
            echo ${minion_group_ip} > /opt/ip.txt
          params:
            $minion_group_ip: {get_attr: [minion_group, first_address] }

 deployment:
    type: OS::Heat::SoftwareDeployment
    properties:
      signal_transport: HEAT_SIGNAL
      config: {get_resource: get_ip}
      server: {get_resource: master}