Project

General

Profile

Actions

Bug #14568

closed

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

Added by Dominic Cleal almost 8 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Difficulty:
Triaged:
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 1 (0 open1 closed)

Blocks Foreman - Tracker #8447: Puppet 4 supportClosed11/19/2014

Actions
Actions #1

Updated by Dominic Cleal almost 8 years ago

Actions #2

Updated by Dominic Cleal almost 8 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.

Actions #3

Updated by Dominic Cleal almost 8 years ago

  • Status changed from New to Assigned
  • Assignee set to Dominic Cleal
Actions #4

Updated by Dominic Cleal almost 8 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
Actions #5

Updated by The Foreman Bot almost 8 years ago

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

Updated by Dominic Cleal almost 8 years ago

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

Also available in: Atom PDF