Compare commits

...

8 Commits

Author SHA1 Message Date
Tube ba31a7cfa3 Merge branch 'main' of https://srcsrv.wikimedia.de/WMDE/wmdeit-cf-wmdelib 2023-10-22 23:34:48 +02:00
Tube d78d7189d6 almost empty my.cnf 2023-10-22 23:30:19 +02:00
Tube ff692df2ee createdb for mysql8 2023-10-22 23:29:39 +02:00
Tube 17ca7a5299 Removed FreeBSD sysrc crap 2023-10-22 23:29:07 +02:00
Tube 9285751709 some modules for freebsd added 2023-10-22 23:27:50 +02:00
Tube cdcc0bdcd5 Fixes for fedora 2023-10-22 23:27:25 +02:00
Tube 176a9cf980 changes owner 2023-10-22 23:22:23 +02:00
Tube 0c5024867d Added fedora/centos 2023-10-22 21:05:45 +02:00
7 changed files with 128 additions and 37 deletions

View File

@ -202,14 +202,15 @@ methods:
"any" usebundle => install_apache_php, "any" usebundle => install_apache_php,
depends_on => { "apache_pkgs_installed" }; depends_on => { "apache_pkgs_installed" };
commands: commands:
freebsd:: # freebsd::
"/usr/sbin/sysrc" # "/usr/sbin/sysrc"
handle => "apache_editrc", # handle => "apache_editrc",
args => "apache24_enable=yes", # args => "apache24_enable=yes",
inform=>"false"; # inform=>"false";
debian|centos:: # debian|centos::
"/bin/true" handle => "apache_editrc", # any::
inform => "false"; # "/bin/true" handle => "apache_editrc",
# inform => "false";
files: files:
"$(apache.log_dir)/." "$(apache.log_dir)/."
@ -245,8 +246,9 @@ files:
classes => if_repaired(apache_changed); classes => if_repaired(apache_changed);
services: services:
# apache_editrs depends
"$(apache.service_name)" "$(apache.service_name)"
depends_on => {"apache_editrc","apache_vhost_dir_created","apache_www_dir_created","apache_main_cfg_crreated"}, depends_on => {"apache_vhost_dir_created","apache_www_dir_created","apache_main_cfg_crreated"},
service_policy => "start", service_policy => "start",
handle => "apache_running"; handle => "apache_running";

7
lib.cf
View File

@ -30,6 +30,13 @@ packages:
package_module => apt_get, package_module => apt_get,
handle => "$(name)_pkgs_installed", handle => "$(name)_pkgs_installed",
classes => results("namespace","$(name)"); classes => results("namespace","$(name)");
fedora|centos::
"$(pkgs)"
policy => "present",
package_module => yum,
handle => "$(name)_pkgs_installed",
classes => results("namespace","$(name)");
} }

111
mysql.cf
View File

@ -14,20 +14,31 @@ vars:
"cfg" data => mergedata(@(default_cfg),@(cfg_param)); "cfg" data => mergedata(@(default_cfg),@(cfg_param));
freebsd:: freebsd::
# "pkg" string => "mariadb106-server"; # "server_pkgs" slist => {"mariadb106-server"};
"pkg" slist => {"mysql80-server"}; # "client_pkgs" slist => {"mariadb106-client"};
"server_pkgs" slist => {"mysql80-server"};
"client_pkgs" slist => {"mysql80-client"}; "client_pkgs" slist => {"mysql80-client"};
"type" string => "mysql8";
"service_name" string => "mysql-server"; "service_name" string => "mysql-server";
"cfg_dir" string => "/usr/local/etc/mysql"; "cfg_dir" string => "/usr/local/etc/mysql";
"cfg_file" string => "/usr/local/etc/mysql/my.cnf"; "cfg_file" string => "/usr/local/etc/mysql/my.cnf";
"bin_dir" string => "/usr/local/bin"; "bin_dir" string => "/usr/local/bin";
debian:: debian::
"pkg" slist => {"mariadb-server"}; "server_pkgs" slist => {"mariadb-server"};
"client_pkgs" slist => {"mariadb-client"}; "client_pkgs" slist => {"mariadb-client"};
"type" string => "mariadb";
"service_name" string => "mysql"; "service_name" string => "mysql";
"cfg_dir" string => "/etc/mysql"; "cfg_dir" string => "/etc/mysql";
"cfg_file" string => "/etc/mysql/my.cnf"; "cfg_file" string => "/etc/mysql/my.cnf";
"bin_dir" string => "/usr/bin"; "bin_dir" string => "/usr/bin";
fedora::
"server_pkgs" slist => {"mariadb-server"};
"client_pkgs" slist => {"mariadb-client"};
"type" string => "mariadb";
"service_name" string => "mariadb";
"cfg_dir" string => "/etc/mysql";
"cfg_file" string => "/etc/my.cnf";
"bin_dir" string => "/usr/bin"; any::
any:: any::
"mysql_cmd" string => "$(bin_dir)/mysql"; "mysql_cmd" string => "$(bin_dir)/mysql";
"mysqldump_cmd" string => "$(bin_dir)/mysqldump"; "mysqldump_cmd" string => "$(bin_dir)/mysqldump";
@ -56,10 +67,6 @@ files:
classes => if_repaired("mysql_repaired"); classes => if_repaired("mysql_repaired");
methods:
"any" usebundle => wmde_install_packages(@(mysql.pkg),"mysql"),
depends_on => { "mysql_cfg_created"};
services: services:
"$(service_name)" "$(service_name)"
depends_on => {"mysql_pkgs_installed"}, depends_on => {"mysql_pkgs_installed"},
@ -74,7 +81,83 @@ services:
reports: reports:
} }
bundle agent install_mysql_server(cfg)
{
vars:
"mysqld_idx" slist => getindices(@(cfg[settings][mysqld]));
"settings[mysqld][$(mysqld_idx)]" string => "$(cfg[settings][mysqld][$(mysqld_idx)])";
"j" string => storejson(@(cfg));
methods:
"any" usebundle => wmde_install_packages(@(mysql.server_pkgs),"mysql_server");
files:
"$(mysql.cfg_file)"
copy_from => seed_cp("$(sys.workdir)/inputs/$(def.wmde_libdir)/templates/my.cnf.mustache"),
handle => "myslq_server_cfg_created",
depends_on => {"mysql_server_pkgs_installed"};
"$(mysql.cfg_file)"
create => "true",
perms => m("644"),
edit_line => set_variable_values_inix("$(this.bundle).settings","mysqld"),
depends_on => {"myslq_server_cfg_created"},
handle => "myslq_server_cfg_edited",
classes => if_repaired("mysql_server_repaired");
methods:
"any" usebundle => wmde_service("$(mysql.service_name)","mysql_server_kept","mysql_server_repaired"),
depends_on => {"myslq_server_cfg_edited"};
reports:
}
bundle edit_line set_variable_values_inix(tab, sectionName)
{
vars:
"index" slist => getindices("$(tab)[$(sectionName)]");
# Be careful if the index string contains funny chars
"cindex[$(index)]" string => canonify("$(index)");
classes:
"edit_$(cindex[$(index)])" not => strcmp("$($(tab)[$(sectionName)][$(index)])","dontchange"),
comment => "Create conditions to make changes";
field_edits:
# If the line is there, but commented out, first uncomment it
# "#+\s*$(index)\s*=.*"
# select_region => INI_section(escape("$(sectionName)")),
# edit_field => col("\s*=\s*","1","$(index)","set"),
# if => "edit_$(cindex[$(index)])";
# match a line starting like the key something
"\s*$(index)\s*=.*"
edit_field => col("\s*=\s*","2","$($(tab)[$(sectionName)][$(index)])","set"),
select_region => INI_section(escape("$(sectionName)")),
classes => results("bundle", "set_variable_values_ini_not_$(cindex[$(index)])"),
if => "edit_$(cindex[$(index)])";
delete_lines:
"!include.*";
insert_lines:
"[$(sectionName)]"
location => start,
comment => "Insert lines";
"$(index)=$($(tab)[$(sectionName)][$(index)])"
select_region => INI_section(escape("$(sectionName)")),
if => "!(set_variable_values_ini_not_$(cindex[$(index)])_kept|set_variable_values_ini_not_$(cindex[$(index)])_repaired).edit_$(cindex[$(index)])";
}
bundle agent install_mysql_client bundle agent install_mysql_client
{ {
@ -178,19 +261,25 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
bundle agent create_mysql_db(cfg) bundle agent create_mysql_db(cfg)
{ {
classes:
"type_$(mysql.type)" ;
vars: vars:
"db_name" string => "$(cfg[db_name])"; "db_name" string => "$(cfg[db_name])";
"db_user" string => "$(cfg[db_user])"; "db_user" string => "$(cfg[db_user])";
"host" string => "$(cfg[db_user_host])"; "host" string => "$(cfg[db_user_host])";
"db_pass" string => "$(cfg[db_pass])"; "db_pass" string => "$(cfg[db_pass])";
type_mariadb::
"args" string => "-e \"CREATE DATABASE IF NOT EXISTS $(db_name); GRANT ALL PRIVILEGES ON $(db_name).* TO '$(db_user)'@'$(host)' IDENTIFIED BY '$(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)'; \" ";
type_mysql8::
"args" string => "-e \"CREATE DATABASE IF NOT EXISTS $(db_name); CREATE USER IF NOT EXISTS '$(db_user)'@'$(host)'; ALTER USER '$(db_user)'@'$(host)' IDENTIFIED BY '$(db_pass)'; GRANT ALL PRIVILEGES ON $(db_name).* TO '$(db_user)'@'$(host)';\" ";
commands: commands:
debian::
"$(mysql.mysql_cmd)" "$(mysql.mysql_cmd)"
args => "$(args)", args => "$(args)",
inform => "false"; inform => "false";
reports: reports:
} }

5
php.cf
View File

@ -28,6 +28,11 @@ vars:
"php$(bsdvs)-pdo_mysql", "php$(bsdvs)-pdo_mysql",
"php$(bsdvs)-pdo", "php$(bsdvs)-pdo",
"php$(bsdvs)-filter", "php$(bsdvs)-filter",
"php$(bsdvs)-mbstring",
"php$(bsdvs)-dom",
"php$(bsdvs)-xml",
"php$(bsdvs)-ctype",
"php$(bsdvs)-intl",
}; };
# "php$(bsdvs)-json", # "php$(bsdvs)-json",

