Ask Your Question
0

share data (IPs) between two OS::Nova::Server nodes

asked 2017-07-17 00:15:44 -0600

CRS gravatar image

Hi, I am creating two OS::Nova::Server node for Elasticsearch, say Node0 & Node1, I need to update config files of Node0 & Node1 with IPs of Node0 & Node1. How can I do that? I am trying something like this -

heat_template_version: 2014-10-16
description: |
  This will create an Elasticsearch cluster of 3 Elasticsearch nodes.

resources: 
  Node0:
    type: OS::Nova::Server
    properties:
      name: n0
      image: ubuntu16-ecomp.qcow2
      flavor: onap_large
      networks:
        - network: NET_1266
      user_data: |
        #!/bin/sh

        local_ip_1=`ifconfig eth0 | grep "inet addr" | cut -d ':' -f 2 | awk '{print $1}'`

        ip_arr="[ $local_ip_1, $local_ip_2 ]"

        sed -i "/network\.host/a network.host: $(echo $ip_arr)" /etc/elasticsearch/elasticsearch.yml

      user_data_format: RAW

  Node1:
    type: OS::Nova::Server
    properties:
      name: n1
      image: ubuntu16-ecomp.qcow2
      flavor: onap_large
      networks:
        - network: NET_1266
      user_data: |
        #!/bin/sh

        local_ip_2=`ifconfig eth0 | grep "inet addr" | cut -d ':' -f 2 | awk '{print $1}'`

        ip_arr="[ $local_ip_1, $local_ip_2 ]"

        sed -i "/network\.host/a network.host: $(echo $ip_arr)" /etc/elasticsearch/elasticsearch.yml

      user_data_format: RAW

As above, I need to share local_ip_1 & local_ip_2 between Node0 & Node1, how can I do? Please do not mind, I am completely new in HOT, I started today, I could not get much info in Google

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-17 09:14:14 -0600

zaneb gravatar image

You won't be able to do this using user_data, because the user_data is fixed at the time the server is created (and the IP addresses can't be obtained until after the server is created), so this would create a circular dependency.

What you can do is use an OS::Heat::SoftwareDeploymentGroup resource to deploy a SoftwareConfig to both servers, and you can use the IP addresses of the servers as an input to the SoftwareDeploymentGroup (using the {getattr: } intrinsic function.

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: 2017-07-17 00:15:44 -0600

Seen: 21 times

Last updated: Jul 17