Compare commits

...

7 Commits

Author SHA1 Message Date
Charlie Root 94abf0568a Handle for wget installed 2023-11-16 21:26:43 +01:00
Charlie Root 20683ccbc4 Use default postfix packagea 2023-11-16 21:26:00 +01:00
Charlie Root 46810b3b75 php-fpm socket fixed 2023-11-16 21:25:31 +01:00
Charlie Root 024f2767cd Fixes mysql version on FreeBSD 2023-11-16 21:24:38 +01:00
Charlie Root c57bf87e34 Simple bundle to edit /etc/hosts 2023-11-16 21:23:51 +01:00
Charlie Root 5c7dad802e use local_dcp instead of local_cp 2023-11-16 21:22:49 +01:00
Charlie Root 240f257bfd Matomo logging works 2023-11-16 21:21:59 +01:00
7 changed files with 73 additions and 17 deletions

View File

@ -50,6 +50,7 @@ vars:
freebsd:: freebsd::
"pkgs" slist => { "pkgs" slist => {
"apache24", "apache24",
"mod_dav_svn",
}; };
"log_dir" string =>"/var/log/httpd"; "log_dir" string =>"/var/log/httpd";
"log_dir_owner" string => "root"; "log_dir_owner" string => "root";
@ -80,7 +81,10 @@ vars:
{m:"proxy_fcgi",f:"mod_proxy_fcgi"}, {m:"proxy_fcgi",f:"mod_proxy_fcgi"},
{m:"proxy_http",f:"mod_proxy_http"}, {m:"proxy_http",f:"mod_proxy_http"},
{m:"proxy_http2",f:"mod_proxy_http2"}, {m:"proxy_http2",f:"mod_proxy_http2"},
{m:"remoteip",f:"mod_remoteip"} {m:"remoteip",f:"mod_remoteip"},
{m: "dav",f:"mod_dav"},
{m: "dav_svn", f:"mod_dav_svn"},
{m: "authz_svn", f:"mod_authz_svn"}
]'; ]';
@ -450,15 +454,17 @@ vars:
"pid" string => "/var/run/matomo-logger-$(site[domain]).pid"; "pid" string => "/var/run/matomo-logger-$(site[domain]).pid";
"log" string => "$(apache.log_dir)/$(site[domain])-access.log"; "log" string => "$(apache.log_dir)/$(site[domain])-access.log";
"siteid" string => "$(site[matomoid])"; "siteid" string => "$(site[matomoid])";
"logger_script" string => "/tmp/matomo-logger-$(site[domain]).sh";
freebsd:: freebsd::
"analyt_cmd" string => "/usr/local/bin/python3.9 /var/www/matomo/misc/log-analytics/import_logs.py"; "analyt_cmd" string => "/usr/local/bin/python3.9 $(matomo.log_importer)";
debian:: debian::
"analyt_cmd" string => "/usr/bin/python3 /var/www/matomo/misc/log-analytics/import_logs.py"; "analyt_cmd" string => "/usr/bin/python3 $(matomo.log_importer)";
centos:: centos::
"analyt_cmd" string => "/usr/bin/python3 /var/www/matomo/misc/log-analytics/import_logs.py"; "analyt_cmd" string => "/usr/bin/python3 $(matomo.log_importer)";
matomo:: matomo::
"cmd" string => "/usr/bin/pkill -P `cat $(pid)` ; exec /bin/sh -c 'echo $$ > $(pid); /usr/bin/tail -n+1 -f $(log) | $(analyt_cmd) --token-auth=$(site[matomotoken]) --disable-bulk-tracking --idsite=$(siteid) --url=$(site[matomosite]) --exclude-path=/wp-login.php --exclude-path=/wp-json/* --recorders=1 --recorder-max-payload-size=1 --log-format-name=ncsa_extended --exclude-path=*.php --exclude-path=/wp-admin/* - > /dev/null' "; "cmd" string => "/usr/bin/pkill -P `cat $(pid)` ; exec /bin/sh -c 'echo $$ > $(pid); echo \"hello\" | /usr/bin/tail -n+1 -f $(log) | $(analyt_cmd) --token-auth=$(site[matomotoken]) --disable-bulk-tracking --idsite=$(siteid) --url=$(site[matomosite]) --exclude-path=/wp-login.php --exclude-path=/wp-json/\\* --recorders=1 --recorder-max-payload-size=1 --log-format-name=ncsa_extended --exclude-path=\\*.php --exclude-path=/wp-admin/\\* - > /dev/null'
";
!matomo:: !matomo::
"cmd" string => ""; "cmd" string => "";
any:: any::
@ -494,7 +500,21 @@ files:
"$(pid)" "$(pid)"
create => "true"; create => "true";
"$(logger_script)"
create => "true",
perms => m("755"),
content => '#!/bin/sh
if [ "$1" != "child" ]; then
"$(logger_script)" child &
else
setsid >/dev/null 2>&1
exec 0<&- 1>/dev/null 2>&1
$(cmd)
fi
',
handle => "loggerscript_$(site[domain])_created";
classes: classes:
"matomo" expression => isvariable("site[matomoid]"); "matomo" expression => isvariable("site[matomoid]");
@ -507,10 +527,22 @@ commands:
inform => "false", inform => "false",
module => "true"; module => "true";
start_matomo::
"$(logger_script)"
args => "$(logger_script)",
contain => wmde_cmd_useshell,
depends_on => {"loggerscript_$(site[domain])_created"};
# "/bin/sh"
# args => "$(logger_script) &",
# contain => wmde_cmd_useshell,
# depends_on => {"loggerscript_$(site[domain])_created"};
methods: methods:
start_matomo:: # start_matomo::
"call" usebundle => daemonize( "$(cmd)" ); # "call" usebundle => daemonize( "/bin/sh $(logger_script)" ),
# depends_on => {"loggerscript_$(site[domain])_created"};
reports: reports:
#start_matomo:: #start_matomo::

