1
0
mirror of https://github.com/azlux/log2ram synced 2024-11-27 15:44:07 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
2977823e71
Merge pull request #162 from rgm3/master
Update ansible playbook
2021-07-06 17:21:49 +02:00
rgm
193c41573c Update ansible playbook
Use new trusted.gpg.d keyring for apt key, improve idempotency,
only update cache when necessary, only restart service when necessary.
2021-07-05 08:12:23 -05:00

View File

@ -1,32 +1,76 @@
#!/usr/bin/env ansible-playbook
--- ---
# Configure Raspberry Pi to log to RAM, with occasional SD card sync
# to reduce SD card writes
# Usage: ansible-playbook -e 'log2ram_size=80M' install_log2ram.yml
- hosts: all - hosts: all
gather_facts: true
gather_subset: min
become: true become: true
vars:
apt_keyring_file: azlux.fr.log2ram.gpg
apt_sources_file: log2ram.list
log2ram_size: 40M
log2ram_path_disk: /var/log
log2ram_use_z2lr: true
log2ram_comp_alg: lz4
log2ram_log_disk_size: 100M
tasks: tasks:
- name: Add apt-key for new repository - name: "Add /etc/apt/sources.list.d/{{ apt_sources_file }}"
copy:
content: "deb http://packages.azlux.fr/debian/ {{ ansible_facts['distribution_release'] }} main\n"
dest: /etc/apt/sources.list.d/{{ apt_sources_file }}
mode: 0644
owner: root
register: source_list
- name: Import apt key
apt_key: apt_key:
keyserver: keyserver.ubuntu.com url: https://azlux.fr/repo.gpg.key
id: CA548A0A0312D8E6 id: 98B824A5FA7D3A10FDB225B7CA548A0A0312D8E6
- name: Add log2ram to sources.list keyring: /etc/apt/trusted.gpg.d/{{ apt_keyring_file }}
apt_repository: register: dl_key
repo: deb http://packages.azlux.fr/debian/ buster main
state: present - name: Remove tilde backup file {{ apt_keyring_file }}~
- name: update pkg database file:
path: /etc/apt/trusted.gpg.d/{{ apt_keyring_file }}~
state: absent
- name: update apt cache
apt: apt:
upgrade: yes update_cache: true
update_cache: yes when: dl_key is changed or source_list is changed
- name: Install log2ram - name: Install log2ram
apt: apt:
pkg: pkg:
- log2ram - log2ram
register: pkg
notify: Restart log2ram
- name: modify config - name: Set config options
lineinfile: lineinfile:
path: /etc/log2ram.conf path: /etc/log2ram.conf
regexp: '^SIZE=(.*)$' regexp: "{{ item.regexp }}"
line: 'SIZE=80M' line: "{{ item.line }}"
backrefs: yes backrefs: true
loop:
- {regexp: '^SIZE=(.*)$', line: 'SIZE={{ log2ram_size }}'}
- {regexp: '^PATH_DISK=(.*)$', line: 'PATH_DISK="{{ log2ram_path_disk }}"'}
- {regexp: '^ZL2R=(.*)$', line: 'ZL2R={{ log2ram_use_z2lr|lower }}'}
- {regexp: '^COMP_ALG=(.*)$', line: 'COMP_ALG={{ log2ram_comp_alg }}'}
- {regexp: '^LOG_DISK_SIZE=(.*)$', line: 'LOG_DISK_SIZE={{ log2ram_log_disk_size }}'}
notify: Restart log2ram
- name: Start log2ram service
handlers:
- name: Restart log2ram
systemd: systemd:
state: started
name: log2ram name: log2ram
state: restarted