Skip to content

Commit

Permalink
NOTASK: add systemd-oomd role
Browse files Browse the repository at this point in the history
  • Loading branch information
damex committed Apr 22, 2024
1 parent ad762e7 commit 99db1e4
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 0 deletions.
Empty file added roles/systemd_oomd/README.md
Empty file.
9 changes: 9 additions & 0 deletions roles/systemd_oomd/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
systemd_oomd_service_name: systemd-oomd
systemd_oomd_configuration_file: /etc/systemd/oomd.conf
systemd_oomd_swapusedlimit: 90%
systemd_oomd_defaultmemorypressurelimit: 60%
systemd_oomd_defaultmemorypressuredurationsec: 30s
systemd_oomd_package_name: systemd-oomd
systemd_oomd_package_version: ""
systemd_oomd_package_state: present
26 changes: 26 additions & 0 deletions roles/systemd_oomd/meta/argument_specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
argument_specs:
main:
options:
systemd_oomd_service_name:
required: true
type: str
systemd_oomd_configuration_file:
required: true
type: str
systemd_oomd_swapusedlimit:
type: str
systemd_oomd_defaultmemorypressurelimit:
type: str
systemd_oomd_defaultmemorypressuredurationsec:
type: str
systemd_oomd_package_name:
required: true
type: str
systemd_oomd_package_version:
type: str
systemd_oomd_package_state:
type: str
choices:
- present
- absent
15 changes: 15 additions & 0 deletions roles/systemd_oomd/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
galaxy_info:
author: Roman Kuzmitskii <ansible@damex.org>
description: systemd oomd role
license: GPLv2
min_ansible_version: 2.16.0
platforms:
- name: Debian
versions:
- buster
- bullseye
- name: Ubuntu
versions:
- focal
dependencies: []
13 changes: 13 additions & 0 deletions roles/systemd_oomd/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Ensure systemd oomd
tags:
- systemd_oomd
- systemd
- oomd
block:
- name: Ensure systemd oomd package
ansible.builtin.import_tasks: package.yml
- name: Ensure systemd oomd oomd.conf
ansible.builtin.import_tasks: oomd.conf.yml
- name: Ensure systemd oomd systemd service
ansible.builtin.import_tasks: systemd_service.yml
10 changes: 10 additions & 0 deletions roles/systemd_oomd/tasks/oomd.conf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Ensure oomd.conf
ansible.builtin.template:
src: oomd.conf.j2
dest: "{{ systemd_oomd_configuration_file }}"
group: root
owner: root
mode: "0644"
register: systemd_oomd_conf
become: true
9 changes: 9 additions & 0 deletions roles/systemd_oomd/tasks/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Ensure systemd oomd package
ansible.builtin.include_role:
name: damex.apt.apt_packages
vars:
apt_packages: # noqa: var-naming[no-role-prefix]
- name: "{{ systemd_oomd_package_name }}"
version: "{{ systemd_oomd_package_version }}"
state: "{{ systemd_oomd_package_state }}"
7 changes: 7 additions & 0 deletions roles/systemd_oomd/tasks/systemd_service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Ensure systemd service {{ systemd_oomd_service_name }}
ansible.builtin.include_role:
name: damex.systemd.systemd_service
vars:
systemd_service_name: "{{ systemd_oomd_service_name }}"
systemd_service_restart_on: "{{ systemd_oomd_conf.changed }}"
5 changes: 5 additions & 0 deletions roles/systemd_oomd/templates/oomd.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ ansible_managed | comment }}
[OOM]
SwapUsedLimit = {{ systemd_oomd_swapusedlimit }}
DefaultMemoryPressureLimit = {{ systemd_oomd_defaultmemorypressurelimit }}
DefaultMemoryPressureDurationSec = {{ systemd_oomd_defaultmemorypressuredurationsec }}

0 comments on commit 99db1e4

Please sign in to comment.