On Tuesday, April 22, 2014 11:40:08 AM UTC-5, Chris Neal wrote:
>
> Hi all,
>
> This is most likely a noob question, so I apologize.  I've googled as well 
> and was not able to find an answer to this seemingly basic question.
> I'm using Puppet Enterprise 3.1.2 along with this module to install/manage 
> Elasticsearch:  
> https://forge.puppetlabs.com/elasticsearch/elasticsearch/0.2.3
>
> I've added the elasticsearch class to my node definition, and when I try 
> and pass the hash to the 'config' variable, my runs fail with various 
> errors about the parameter being a string, not a hash.  
>
> I've tried:
>
>  class { 'elasticsearch':
>    config                   => {
>      'node'                 => {
>        'name'               => 'elasticsearch001'
>      },
>      'index'                => {
>        'number_of_replicas' => '0',
>        'number_of_shards'   => '5'
>      },
>      'network'              => {
>        'host'               => $::ipaddress
>      }
>    }
>  }
>
> [...]

 

> All result in something like this:
>
> ====================
> Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
> " config => { 'node' => { 'name' => 'elasticsearch001' }, 'index' => { 
> 'number_of_replicas' => '0', 'number_of_shards' => '5' }, 'network' => { 
> 'host' => $::ipaddress } }" is not a Hash. It looks to be a String at 
> /etc/puppetlabs/puppet/modules/elasticsearch/manifests/init.pp:242 on node 
> n6.example.com 
>
>

Differences in whitespace are not significant in Puppet manifests, so as 
far as I can tell, all your attempts are equivalent.  I don't see anything 
wrong with them as such, but perhaps the context in which that declaration 
appears is causing the issue.  Or maybe the keys should be unquoted.  
Following PL examples (
http://docs.puppetlabs.com/puppet/3/reference/lang_datatypes.html#hashes), 
I don't quote my hash keys, but the docs do say they are strings, so I 
would expect quoting them to be valid.

Does that declaration appear, in that form, in a manifest file somewhere?  
(If not, then please tell us what you are really doing.)  If putting the 
example declaration, verbatim, into a Puppet class and assigning that class 
to a node causes the compilation of the node's catalog to fail, then I'm 
sure PL would appreciate a bug report.  In the mean time, you could 
consider assigning the hash to a class variable of the containing class, 
and using that to configure Class['elasticsearch']:

$search_config = {
  node    => {
    name => 'elasticsearch001'
  },
  index   => {
    numberofreplicas => '0',
    numberofshards   => '5'
  },
  network => {
    host  => $::ipaddress
  }
}

class { 'elasticsearch':
  config => $search_config
}


Really, though, it would be much better form to to externalize the data -- 
i.e. to store the config hash in an Hiera data store under key 
'elasticsearch::config'.  (If you do that then remember to format the hash 
appropriately for the relevant Hiera back-end.)



John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/80f2036a-d437-4f4e-80b5-a39b3973d9d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to