View File

@ -44,7 +44,7 @@ files:
freebsd:: freebsd::
"/etc/cron.d/certbot" "/etc/cron.d/certbot"
create => "true", create => "true",
copy_from => local_cp("$(sys.workdir)/inputs/$(def.wmde_libdir)/templates/certbot-cron.mustache"); copy_from => local_dcp("$(sys.workdir)/inputs/$(def.wmde_libdir)/templates/certbot-cron.mustache");
# content => '# # content => '#
# Managed by CFEngine # Managed by CFEngine

17
lib.cf
View File

@ -336,7 +336,7 @@ files:
perms => mog ("$(prms[m])","$(prms[o])","$(prms[g])"); perms => mog ("$(prms[m])","$(prms[o])","$(prms[g])");
methods: methods:
wget:: wget::
"any" usebundle => "install_wget", handle=>"wget_installed"; "any" usebundle => "install_wget"; #, handle=>"wget_installed";
commands: commands:
run_wget:: run_wget::
@ -393,3 +393,18 @@ commands:
args => "-a"; args => "-a";
} }
bundle agent etc_hosts(hosts)
{
vars:
"idx" slist => getindices(@(hosts));
"settings[$(idx)]" string => "$(hosts[$(idx)])";
files:
"/etc/hosts"
create => "true",
perms => m("644"),
edit_line => set_config_values("$(this.bundle).settings"),
classes => results("namespace","etc_hosts");
}

View File

@ -20,11 +20,12 @@ vars:
"user" string => "mysql"; "user" string => "mysql";
"server_pkgs" slist => {"mysql80-server"}; "server_pkgs" slist => {"mysql80-server"};
"client_pkgs" slist => {"mysql80-client"}; "client_pkgs" slist => {"mysql80-client"};
"type" string => "mysql8";
"server_pkgs" slist => {"mariadb106-server"}, if => strcmp("$(cfg[mariadb])","true"); "server_pkgs" slist => {"mariadb106-server"}, if => strcmp("$(cfg[mariadb])","true");
"client_pkgs" slist => {"mariadb106-client"}, if => strcmp("$(cfg[mariadb])","true"); "client_pkgs" slist => {"mariadb106-client"}, if => strcmp("$(cfg[mariadb])","true");
"type" string => "mariadb",if => strcmp("$(cfg[mariadb])","true");
"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";
@ -434,9 +435,12 @@ classes:
vars: vars:
"table_exists" string => "mysql_$(cfg[db_name])_$(cfg[db_check_table])_exists"; "table_exists" string => "mysql_$(cfg[db_name])_$(cfg[db_check_table])_exists";
methods: methods:
"any" usebundle => mysql_table_exists(@(cfg),"$(cfg[db_check_table])"); "any" usebundle => mysql_table_exists(@(cfg),"$(cfg[db_check_table])"),
handle=>"$(table_exists)_checked";
"!$(table_exists)&backup_exists":: "!$(table_exists)&backup_exists"::
"any" usebundle => restore_mysql_db(@(cfg),"$(file)"); "any" usebundle => restore_mysql_db(@(cfg),"$(file)"),
depends_on=>{"$(table_exists)_checked"};
reports: reports:
} }

