voxpupuli / puppet-zabbix

Puppet module for creating and maintaining zabbix components with puppet.
https://forge.puppet.com/puppet/zabbix
Apache License 2.0
80 stars 227 forks source link

Zabbix::Userparameters unable to find zabbix user/group on first run #205

Open bastelfreak opened 8 years ago

bastelfreak commented 8 years ago

Hi, my profile contains this:

  $zabbix_server_ip = hiera('zabbix_server_ip')
  $zabbix_agent_ip = hiera('zabbix_agent_ip', $ipaddr)
  class { '::zabbix::agent':
    manage_repo           => $zabbix_manage_repo,
    server                => $zabbix_server_ip,
    zabbix_package_state  => 'latest',
    zabbix_version        => '2.4',
    manage_resources      => false,
    serveractive          => $zabbix_server_ip,
    hostmetadata          => $::sach_type,
    listenip              => $zabbix_agent_ip,
  }
  # basic check for puppet agent
  zabbix::userparameters{'get_file_time.sh':
    script  => 'puppet:///modules/profiles/zabbix_userparams/get_file_time.sh',
  }
  zabbix::userparameters{'lld_bmdisks.rb':
    script  => 'puppet:///modules/profiles/zabbix_userparams/lld_bmdisks.rb',
  }
  file{'/etc/sudoers.d/zabbix-generic':
    content => "zabbix ALL = NOPASSWD: /bin/bash /usr/bin/get_file_time.sh\n",
    mode    => '0640',
    owner   => 'root',
    group   => 'root',
  }

results in:

Error: Could not set 'file' on ensure: Could not find user zabbix at 91:/etc/puppet/environments/production/modules/zabbix/manifests/userparameters.pp
Error: Could not set 'file' on ensure: Could not find user zabbix at 91:/etc/puppet/environments/production/modules/zabbix/manifests/userparameters.pp
Wrapped exception:
Could not find user zabbix
Error: /Stage[main]/Profiles::Rootserverconfig/Zabbix::Userparameters[lld_bmdisks.rb]/File[/usr/bin/lld_bmdisks.rb]/ensure: change from absent to file failed: Could not set 'file' on ensure: Could not find user zabbix at 91:/etc/puppet/environments/production/modules/zabbix/manifests/userparameters.pp
Error: Could not set 'file' on ensure: Could not find user zabbix at 91:/etc/puppet/environments/production/modules/zabbix/manifests/userparameters.pp
Error: Could not set 'file' on ensure: Could not find user zabbix at 91:/etc/puppet/environments/production/modules/zabbix/manifests/userparameters.pp
Wrapped exception:
Could not find user zabbix
Error: /Stage[main]/Profiles::Base/Zabbix::Userparameters[get_file_time.sh]/File[/usr/bin/get_file_time.sh]/ensure: change from absent to file failed: Could not set 'file' on ensure: Could not find user zabbix at 91:/etc/puppet/environments/production/modules/zabbix/manifests/userparameters.pp

using the latest commit of the module, zabbix 2.4, puppet 3.8.6.

bastelfreak commented 8 years ago

The quickest fix that came up my mind: The three file resources in the userparameter.pp should also require the user/group zabbix.

dj-wasabi commented 8 years ago

@bastelfreak You mean that the userparameter.pp should also create the zabbix user/group if it isn't created yet?

bastelfreak commented 8 years ago

AH, not directly, but thats a good idea and any maybe better than my own.

The user and group resurce is already in the moduke, I thought about using:

require => [User['zabbix'], Group['zabbix]]

in the userparameter.pp. But I'm not sure if this will create a dependency cycle, I had no time to test it. Maybe we could use create_resource() function here to define the user/group in the userparameter.pp as well.