refactor ♻️: Refactor installation logic and configure settings using loops
This refactoring simplifies the installation process by utilizing loops to handle repetitive tasks, improving readability and maintainability of the code.
This commit is contained in:
@@ -40,7 +40,8 @@
|
|||||||
mode: '0644'
|
mode: '0644'
|
||||||
register: download_archive
|
register: download_archive
|
||||||
|
|
||||||
- name: Installation Logic
|
- name: ram | Logic to extract and install log2ram
|
||||||
|
when: download_archive.changed # noqa: no-handler
|
||||||
block:
|
block:
|
||||||
- name: ram | Extract log2ram
|
- name: ram | Extract log2ram
|
||||||
ansible.builtin.unarchive:
|
ansible.builtin.unarchive:
|
||||||
@@ -55,23 +56,18 @@
|
|||||||
# 'creates' makes the command idempotent by checking for the binary
|
# 'creates' makes the command idempotent by checking for the binary
|
||||||
creates: /usr/local/bin/log2ram
|
creates: /usr/local/bin/log2ram
|
||||||
notify: Restart log2ram
|
notify: Restart log2ram
|
||||||
when: download_archive.changed
|
|
||||||
|
|
||||||
# Configure log2ram
|
# Configure log2ram
|
||||||
|
|
||||||
- name: ram | Configure log2ram size
|
- name: Configure log2ram settings
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/log2ram.conf
|
path: /etc/log2ram.conf
|
||||||
regexp: '^#?SIZE='
|
regexp: "{{ item.regexp }}"
|
||||||
line: "SIZE={{ log2ram_size }}"
|
line: "{{ item.line }}"
|
||||||
backup: yes
|
backup: yes
|
||||||
notify: Restart log2ram
|
loop:
|
||||||
|
- { regexp: '^#?SIZE=', line: "SIZE={{ log2ram_size }}" }
|
||||||
- name: ram | Enable rsync sync
|
- { regexp: '^#?USE_RSYNC=', line: "USE_RSYNC=true" }
|
||||||
ansible.builtin.lineinfile:
|
|
||||||
path: /etc/log2ram.conf
|
|
||||||
regexp: '^#?USE_RSYNC='
|
|
||||||
line: "USE_RSYNC=true"
|
|
||||||
notify: Restart log2ram
|
notify: Restart log2ram
|
||||||
|
|
||||||
# Keep journald fully in RAM
|
# Keep journald fully in RAM
|
||||||
|
|||||||
Reference in New Issue
Block a user