mirror of
https://github.com/azlux/log2ram
synced 2024-11-23 22:06:10 +00:00
Compare commits
No commits in common. "2977823e7163f0f62d51f7c7753defa87fc50342" and "f570ff6e4bde5b019fd601853e503679e042868b" have entirely different histories.
2977823e71
...
f570ff6e4b
@ -1,76 +1,32 @@
|
|||||||
#!/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 /etc/apt/sources.list.d/{{ apt_sources_file }}"
|
- name: Add apt-key for new repository
|
||||||
copy:
|
apt_key:
|
||||||
content: "deb http://packages.azlux.fr/debian/ {{ ansible_facts['distribution_release'] }} main\n"
|
keyserver: keyserver.ubuntu.com
|
||||||
dest: /etc/apt/sources.list.d/{{ apt_sources_file }}
|
id: CA548A0A0312D8E6
|
||||||
mode: 0644
|
- name: Add log2ram to sources.list
|
||||||
owner: root
|
apt_repository:
|
||||||
register: source_list
|
repo: deb http://packages.azlux.fr/debian/ buster main
|
||||||
|
state: present
|
||||||
|
- name: update pkg database
|
||||||
|
apt:
|
||||||
|
upgrade: yes
|
||||||
|
update_cache: yes
|
||||||
|
- name: Install log2ram
|
||||||
|
apt:
|
||||||
|
pkg:
|
||||||
|
- log2ram
|
||||||
|
|
||||||
- name: Import apt key
|
- name: modify config
|
||||||
apt_key:
|
lineinfile:
|
||||||
url: https://azlux.fr/repo.gpg.key
|
path: /etc/log2ram.conf
|
||||||
id: 98B824A5FA7D3A10FDB225B7CA548A0A0312D8E6
|
regexp: '^SIZE=(.*)$'
|
||||||
keyring: /etc/apt/trusted.gpg.d/{{ apt_keyring_file }}
|
line: 'SIZE=80M'
|
||||||
register: dl_key
|
backrefs: yes
|
||||||
|
|
||||||
- name: Remove tilde backup file {{ apt_keyring_file }}~
|
- name: Start log2ram service
|
||||||
file:
|
systemd:
|
||||||
path: /etc/apt/trusted.gpg.d/{{ apt_keyring_file }}~
|
state: started
|
||||||
state: absent
|
name: log2ram
|
||||||
|
|
||||||
- name: update apt cache
|
|
||||||
apt:
|
|
||||||
update_cache: true
|
|
||||||
when: dl_key is changed or source_list is changed
|
|
||||||
|
|
||||||
- name: Install log2ram
|
|
||||||
apt:
|
|
||||||
pkg:
|
|
||||||
- log2ram
|
|
||||||
register: pkg
|
|
||||||
notify: Restart log2ram
|
|
||||||
|
|
||||||
- name: Set config options
|
|
||||||
lineinfile:
|
|
||||||
path: /etc/log2ram.conf
|
|
||||||
regexp: "{{ item.regexp }}"
|
|
||||||
line: "{{ item.line }}"
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
handlers:
|
|
||||||
- name: Restart log2ram
|
|
||||||
systemd:
|
|
||||||
name: log2ram
|
|
||||||
state: restarted
|
|
||||||
|
Loading…
Reference in New Issue
Block a user