Project

General

Profile

Bug #14568

Default answers for undef parameters stored as ::module::params::param on Puppet 4

Added by Dominic Cleal over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

When Kafo determines default values for class parameters, any parameter that evaluates to undef is stored in the answers file as the parameter name when running under Puppet 4:

---
foreman:
  foreman_url: https://foreman.example.com
  selinux: '::foreman::params::selinux'
  locations_enabled: false
  organizations_enabled: false
  passenger_interface: '::foreman::params::passenger_interface'
  email_conf: email.yaml
  email_source: email.yaml.erb
  email_delivery_method: '::foreman::params::email_delivery_method'
  email_smtp_address: '::foreman::params::email_smtp_address'
  email_smtp_port: 25
  email_smtp_domain: '::foreman::params::email_smtp_domain'
  email_smtp_authentication: none
  email_smtp_user_name: '::foreman::params::email_smtp_user_name'
  email_smtp_password: '::foreman::params::email_smtp_password'

When Puppet runs, it fails with:

[ERROR 2016-04-08 21:38:26 main]  Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, email_delivery_method can be either sendmail or smtp, not ::foreman::params::email_delivery_method at /usr/share/foreman-installer/modules/foreman/manifests/init.pp:320:5 on node foreman.example.com

On Puppet 3, the answers file has the same parameter stored as nil:

---
  foreman:
    email_conf: email.yaml
    email_source: email.yaml.erb
    email_delivery_method:
    email_smtp_address:
    email_smtp_port: 25
    email_smtp_domain:
    email_smtp_authentication: none
    email_smtp_user_name:
    email_smtp_password:

Related issues

Blocks Foreman - Tracker #8447: Puppet 4 supportClosed2014-11-19

Associated revisions

Revision 5453fb75 (diff)
Added by Dominic Cleal over 5 years ago

fixes #14568 - don't pass any default value for undef class parameters

Under Puppet 4, dump_values returned the parameter name for any undef
values, as lookupvar now returned nil rather than :undef. This has been
removed so it simply returns nil in all cases.

Secondly, when instantiating classes with undef parameter values, don't
pass the parameter at all when it's nil (undef) to allow it to be
determined by Puppet. Passing an undef value causes the parameter to be
set to the value undef, rather than meaning "not set".

Revision c48c649a
Added by Marek Hulán over 5 years ago

Merge pull request #140 from domcleal/14568-undef-params

fixes #14568 - don't pass any default value for undef class parameters

History

#1 Updated by Dominic Cleal over 5 years ago

#2 Updated by Dominic Cleal over 5 years ago

The kafo dump_values function has changed behaviour between 3 and 4. On 3, lookupvar returns :undef for undef parameters, but on 4 it's returning nil.

dump_values has a conditional in it that returns the arg name if lookupvar's nil: found_value.nil? ? arg : found_value, causing the parameter name to be written into the value field. I'm unsure if this serves any useful purpose.

#3 Updated by Dominic Cleal over 5 years ago

  • Status changed from New to Assigned
  • Assignee set to Dominic Cleal

#4 Updated by Dominic Cleal over 5 years ago

A second, closely related issue is found when instantiating the Puppet classes using the answers file. When a nil class parameter is stored and passed to create_resources, it's passed and set to undef rather than then inheriting the default value of the class.

As an example, $::foreman::db_database defaults to the string 'UNSET':

class foreman (
  $db_database               = 'UNSET',

On Puppet 3, this is stored as a nil answer because it's not in the params class:

---
foreman:
  db_database:

And the loadanyyaml/convert function usually passes undef to the foreman class. This triggers the following in foreman::database::postgresql as Puppet sets the parameter to the default value, 'UNSET' when undef's passed:

  $dbname = $::foreman::db_database ? {
    'UNSET' => 'foreman',
    default => $::foreman::db_database,
  }

However under Puppet 4, undef actually gets passed in and causes this error:

[ERROR 2016-04-11 08:39:13 verbose]  Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Missing title. The title expression resulted in undef at /usr/share/foreman-installer/modules/foreman/manifests/database/postgresql.pp:20:28 on node foreman.example.com

#5 Updated by The Foreman Bot over 5 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/kafo/pull/140 added

#6 Updated by Dominic Cleal over 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF