Curator environment variables for hosts

How can I specify a list of hosts for curator's config file using an environment variable? I have the following in my curator-config.yml:

client:
hosts: ${ELASTICSEARCH_HOSTS:127.0.0.1}

When I try something like:

$ ELASTICSEARCH_HOST=192.168.202.77,192.168.202.78,192.168.202.79 curator --config curator-config.yml

It times out. The debug output says that hosts gets set to one value in a list instead of three values, which seems wrong:

2018-04-10 15:40:18,700 DEBUG curator.utils get_client:803 kwargs = {'url_prefix': '', 'aws_secret_key': None, 'http_auth': None, 'certificate': None, 'aws_key': None, 'aws_sign_request': False, 'port': 9200, 'hosts': ['192.168.202.77, 192.168.202.78, 192.168.202.79'], 'timeout': 30, 'aws_token': None, 'use_ssl': False, 'master_only': False, 'client_cert': None, 'ssl_no_validate': False, 'client_key': None}

Is there a way to properly expand an environment variable into a list?

No, there is not. Your better bet is to have a single IP that points to a load balancing IP, or to deploy to all of your master eligible nodes, and set master_only: true in the client block. It will then only execute on the elected master node, and just exit without doing anything on the other nodes.

On a very odd chance this might work, you could have 3 environment variables:

client:
  hosts:
    - ${HOST1:127.0.0.1}
    - ${HOST2:127.0.0.1}
    - ${HOST3:127.0.0.1}

I've never tried this, but I can't imagine why this approach wouldn't work.

Thanks, pointing at a single IP is the strategy I settled on. I'm deploying curator in a docker container, and the de facto way of providing config to a container is via env vars (a la the official Elasticsearch containers)

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.