From 34a79515391e1b6f02a6c95b1d9687da007364bd Mon Sep 17 00:00:00 2001 From: phil Date: Sun, 21 Jan 2024 01:13:24 +0100 Subject: [PATCH] Enable configuration of Systemd service --- README.md | 10 ++++++++++ files/systemd/override.conf | 8 -------- tasks/configuration.yml | 6 +++--- templates/systemd/override.conf.j2 | 11 +++++++++++ 4 files changed, 24 insertions(+), 11 deletions(-) delete mode 100644 files/systemd/override.conf create mode 100644 templates/systemd/override.conf.j2 diff --git a/README.md b/README.md index cd81d7d..156136c 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,16 @@ mysqld: ... ``` +## Changes to the Systemd service + +Use the following options to configure your MariaDB service: + +```YAML +mariadb_service + limitnofile: 64184 + restart: on-failure +``` + ## Backup For daily backups we use automysqlbackup. You can configure it via the dict diff --git a/files/systemd/override.conf b/files/systemd/override.conf deleted file mode 100644 index f9d01ea..0000000 --- a/files/systemd/override.conf +++ /dev/null @@ -1,8 +0,0 @@ -# Ansible manages - -[Unti] -StartLimitIntervalSec=6 -StartLimitBurst=10 - -[Service] -Restart=always diff --git a/tasks/configuration.yml b/tasks/configuration.yml index 62c4d18..4bf8ad6 100644 --- a/tasks/configuration.yml +++ b/tasks/configuration.yml @@ -7,9 +7,9 @@ notify: restart mariadb - name: "Configuration | Copy systemd override" - ansible.builtin.copy: - src: systemd/override.conf - dest: /etc/systemd/systemd/mariadb.service.d/ + ansible.builtin.template: + src: systemd/override.conf.j2 + dest: /etc/systemd/systemd/mariadb.service.d/override.conf mode: "0644" notify: - Reload systemd diff --git a/templates/systemd/override.conf.j2 b/templates/systemd/override.conf.j2 new file mode 100644 index 0000000..89b7b3b --- /dev/null +++ b/templates/systemd/override.conf.j2 @@ -0,0 +1,11 @@ +{{ ansible_managed | comment }} + +[Unti] +StartLimitIntervalSec=6 +StartLimitBurst=10 + +[Service] +Restart={{ mariadb_service.restart | default('always') }} +{% if mariadb_service.limitnofile is defined %} +LimitNOFILE={{ mariadb_service.limitnofile }} +{% endif %}