Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

77 linhas
2.1 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. apt_keyring_file: azlux.fr.log2ram.gpg
  12. apt_sources_file: log2ram.list
  13. log2ram_size: 40M
  14. log2ram_path_disk: /var/log
  15. log2ram_use_z2lr: true
  16. log2ram_comp_alg: lz4
  17. log2ram_log_disk_size: 100M
  18. tasks:
  19. - name: "Add /etc/apt/sources.list.d/{{ apt_sources_file }}"
  20. copy:
  21. content: "deb http://packages.azlux.fr/debian/ {{ ansible_facts['distribution_release'] }} main\n"
  22. dest: /etc/apt/sources.list.d/{{ apt_sources_file }}
  23. mode: 0644
  24. owner: root
  25. register: source_list
  26. - name: Import apt key
  27. apt_key:
  28. url: https://azlux.fr/repo.gpg.key
  29. id: 98B824A5FA7D3A10FDB225B7CA548A0A0312D8E6
  30. keyring: /etc/apt/trusted.gpg.d/{{ apt_keyring_file }}
  31. register: dl_key
  32. - name: Remove tilde backup file {{ apt_keyring_file }}~
  33. file:
  34. path: /etc/apt/trusted.gpg.d/{{ apt_keyring_file }}~
  35. state: absent
  36. - name: update apt cache
  37. apt:
  38. update_cache: true
  39. when: dl_key is changed or source_list is changed
  40. - name: Install log2ram
  41. apt:
  42. pkg:
  43. - log2ram
  44. register: pkg
  45. notify: Restart log2ram
  46. - name: Set config options
  47. lineinfile:
  48. path: /etc/log2ram.conf
  49. regexp: "{{ item.regexp }}"
  50. line: "{{ item.line }}"
  51. backrefs: true
  52. loop:
  53. - {regexp: '^SIZE=(.*)$', line: 'SIZE={{ log2ram_size }}'}
  54. - {regexp: '^PATH_DISK=(.*)$', line: 'PATH_DISK="{{ log2ram_path_disk }}"'}
  55. - {regexp: '^ZL2R=(.*)$', line: 'ZL2R={{ log2ram_use_z2lr|lower }}'}
  56. - {regexp: '^COMP_ALG=(.*)$', line: 'COMP_ALG={{ log2ram_comp_alg }}'}
  57. - {regexp: '^LOG_DISK_SIZE=(.*)$', line: 'LOG_DISK_SIZE={{ log2ram_log_disk_size }}'}
  58. notify: Restart log2ram
  59. handlers:
  60. - name: Restart log2ram
  61. systemd:
  62. name: log2ram
  63. state: restarted