diff --git a/nodes/mastodon-3.json b/nodes/mastodon-3.json index 6f0e0fa..c5dba55 100644 --- a/nodes/mastodon-3.json +++ b/nodes/mastodon-3.json @@ -37,6 +37,7 @@ "timezone_iii::debian", "ntp::default", "ntp::apparmor", + "kosmos-base::journald_conf", "kosmos-base::systemd_emails", "apt::unattended-upgrades", "kosmos-base::firewall", diff --git a/site-cookbooks/kosmos-base/attributes/default.rb b/site-cookbooks/kosmos-base/attributes/default.rb new file mode 100644 index 0000000..37d8e43 --- /dev/null +++ b/site-cookbooks/kosmos-base/attributes/default.rb @@ -0,0 +1,2 @@ +node.default["kosmos-base"]["journald"]["system_max_use"] = "256M" +node.default["kosmos-base"]["journald"]["max_retention_sec"] = "7d" diff --git a/site-cookbooks/kosmos-base/recipes/default.rb b/site-cookbooks/kosmos-base/recipes/default.rb index d5df463..0033a24 100644 --- a/site-cookbooks/kosmos-base/recipes/default.rb +++ b/site-cookbooks/kosmos-base/recipes/default.rb @@ -27,6 +27,7 @@ include_recipe 'apt' include_recipe 'timezone_iii' include_recipe 'ntp' +include_recipe 'kosmos-base::journald_conf' include_recipe 'kosmos-base::systemd_emails' node.override["apt"]["unattended_upgrades"]["allowed_origins"] = [ diff --git a/site-cookbooks/kosmos-base/recipes/journald_conf.rb b/site-cookbooks/kosmos-base/recipes/journald_conf.rb new file mode 100644 index 0000000..b7744b9 --- /dev/null +++ b/site-cookbooks/kosmos-base/recipes/journald_conf.rb @@ -0,0 +1,14 @@ +# +# Cookbook Name:: kosmos-base +# Recipe:: journald_conf +# + +service "systemd-journald" + +template "/etc/systemd/journald.conf" do + source "journald.conf.erb" + variables system_max_use: node["kosmos-base"]["journald"]["system_max_use"], + max_retention_sec: node["kosmos-base"]["journald"]["max_retention_sec"] + # Restarting journald is required + notifies :restart, "service[systemd-journald]", :delayed +end diff --git a/site-cookbooks/kosmos-base/templates/default/journald.conf.erb b/site-cookbooks/kosmos-base/templates/default/journald.conf.erb new file mode 100644 index 0000000..d39e2d2 --- /dev/null +++ b/site-cookbooks/kosmos-base/templates/default/journald.conf.erb @@ -0,0 +1,6 @@ +[Journal] +# Set the maximum size of the journal logs in bytes +SystemMaxUse=<%= @system_max_use %> + +# Set the number of days after which logs will be deleted +MaxRetentionSec=<%= @max_retention_sec %>