Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

84 рядки
2.5 KiB

  1. #!/usr/bin/env ansible-playbook
  2. ---
  3. # Configure Raspberry Pi to log to RAM, with occasional SD card sync
  4. # to reduce SD card writes
  5. # Usage: ansible-playbook -e 'log2ram_size=80M' install_log2ram.yml
  6. - hosts: all
  7. gather_facts: true
  8. gather_subset: min
  9. become: true
  10. vars:
  11. log2ram_repo_url: http://packages.azlux.fr
  12. log2ram_gpg: https://azlux.fr/repo.gpg
  13. log2ram_keyring: /usr/share/keyrings/azlux-archive-keyring.gpg
  14. log2ram_apt_repository: "deb [signed-by={{ log2ram_keyring }}] {{ log2ram_repo_url }}/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} main"
  15. log2ram_size: 128M
  16. log2ram_use_rsync: true
  17. log2ram_notification: true
  18. log2ram_notification_command: 'mail -s "Log2Ram Error on $HOSTNAME"'
  19. log2ram_path_disk: /var/log
  20. log2ram_use_z2lr: false
  21. log2ram_comp_alg: lz4
  22. log2ram_log_disk_size: 256M
  23. tasks:
  24. - name: Add rsync as pre-requisite
  25. apt:
  26. name: rsync
  27. when: log2ram_use_rsync
  28. - name: Install GnuPG
  29. apt:
  30. name: gnupg
  31. - name: Add gpg key
  32. shell:
  33. cmd: >
  34. curl -fsSL {{ log2ram_gpg }} | gpg --dearmor --yes -o {{ log2ram_keyring }}
  35. creates: "{{ log2ram_keyring }}"
  36. - name: Add apt repository
  37. apt_repository:
  38. repo: "{{ log2ram_apt_repository }}"
  39. filename: log2ram
  40. register: log2ram_apt_repo
  41. - name: Update apt cache
  42. apt:
  43. update_cache: true
  44. when: log2ram_apt_repo is changed
  45. - name: Install log2ram
  46. apt:
  47. name: log2ram
  48. notify: Restart log2ram
  49. - name: Set config options
  50. lineinfile:
  51. path: /etc/log2ram.conf
  52. regexp: "{{ item.regexp }}"
  53. line: "{{ item.line }}"
  54. backrefs: true
  55. loop:
  56. - {regexp: '^SIZE=(.*)$', line: 'SIZE={{ log2ram_size }}'}
  57. - {regexp: 'USE_RSYNC=(.*)$', line: 'USE_RSYNC={{ log2ram_use_rsync }}'}
  58. - {regexp: '^NOTIFICATION=(.*)$', line: 'NOTIFICATION={{ log2ram_notification }}'}
  59. - {regexp: '^NOTIFICATION_COMMAND=(.*)$', line: 'NOTIFICATION_COMMAND={{ log2ram_notification_command }}'}
  60. - {regexp: '^PATH_DISK=(.*)$', line: 'PATH_DISK="{{ log2ram_path_disk }}"'}
  61. - {regexp: '^ZL2R=(.*)$', line: 'ZL2R={{ log2ram_use_z2lr|lower }}'}
  62. - {regexp: '^COMP_ALG=(.*)$', line: 'COMP_ALG={{ log2ram_comp_alg }}'}
  63. - {regexp: '^LOG_DISK_SIZE=(.*)$', line: 'LOG_DISK_SIZE={{ log2ram_log_disk_size }}'}
  64. notify: Restart log2ram
  65. handlers:
  66. - name: Restart log2ram
  67. systemd:
  68. name: log2ram
  69. state: restarted