View File

@ -58,8 +58,9 @@ methods:
commands: commands:
roundcube_untar:: roundcube_untar::
"/usr/bin/tar" "/usr/bin/tar"
args => "xzvf $(dlfile) -C $(cfg[install_dir])", args => "xzf $(dlfile) -C $(cfg[install_dir]) && chown -R $(cfg[www_user]):$(cfg[www_group]) $(cfg[install_dir])",
depends_on => {"roundcube_tgz_copied"}, depends_on => {"roundcube_tgz_copied"},
contain => wmde_cmd_useshell,
handle => "roundcube_untarred"; handle => "roundcube_untarred";
!roundcube_untar:: !roundcube_untar::
"/usr/bin/true" "/usr/bin/true"

View File

@ -1,22 +1,9 @@
# #
# Managed by CFEngine # Created by CFEngine
# #
[client-server] [client-server]
port = {{vars.cfg.mysql.port}}
socket = /run/mysqld/mysqld.sock
#[mysql]
#prompt = \u@\h [\d]>\_
#no_auto_rehash
[mysqld] [mysqld]
#log-error =/var/log/mysql/mysqld.log
user = {{vars.mysql.cfg.user}}
port = {{vars.mysql.cfg.port}}
bind-address = {{vars.mysql.cfg.bind_address}}
lower_case_table_names = 1

4
vim.cf
View File

@ -13,7 +13,7 @@ vars:
debian:: debian::
"vimrc" string => "/etc/vim/vimrc"; "vimrc" string => "/etc/vim/vimrc";
"pkg" string => "vim"; "pkg" string => "vim";
centos:: centos|fedora::
"vimrc" string => "/etc/vim/vimrc"; "vimrc" string => "/etc/vim/vimrc";
"pkg" string => "vim-enhanced"; "pkg" string => "vim-enhanced";
@ -28,7 +28,7 @@ packages:
"$(pkg)" "$(pkg)"
policy => "present", policy => "present",
package_module => apt_get; package_module => apt_get;
centos:: fedora|centos::
"$(pkg)" "$(pkg)"
policy => "present", policy => "present",
package_module => yum; package_module => yum;