wmdeit-cf-wmdelib/mysql.cf

70 lines
1.6 KiB
CFEngine3

#
#
#
bundle agent mysql
{
vars:
"bind_address" string => "127.0.0.1";
"user" string => "mysql";
"port" string => "3306";
freebsd::
# "pkg" string => "mariadb106-server";
"pkg" string => "mysql80-server";
"service_name" string => "mysql-server";
"cfg_file" string => "/usr/local/etc/mysql/my.cnf";
"mysql_cmd" string => "/usr/local/bin/mysql";
debian::
"pkg" string => "mariadb-server";
"service_name" string => "mysql";
"cfg_file" string => "/etc/mysql/my.cnf";
"mysql_cmd" string => "/usr/bin/mysql";
files:
"$(cfg_file)"
create => "true",
perms => m("644"),
edit_template => "$(sys.workdir)/inputs/$(def.wmde_libdir)/templates/my.cnf.mustache",
template_method => "mustache",
handle => "mysql_cfg_created",
depends_on => {"mysql_pkgs_installed"},
classes => if_repaired("mysql_repaired");
methods:
"any" usebundle => wmde_install_packages("$(mysql.pkg)","mysql");
services:
"$(service_name)"
depends_on => {"mysql_pkgs_installed"},
service_policy => "start",
handle => "mysql_running";
mysql_repaired::
"$(service_name)"
service_policy => "restart",
depends_on => {"mysql_running","mysql_cfg_created"};
}
bundle agent create_mysql_db(cfg)
{
vars:
"db_name" string => "$(cfg[db_name])";
"db_user" string => "$(cfg[db_user])";
"host" string => "$(cfg[db_user_host])";
"db_pass" string => "$(cfg[db_pass])";
"args" string => "-e \"CREATE DATABASE IF NOT EXISTS $(db_name); GRANT ALL PRIVILEGES ON $(db_name).* TO '$(db_user)'@'$(host)' IDENTIFIED BY '$(db_pass)'; \" ";
commands:
debian::
"$(mysql.mysql_cmd)"
args => "$(args)",
inform => "false";
reports:
}