Elasticsearch Puppet Error

Hi,

I'm having the following issue below. Note that I'm running puppet 3.x, I bring that up because I'm modifying a hash in the code below. I'm doing that because of time constraints, we are demoing at the end of this month. That part (line 2 below) will be updated later so please don't focus on that.

Thanks!

# This is for puppet 3.x

$es_config                 = hiera_hash('elasticsearch.config')
$es_config['network.host'] = "['${hostname}','_local_']"
$proxy_addr                = hiera('proxy.url')
$es_rpm_url                = hiera('es.rpm.url')

class { 'elasticsearch':
        package_url       => $es_rpm_url,
        proxy_url         => $proxy_addr,
      }->
      elasticsearch::instance { "${es_instance_name}":
        init_defaults => hiera_hash('elasticsearch.init_defaults'),
        config        => $es_config
      }

————

The following gets written to /etc/elasticsearch/instancename/elasticsearch.yml:
### MANAGED BY PUPPET ###
---
discovery:
  zen:
    ping:
      multicast:
        enabled: false
elasticsearch:
  node:
    local: true
http:
  cors:
    allow-credentials: true
    allow-origin: /.*/
    enabled: true
  max_header_size: 24kb
network:
  host: ["myhost","_local_"]

node:
  name: myhost-es-01
path:
  data: /usr/share/elasticsearch/data/es-01

transport:
  host:

——————

After puppet finishing running elasticsearch will be installed correctly and it will launch the elasticsearch service correctly.
Any additional puppet run will cause the following error:

Error: Could not retrieve local facts: syntax error on line 17, col 36: `  host: ["myhost","_local_"]'
Error: Failed to apply catalog: Could not retrieve local facts: syntax error on line 17, col 36: `  host: ["myhost","_local_"]'

How can I make the elasticsearch puppet module write the network.host array like this:

'''
network:
host:
- myhost
- local
'''

@tylerjl

Hi @cpitzak, the first thing I'd suggest is defining your list for network.host as a native puppet array rather than a static string. Your config is outputting

["myhost","_local_"]

Because that's the literal string you've defined in:

$es_config['network.host'] = "['${hostname}','_local_']"
1 Like

@tylerjl thanks, that worked!