roles: add earlyoom role

This commit is contained in:
Hoang Nguyen 2022-07-23 18:43:38 +07:00
parent b72db7e5fa
commit b2f0cd6808
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
4 changed files with 59 additions and 0 deletions

View File

@ -102,6 +102,13 @@ opened_ports:
# 'podman' or 'nerdctl'
rootless_container_cli: podman
# earlyoom kills processes on its own so make it optional
earlyoom:
enabled: true
set_priority: true
mem_min_percent: 5,2
swap_min_percent: 10,5
# Configure waydroid base image
waydroid:
rom_type: lineage # lineage, bliss

View File

@ -0,0 +1,20 @@
---
- name: earlyoom | Install earlyoom package
apk:
name: earlyoom
state: present
- name: earlyoom | Copy service configuration
template:
src: conf.j2
dest: /etc/conf.d/earlyoom
mode: 0644
owner: root
group: root
- name: earlyoom | Start earlyoom service on runlevel 'default'
service:
name: earlyoom
runlevel: default
enabled: yes
state: started

View File

@ -0,0 +1,29 @@
# Configuration for /etc/init.d/earlyoom
{% if earlyoom.mem_min_percent is defined %}
# Set available memory minimum to PERCENT of total (default 10 %). [-m]
mem_min_percent={{ earlyoom.mem_min_percent }}
{% endif %}
{% if earlyoom.swap_min_percent is defined %}
# Set free swap minimum to PERCENT of total (default 10 %). [-s]
# Note: Both memory and swap must be below minimum for earlyoom to act.
swap_min_percent={{ earlyoom.swap_min_percent }}
{% endif %}
{% if earlyoom.mem_min_size is defined %}
# Set available memory minimum to SIZE[,KILL_SIZE] KiB. [-M]
mem_min_size={{ earlyoom.mem_min_size }}
{% endif %}
{% if earlyoom.swap_min_size is defined %}
# Set free swap minimum to SIZE[,KILL_SIZE] KiB. [-S]
swap_min_size={{ swap_min_size }}
{% endif %}
{% if earlyoom.set_priority %}
# Set niceness of earlyoom to -20 and oom_score_adj to -100? yes/no [-p]
set_priority=yes
{% endif%}
supervisor="supervise-daemon"

View File

@ -58,6 +58,9 @@
tags: usbguard
- role: zram
tags: zram
- role: earlyoom
tags: earlyoom
when: earlyoom.enabled
- role: user
tags: user
- role: container