Puppet Class: zabbix::database::mysql
- Inherits:
- zabbix::params
- Defined in:
- manifests/database/mysql.pp
Overview
Class: zabbix::database::mysql
This will install and load the sql files for the tables
and other data which is needed for zabbix.
Please note:
This class will be called from zabbix::database. No need for calling
this class manually.
Authors
Author Name: ikben@werner-dijkerman.nl
Copyright
Copyright 2014 Werner Dijkerman
18 19 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'manifests/database/mysql.pp', line 18
class zabbix::database::mysql (
$zabbix_type = '',
$zabbix_version = $zabbix::params::zabbix_version,
$database_schema_path = '',
$database_name = '',
$database_user = '',
$database_password = '',
$database_host = '',
$database_path = $zabbix::params::database_path,) inherits zabbix::params {
#
# Adjustments for version 3.0 - structure of package with sqls differs from previous versions
case $zabbix_version {
'3.0': {
if ($database_schema_path == false) or ($database_schema_path == '') {
case $::operatingsystem {
'CentOS', 'RedHat', 'OracleLinux': {
$schema_path = "/usr/share/doc/zabbix-*-mysql-${zabbix_version}**/"
}
default : {
$schema_path = '/usr/share/doc/zabbix-*-mysql'
}
}
}
else {
$schema_path = $database_schema_path
}
case $zabbix_type {
'proxy': {
$zabbix_proxy_create_sql = "cd ${schema_path} && if [ -f schema.sql.gz ]; then gunzip schema.sql.gz ; fi && mysql -h '${database_host}' -u '${database_user}' -p'${database_password}' -D '${database_name}' < schema.sql && touch /etc/zabbix/.schema.done"
}
default: {
$zabbix_server_create_sql = "cd ${schema_path} && if [ -f create.sql.gz ]; then gunzip create.sql.gz ; fi && mysql -h '${database_host}' -u '${database_user}' -p'${database_password}' -D '${database_name}' < create.sql && touch /etc/zabbix/.schema.done"
$zabbix_server_images_sql = 'touch /etc/zabbix/.images.done'
$zabbix_server_data_sql = 'touch /etc/zabbix/.data.done'
}
}
}
default: {
if ($database_schema_path == false) or ($database_schema_path == '') {
case $::operatingsystem {
'CentOS', 'RedHat', 'OracleLinux': {
$schema_path = "/usr/share/doc/zabbix-*-mysql-${zabbix_version}*/create"
}
default : {
$schema_path = '/usr/share/zabbix-*-mysql'
}
}
}
else {
$schema_path = $database_schema_path
}
case $zabbix_type {
'proxy': {
$zabbix_proxy_create_sql = "cd ${schema_path} && if [ -f schema.sql.gz ]; then gunzip schema.sql.gz ; fi && mysql -h '${database_host}' -u '${database_user}' -p'${database_password}' -D '${database_name}' < schema.sql && touch /etc/zabbix/.schema.done"
}
default: {
$zabbix_server_create_sql = "cd ${schema_path} && if [ -f schema.sql.gz ]; then gunzip schema.sql.gz ; fi && mysql -h '${database_host}' -u '${database_user}' -p'${database_password}' -D '${database_name}' < schema.sql && touch /etc/zabbix/.schema.done"
$zabbix_server_images_sql = "cd ${schema_path} && if [ -f images.sql.gz ]; then gunzip images.sql.gz ; fi && mysql -h '${database_host}' -u '${database_user}' -p'${database_password}' -D '${database_name}' < images.sql && touch /etc/zabbix/.images.done"
$zabbix_server_data_sql = "cd ${schema_path} && if [ -f data.sql.gz ]; then gunzip data.sql.gz ; fi && mysql -h '${database_host}' -u '${database_user}' -p'${database_password}' -D '${database_name}' < data.sql && touch /etc/zabbix/.data.done"
}
}
}
}
# Loading the sql files.
case $zabbix_type {
'proxy' : {
exec { 'zabbix_proxy_create.sql':
command => $zabbix_proxy_create_sql,
path => "/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:${database_path}",
unless => 'test -f /etc/zabbix/.schema.done',
provider => 'shell',
require => Package['zabbix-proxy-mysql'],
notify => Service['zabbix-proxy'],
}
}
'server' : {
exec { 'zabbix_server_create.sql':
command => $zabbix_server_create_sql,
path => "/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:${database_path}",
unless => 'test -f /etc/zabbix/.schema.done',
provider => 'shell',
} ->
exec { 'zabbix_server_images.sql':
command => $zabbix_server_images_sql,
path => "/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:${database_path}",
unless => 'test -f /etc/zabbix/.images.done',
provider => 'shell',
} ->
exec { 'zabbix_server_data.sql':
command => $zabbix_server_data_sql,
path => "/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:${database_path}",
unless => 'test -f /etc/zabbix/.data.done',
provider => 'shell',
}
}
default : {
fail 'We do not work.'
}
} # END case $zabbix_type
}
|