8
php.cf
View File

@ -192,7 +192,7 @@ vars:
"fpm_pkgs" slist => { "php$(version)-fpm" }; "fpm_pkgs" slist => { "php$(version)-fpm" };
"fpm_service_name" string => "php$(version)-fpm"; "fpm_service_name" string => "php$(version)-fpm";
"fpm_socket" string => "/run/php/php$(version)-fpm.sock"; "fpm_socket" string => "/run/php/php$(version)-fpm.sock";
"fpm_socket_type" string => "unix"; "fpm_socket_type" string => "unix:";
"apt_repo_url" string => "https://packages.sury.org/php/"; "apt_repo_url" string => "https://packages.sury.org/php/";
"apt_repo_key" string => "https://packages.sury.org/php/apt.gpg"; "apt_repo_key" string => "https://packages.sury.org/php/apt.gpg";
@ -223,7 +223,7 @@ vars:
"fpm_pkgs" slist => {}; "fpm_pkgs" slist => {};
"fpm_service_name" string => "php-fpm"; "fpm_service_name" string => "php-fpm";
"fpm_socket" string => "127.0.0.1:9000"; "fpm_socket" string => "127.0.0.1:9000";
"fpm_socket_type" string => "inet"; "fpm_socket_type" string => "fcgi://";
centos:: centos::
"cli_exe" string => "/usr/bin/php"; "cli_exe" string => "/usr/bin/php";
@ -231,6 +231,7 @@ vars:
"fpm_pkgs" slist => { "php-fpm" }; "fpm_pkgs" slist => { "php-fpm" };
"fpm_service_name" string => "php$(version)-fpm"; "fpm_service_name" string => "php$(version)-fpm";
"fpm_socket" string => "/run/php-fpm/www.sock"; "fpm_socket" string => "/run/php-fpm/www.sock";
"fpm_socket_type" string => "unix:";
files: files:
@ -260,11 +261,14 @@ vars:
"service_deps" slist => { "service_deps" slist => {
"php_pkgs_installed" "php_pkgs_installed"
}; };
"service_name" string => "$(php.fpm_service_name)";
"service_cfg_name" string => "php_fpm";
methods: methods:
"any" usebundle => install_php; "any" usebundle => install_php;
"any" usebundle => wmde_install_packages(@(php.fpm_pkgs),"php_fpm"); "any" usebundle => wmde_install_packages(@(php.fpm_pkgs),"php_fpm");
"any" usebundle => wmde_enable_service("$(this.bundle)");
"any" usebundle => wmde_service("$(php.fpm_service_name)","php_kept|php_fpm_kept","php_repaired|php_fpm_repaired"), "any" usebundle => wmde_service("$(php.fpm_service_name)","php_kept|php_fpm_kept","php_repaired|php_fpm_repaired"),
depends_on => @(service_deps); depends_on => @(service_deps);

View File

@ -11,7 +11,7 @@ vars:
freebsd:: freebsd::
"pkgs" slist => { "pkgs" slist => {
"postfix-mysql", "postfix",
#"postfix", #"postfix",
}; };
"db_dir" string => "/var/db"; "db_dir" string => "/var/db";

View File

@ -22,6 +22,7 @@ vars:
bundle agent install_wget bundle agent install_wget
{ {
methods: methods:
"any" usebundle => wmde_install_packages(@(wget.pkgs),"wget"); "any" usebundle => wmde_install_packages(@(wget.pkgs),"wget"),
handle=>"wget_installed";
} }