0

I'm having problem when migrating the puppet code from puppet 3 to puppet 6.

This is the error message:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Failed to parse template puppetserver/var/test.sh.erb:
  Filepath: /opt/puppetlabs/environments/production/modules/puppetserver/templates/var/test.sh.erb
  Line: 21
  Detail: undefined method `join' for nil:NilClass
Did you mean?  JSON
 (file: /opt/puppetlabs/environments/production/modules/puppetserver/manifests/config.pp, line: 38, column: 16) on node test.domain

/opt/puppetlabs/environments/production/modules/puppetserver/templates/var/test.sh.erb:

...
for environment in <%= @pup_environments_array.join(' ') %>; do
this that
...

In my hieradata JSON:

//test.domain
{
  "puppetserver::working::environments": {
    "production": {
      "ensure": "present",
    },
    "staging": {
      "ensure": "present"
    }
  }
}

In /opt/puppetlabs/environments/production/modules/puppetserver/manifests/config.pp:

class puppetserver::config {
  file {'/var/test.sh.erb':
    ensure  => file,
    owner   => 'puppet',
    group   => 'puppet',
    content => template('puppetserver/var/test.sh.erb'),
  }
}

In /opt/puppetlabs/environments/production/modules/puppetserver/manifests/init.pp:

class puppetserver (
) inherits puppetserver:params {
  $pup_environments= hiera_hash('puppetserver::working::environments',{})
  $pup_environments_array = keys($pup_environments)
  include puppetserver::config
}
  • puppetserver: 6.0.2
  • puppet-agent: 6.0.4

That code is working fine on puppet 3 but not puppet 6. Can anyone please let me know the reason and how to fix it?

Thank you

Diamond
  • 1
  • 1

1 Answers1

0

OK. I got the answer myself.

The code:

file {'/var/test.sh.erb':
  ensure  => file,
  owner   => 'puppet',
  group   => 'puppet',
  content => template('puppetserver/var/test.sh.erb'),
}

needs to be on /opt/puppetlabs/environments/production/modules/puppetserver/manifests/init.pp not /opt/puppetlabs/environments/production/modules/puppetserver/manifests/config.pp

On puppet 3 I didn't split to many manifests.

Diamond
  • 1
  • 1