Defined Type: zabbix::startup

Defined in:
manifests/startup.pp

Summary

This manage the zabbix related service startup script.

Overview

Examples:

zabbix::startup { 'agent': }
zabbix::startup { 'server': }

Parameters:

  • pidfile (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Location of the PID file

  • agent_configfile_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Location of Zabbix’s agent configuration file

  • server_configfile_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Location of Zabbix’s server configuration file

  • database_type (Optional[Zabbix::Databases]) (defaults to: undef)

    Type of database. Can use the following 2 databases:

    • postgresql

    • mysql

  • zabbix_user (Optional[String]) (defaults to: undef)

    User the zabbix service will run as

  • additional_service_params (Optional[String[1]]) (defaults to: undef)

    Additional parameters to pass to the service

  • service_type (String) (defaults to: 'simple')

    Systemd service type

  • manage_database (Optional[Boolean]) (defaults to: undef)

    When true, it will configure the database and execute the sql scripts.

  • service_name (Optional[String]) (defaults to: $name)

    Name of the service. Defaults to the resource name



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'manifests/startup.pp', line 20

define zabbix::startup (
  Optional[Stdlib::Absolutepath] $pidfile                = undef,
  Optional[Stdlib::Absolutepath] $agent_configfile_path  = undef,
  Optional[Stdlib::Absolutepath] $server_configfile_path = undef,
  Optional[Zabbix::Databases] $database_type             = undef,
  Optional[String] $zabbix_user                          = undef,
  Optional[String[1]] $additional_service_params         = undef,
  String $service_type                                   = 'simple',
  Optional[Boolean] $manage_database                     = undef,
  Optional[String] $service_name                         = $name,
) {
  case $title.downcase {
    /agent/: {
      assert_type(Stdlib::Absolutepath, $agent_configfile_path)
    }
    /server/: {
      assert_type(Stdlib::Absolutepath, $server_configfile_path)
      assert_type(Zabbix::Databases, $database_type)
      assert_type(Boolean, $manage_database)
    }
    default: {
      fail('we currently only support a title that contains agent or server')
    }
  }
  # provided by camp2camp/systemd
  if $facts['systemd'] {
    contain systemd
    systemd::unit_file { "${name}.service":
      content => template("zabbix/${service_name}-systemd.init.erb"),
    }
    file { "/etc/init.d/${name}":
      ensure  => absent,
    }
  } elsif $facts['os']['family'] in ['Debian', 'RedHat'] {
    # Currently other osfamily without systemd is not supported
    $osfamily_downcase = downcase($facts['os']['family'])
    file { "/etc/init.d/${service_name}":
      ensure  => file,
      mode    => '0755',
      content => template("zabbix/${name}-${osfamily_downcase}.init.erb"),
    }
  } elsif $facts['os']['family'] in ['AIX'] {
    file { "/etc/rc.d/init.d/${service_name}":
      ensure  => file,
      mode    => '0755',
      content => epp('zabbix/zabbix-agent-aix.init.epp', { 'pidfile' => $pidfile, 'agent_configfile_path' => $agent_configfile_path, 'zabbix_user' => $zabbix_user }),
    }
    file { "/etc/rc.d/rc2.d/S999${service_name}":
      ensure => 'link',
      target => "/etc/rc.d/init.d/${service_name}",
    }
  } elsif ($facts['os']['family'] == 'windows') {
    exec { "install_agent_${name}":
      command  => "& 'C:\\Program Files\\Zabbix Agent\\zabbix_agentd.exe' --config ${agent_configfile_path} --install",
      onlyif   => "if (Get-WmiObject -Class Win32_Service -Filter \"Name='${name}'\"){exit 1}",
      provider => powershell,
      notify   => Service[$name],
    }
  } else {
    fail('We currently only support Debian, FreeBSD, Redhat, AIX and Windows osfamily as non-systemd')
  }
}