Ask Your Question
0

OpenStack heat get ResourceGroup ip address and set to params

asked 2019-06-19 11:07:23 -0500

dommgifer gravatar image

updated 2019-06-19 11:07:41 -0500

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}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-06-20 08:45:18 -0500

zaneb gravatar image

I don't see any reason your template shouldn't work, but a simpler way than using str_replace would be to define an input to your software config and pass the value to the deployment:

 get_ip:
    type: OS::Heat::SoftwareConfig
    properties:
      group: script
      inputs:
        - name: minion_group_ip
      config: 
          #!/bin/bash
          echo ${minion_group_ip} > /opt/ip.txt

 deployment:
    type: OS::Heat::SoftwareDeployment
    properties:
      signal_transport: HEAT_SIGNAL
      config: {get_resource: get_ip}
      server: {get_resource: master}
      input_values:
        minion_group_ip: {get_attr: [minion_group, first_address]}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2019-06-19 11:07:23 -0500

Seen: 34 times

Last updated: Jun 20