Foreman as ENC for Puppet

Attempting to use Foreman as an ENC for Puppet. I set up a hostgroup and a smart class parameter that matches to that hostgroup, yet puppet doesn’t seem to catch this parameter.

Expected outcome:
Puppet sees the class parameter and applies the override value supplied in the smart class parameter

Foreman and Proxy versions:

Foreman and Proxy plugin versions:

Other relevant data:
[e.g. logs from Foreman and/or the Proxy, modified templates, commands issued, etc]
(for logs, surround with three back-ticks to get proper formatting, e.g.)

2018-12-06 08:25:13,489 ERROR [qtp1401428088-68] [puppetserver] Puppet Evaluation Error: Error while evaluating a Resource Statement, Class[Ntp_chrony]: has no parameter named 'servers' on node <name>

The parameter is clearly defined for that node in Foreman. Logs on the Foreman side look to be ok as well, no errors.

If you go to the UI and open the host detail page there is a YAML button. That shows the ENC and should display the class and its parameters. Do you see it there?

Note that a Puppet ENC can only send classes and its parameters + global parameters. It’s not full data binding like Hiera. This is an ENC limitation. We have no Hiera data provider backend.

Yes I see the class and parameter value there in the YAML output.

Are you also sure the manifest on the puppet server actually has the parameter servers? Sometimes manifests change on the puppet server and you need to import them in Foreman.

Interesting. I imported the environment, now the hostgroup doesn’t have the smart class parameter defined anymore; the host now has the class defined in the YAML output, but not the override values.

The smart class parameter is set up to match on the hostgroup name, yet looking into the host group I no longer see that smart class parameter defined.

Ok, maybe this can be marked as ‘not a problem’ or ‘solved’?

Once I imported the puppet environment, I was able to set the smart class parameter for the host group and added the class into the host group’s puppet classes as expected. I was also able to see this attribute in the host’s YAML output.

After this the puppet run gave the following error:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Duplicate declaration: Class[Ntp_chrony] is already declared at (file: /etc/puppetlabs/code/environments/test/manifests/site.pp, line: 31); cannot redeclare on node

After this I removed the class from the puppet server’s site.pp and it now works as intended. So it seems that this is the workflow that worked for me:

  1. Import classes/environments from Puppet.
  2. Set smart class parameters and add the class to the host group
  3. Remove the class from Puppet’s site manifest as to not have duplicate class declarations.

Is this is intended / expected workflow, or am I misunderstanding something?

That sounds correct. In general using a site.pp to assign classes to nodes is not recommended when using an ENC since they both aim to achieve the same goal.