example42 / puppi

Puppet module to manage applications deployments and servers local management
http://www.example42.com
Other
142 stars 84 forks source link

params_lookup on Puppet4 with subclass params #148

Closed Poil closed 7 years ago

Poil commented 7 years ago

Hi,

On Puppet 3.8 I have no problem with this module, but with Puppet 4 params_lookup return an empty string :

class zabbix::agent (
  $mirror_host         = params_lookup('mirror_host', 'global'),
  $listen_address      = params_lookup('listen_address'),
  $admin_address       = params_lookup('admin_address', 'global'),
  $proxies             = params_lookup('proxies'),
) inherits zabbix::agent::params {

  if empty($admin_address) {
    notify { 'empty': }
    $_listen_address = $listen_address ? {
      /^ipaddress_.*/ => get_magicvar($listen_address),
      default         => $listen_address
    }
  } else {
    notify { 'not empty': }
    $_listen_address = $admin_address ? {
      /^ipaddress_.*/ => get_magicvar($admin_address),
      default         => $admin_address
    }
  }

  notify { "admin_address: ${admin_address}": }
  notify { "listen_address: ${listen_address}": }
  notify { "_listen_address: ${_listen_address}": }
class zabbix::agent::params {
  $listen_address = $::ipaddress
}
Notice: empty
Notice: /Stage[main]/Zabbix::Agent/Notify[empty]/message: defined 'message' as 'empty'
Notice: admin_address: 
Notice: /Stage[main]/Zabbix::Agent/Notify[admin_address: ]/message: defined 'message' as 'admin_address: '
Notice: listen_address: 
Notice: /Stage[main]/Zabbix::Agent/Notify[listen_address: ]/message: defined 'message' as 'listen_address: '
Notice: _listen_address: 
Notice: /Stage[main]/Zabbix::Agent/Notify[_listen_address: ]/message: defined 'message' as '_listen_address: '
Notice: /Stage[main]/Sssd::Service/Service[messagebus]/ensure: ensure changed 'stopped' to 'running'

I think there is something broken on Puppet4 with value from ::classname::params

Any idea ? :)

Best regards,

Poil commented 7 years ago

I think I've got my answer :(

    # TODO: Set the correct classname when params_lookup used in subclasses
    classname = modulename
Poil commented 7 years ago

Ok I've got a quick fix, change this line with

classname = scope.namespaces.first