Replace systemd unit overrides with role

Instead of placing bunch of templates, we can use our systemd_role
that is capable of placing just overrides file, that will have same
functionality but also provide ability to easily add required data into
systemd overrides.

Change-Id: I7b3b0f4da047f82a49266ef57fba2fbaa24cebdc
This commit is contained in:
Dmitriy Rabotyagov 2021-06-11 19:07:59 +03:00
parent dd47f7247e
commit 818c5a71b0
11 changed files with 60 additions and 73 deletions

View File

@ -148,6 +148,7 @@ galera_my_cnf_overrides: {}
galera_cluster_cnf_overrides: {}
galera_debian_cnf_overrides: {}
galera_encryption_overrides: {}
galera_init_overrides: {}
# Set the max connections value for galera. Set this value to override the
# computed value which is (100 x vCPUs) with a cap of 1600. If computed, the

View File

@ -0,0 +1,7 @@
---
features:
- |
Added variable ``galera_init_overrides`` that can be leveraged to override
default set of systemd unit file for mariadb.
This also brings requirement of `systemd_service <https://opendev.org/openstack/ansible-role-systemd_service>`_
role.

View File

@ -13,34 +13,32 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Create mariadb systemd service config dir
# TODO(noonedeadpunk): Remove task and called handler after X release
- name: Remove old systemd overrides
file:
path: "/etc/systemd/system/{{ galera_mariadb_service_name }}.service.d"
state: "directory"
group: "root"
owner: "root"
mode: "0755"
- name: Apply systemd options
template:
src: "{{ item.src }}"
dest: "/etc/systemd/system/{{ galera_mariadb_service_name }}.service.d/{{ item.dest }}"
mode: "0644"
path: "/etc/systemd/system/{{ galera_mariadb_service_name }}.service.d/{{ item }}"
state: absent
with_items:
- { src: "systemd.environment.conf.j2", dest: "environment.conf" }
- { src: "systemd.limits.conf.j2", dest: "limits.conf" }
- { src: "systemd.restart.conf.j2", dest: "restart.conf" }
- { src: "systemd.slice.conf.j2", dest: "slice.conf" }
- { src: "systemd.timeout.conf.j2", dest: "timeout.conf" }
- { src: "systemd.without-privatedevices.conf.j2", dest: "without-privatedevices.conf" }
notify:
- Manage LB
- Reload the systemd daemon
- Restart all mysql
- environment.conf
- limits.conf
- restart.conf
- slice.conf
- timeout.conf
- without-privatedevices.conf
when: galera_upgrade | bool
notify: Reload the systemd daemon
- name: Reload systemd service files
systemd:
daemon_reload: yes
- name: Run the systemd service role
import_role:
name: systemd_service
vars:
systemd_tempd_prefix: openstack
systemd_services:
- service_name: "{{ galera_mariadb_service_name }}"
systemd_overrides_only: True
systemd_overrides: "{{ galera_init_defaults | combine(galera_init_overrides) }}"
tags:
- galera-service
# NOTE(cloudnull): The secure task is not needed on Debian based systems
# as all of these tasks will be run on Package install
@ -134,7 +132,6 @@
notify:
- Manage LB
- Restart all mysql
- Reload the systemd daemon
- name: Link mysql and mariadb config files
file:

View File

@ -1,8 +0,0 @@
# {{ ansible_managed }}
[Service]
# https://jira.mariadb.org/browse/MDEV-14256
Environment="WSREP_SST_OPT_PORT=4444"
# Configure Linux OOM killer to prioritize other targets than mariadb
OOMScoreAdjust=-1000

View File

@ -1,5 +0,0 @@
# {{ ansible_managed }}
[Service]
LimitNOFILE={{ galera_file_limits }}

View File

@ -1,9 +0,0 @@
# {{ ansible_managed }}
[Service]
# Define the condition under which the service will be restarted
# on-abort is the most conservative one since that should capture unexpected
# failures but also exclude failures due to bad configurations. This is
# currently the upstream option as well
Restart=on-abort
RestartSec=5s

View File

@ -1,11 +0,0 @@
# {{ ansible_managed }}
[Service]
# This creates a specific slice to operate from. The accounting options give us
# the ability to see resource usage through the `systemd-cgtop` command and
# further isolate this service from the host machine.
Slice=galera.slice
CPUAccounting=true
BlockIOAccounting=true
MemoryAccounting=false
TasksAccounting=true

View File

@ -1,6 +0,0 @@
# {{ ansible_managed }}
[Service]
# How long to wait for successful mysql startup
# Startup can take a while if it requires a galera state transfer.
TimeoutStartSec={{ galera_startup_timeout }}

View File

@ -1,4 +0,0 @@
# {{ ansible_managed }}
[Service]
PrivateDevices={{ galera_disable_privatedevices | bool | ternary('false', 'true') }}

View File

@ -1,4 +0,0 @@
# {{ ansible_managed }}
# OpenFile limits
* - nofile {{ galera_file_limits }}

29
vars/main.yml Normal file
View File

@ -0,0 +1,29 @@
---
# Copyright 2021, City Network International AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
galera_init_defaults:
Service:
LimitNOFILE: "{{ galera_file_limits }}"
Restart: on-abort
RestartSec: 5s
Slice: galera.slice
CPUAccounting: true
BlockIOAccounting: true
MemoryAccounting: false
TasksAccounting: true
TimeoutStartSec: "{{ galera_startup_timeout }}"
PrivateDevices: "{{ galera_disable_privatedevices | bool | ternary('false', 'true') }}"
OOMScoreAdjust: "-1000"