configurations-ansible/roles/zram/tasks/main.yml

38 lines
1.1 KiB
YAML
Raw Permalink Normal View History

2023-04-12 18:09:25 +02:00
---
# tasks file for zram
- ansible.builtin.debug:
msg: "ENABLED = {{ zram_enabled }}; zram-role; install and configure zram"
- when:
- "zram_enabled is true"
- "'global.update_only' not in ansible_run_tags"
block:
- name: Gather package facts
package_facts:
manager: auto
- name: Install zram-tools if not present
when: "'zram-tools' not in ansible_facts.packages"
block:
- include_tasks: "install_{{ ansible_os_family }}.yml"
- name: Populate service facts
ansible.builtin.service_facts:
- name: Configure zram-tools
when: "ansible_facts.services['zramswap.service'] is defined"
block:
- name: Update /etc/default/zramswap ALGO
replace:
path: /etc/default/zramswap
regexp: '^[#]?\s*ALGO=[A-Za-z0-9]+$'
replace: "ALGO={{zram_algo}}"
- name: Update /etc/default/zramswap PERCENT
replace:
path: /etc/default/zramswap
regexp: '^[#]?\s*PERCENT=[A-Za-z0-9]+$'
replace: "PERCENT={{zram_percent}}"