I'm trying to get a list of hostnames to populate an array from the Foreman 
function.  We have servers that are dedicated to clients and 
non-production.  We use naming {clientid}-{server_type}.  So for example, 
test1-search001, test1-search002, test2-search001, test2-search003, 
client1-search001, client1-search002.

With my code below, I'm able to get back what appears to be json with the 
following error.  Line 111 is the discovery.zen.ping.unicast.hosts line.

  $search_hostnames = "${clientid}-search"

  $f = { 
    item           => 'fact_values',
    search         => "${search_hostnames}",
    filter_results => 'fact = hostname',
    per_page       => '20',
    foreman_user   => "${puppet_user}",
    foreman_pass   => "${puppet_pass}"
  }

  $hostlist = foreman($f)

  file { '/root/search.txt':
    ensure   => present,
    content  => "${hostlist}",
  }

  elasticsearch::instance { $hostname:
    config                                => {
      'node.name'                         => $hostname,
      'network.host'                      => '0.0.0.0',
      'path.data'                         => '/opt/elastic/search',
      'discovery.zen.ping.unicast.hosts'  => ${hostlist},
    },  
  }

Notice: Local environment: 'production' doesn't match server specified node 
environment 'test', switching agent to 'test'.
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: 
Server Error: Syntax error at '}' at 
/etc/puppetlabs/code/modules/fm_search/manifests/init.pp:111:56 on node 
test-search001.useast.mydomain.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run


{total => 0, subtotal => 4, page => 1, per_page => 20, search => 
test-search, sort => {by => , order => }, results => 
{test-search001.useast.mydomain.com => {networking::hostname => 
test-search001, hostname => test-search001, networking::fqdn => 
test-search001.useast.mydomain.com, clientcert => 
test-search001.useast.mydomain.com, fqdn => 
test-search001.useast.mydomain.com}, test-search002.useast.mydomain.com => 
{hostname => test-search002, networking::hostname => test-search002, 
clientcert => test-search002.useast.mydomain.com, fqdn => 
test-search002.useast.mydomain.com, networking::fqdn => 
test-search002.useast.mydomain.com}, test-search003.useast.mydomain.com => 
{hostname => test-search003, networking::hostname => test-search003, fqdn 
=> test-search003.useast.mydomain.com, networking::fqdn => 
test-search003.useast.mydomain.com, clientcert => 
test-search003.useast.mydomain.com}, test-search004.useast.mydomain.com => 
{hostname => test-search004, networking::hostname => test-search004, fqdn 
=> test-search004.useast.mydomain.com, clientcert => 
test-search004.useast.mydomain.com, networking::fqdn => 
test-search004.useast.mydomain.com}}}

-- 
You received this message because you are subscribed to the Google Groups 
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to foreman-users+unsubscr...@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to