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 f7e38de
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/timesyncd.conf
systemd_oomd_swapusedlimit:

Check failure on line 4 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[empty-values]

Empty value in block mapping

Check failure on line 4 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / yamllint

4:28 [empty-values] empty value in block mapping

Check failure on line 4 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / yamllint

4:28 [empty-values] empty value in block mapping

Check failure on line 4 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[empty-values]

Empty value in block mapping
systemd_oomd_defaultmemorypressurelimit:

Check failure on line 5 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[empty-values]

Empty value in block mapping

Check failure on line 5 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / yamllint

5:41 [empty-values] empty value in block mapping

Check failure on line 5 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / yamllint

5:41 [empty-values] empty value in block mapping

Check failure on line 5 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[empty-values]

Empty value in block mapping
systemd_oomd_defaultmemorypressuredurationsec:

Check failure on line 6 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[empty-values]

Empty value in block mapping

Check failure on line 6 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / yamllint

6:47 [empty-values] empty value in block mapping

Check failure on line 6 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / yamllint

6:47 [empty-values] empty value in block mapping

Check failure on line 6 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[empty-values]

Empty value in block mapping
systemd_timesyncd_package_name: systemd-oomd

Check failure on line 7 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

var-naming[no-role-prefix]

Variables names from within roles should use systemd_oomd_ as a prefix. (vars: systemd_timesyncd_package_name)

Check failure on line 7 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

var-naming[no-role-prefix]

Variables names from within roles should use systemd_oomd_ as a prefix. (vars: systemd_timesyncd_package_name)
systemd_timesyncd_package_version: ""

Check failure on line 8 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

var-naming[no-role-prefix]

Variables names from within roles should use systemd_oomd_ as a prefix. (vars: systemd_timesyncd_package_version)

Check failure on line 8 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

var-naming[no-role-prefix]

Variables names from within roles should use systemd_oomd_ as a prefix. (vars: systemd_timesyncd_package_version)
systemd_timesyncd_package_state: present

Check failure on line 9 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

var-naming[no-role-prefix]

Variables names from within roles should use systemd_oomd_ as a prefix. (vars: systemd_timesyncd_package_state)

Check failure on line 9 in roles/systemd_oomd/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

var-naming[no-role-prefix]

Variables names from within roles should use systemd_oomd_ as a prefix. (vars: systemd_timesyncd_package_state)
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 <[email protected]>
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 f7e38de

Please sign in to comment.