Matrix Docker Ansible eploy
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

99 Zeilen
3.7 KiB

  1. ---
  2. - name: Ensure borg paths exist
  3. file:
  4. path: "{{ item.path }}"
  5. state: directory
  6. mode: 0750
  7. owner: "{{ matrix_user_username }}"
  8. group: "{{ matrix_user_groupname }}"
  9. with_items:
  10. - {path: "{{ matrix_backup_borg_config_path }}", when: true}
  11. - {path: "{{ matrix_backup_borg_docker_src_files_path }}", when: true}
  12. when: "item.when|bool"
  13. - name: Ensure borg config is created
  14. template:
  15. src: "{{ role_path }}/templates/config.yaml.j2"
  16. dest: "{{ matrix_backup_borg_config_path }}/config.yaml"
  17. owner: "{{ matrix_user_username }}"
  18. group: "{{ matrix_user_groupname }}"
  19. mode: 0640
  20. # the passwd file with correct username, UID and GID is mandatory to work with borg over ssh, otherwise ssh connections will fail
  21. - name: Ensure borg passwd is created
  22. template:
  23. src: "{{ role_path }}/templates/passwd.j2"
  24. dest: "{{ matrix_backup_borg_config_path }}/passwd"
  25. owner: "{{ matrix_user_username }}"
  26. group: "{{ matrix_user_groupname }}"
  27. mode: 0640
  28. - name: Ensure borg ssh key is created
  29. template:
  30. src: "{{ role_path }}/templates/sshkey.j2"
  31. dest: "{{ matrix_backup_borg_config_path }}/sshkey"
  32. owner: "{{ matrix_user_username }}"
  33. group: "{{ matrix_user_groupname }}"
  34. mode: 0600
  35. - name: Ensure borg image is pulled
  36. docker_image:
  37. name: "{{ matrix_backup_borg_docker_image }}"
  38. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  39. force_source: "{{ matrix_backup_borg_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  40. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_backup_borg_docker_image_force_pull }}"
  41. when: "not matrix_backup_borg_container_image_self_build|bool"
  42. register: result
  43. retries: "{{ matrix_container_retries_count }}"
  44. delay: "{{ matrix_container_retries_delay }}"
  45. until: result is not failed
  46. - name: Ensure borg repository is present on self-build
  47. git:
  48. repo: "{{ matrix_backup_borg_docker_repo }}"
  49. dest: "{{ matrix_backup_borg_docker_src_files_path }}"
  50. force: "yes"
  51. register: matrix_backup_borg_git_pull_results
  52. when: "matrix_backup_borg_container_image_self_build|bool"
  53. - name: Ensure borg image is built
  54. docker_image:
  55. name: "{{ matrix_backup_borg_docker_image }}"
  56. source: build
  57. force_source: "{{ matrix_backup_borg_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  58. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_git_pull_results.changed }}"
  59. build:
  60. dockerfile: Dockerfile
  61. path: "{{ matrix_backup_borg_docker_src_files_path }}"
  62. pull: true
  63. when: "matrix_backup_borg_container_image_self_build|bool"
  64. - name: Ensure matrix-backup-borg.service installed
  65. template:
  66. src: "{{ role_path }}/templates/systemd/matrix-backup-borg.service.j2"
  67. dest: "{{ matrix_systemd_path }}/matrix-backup-borg.service"
  68. mode: 0644
  69. register: matrix_backup_borg_systemd_service_result
  70. - name: Ensure matrix-backup-borg.timer installed
  71. template:
  72. src: "{{ role_path }}/templates/systemd/matrix-backup-borg.timer.j2"
  73. dest: "{{ matrix_systemd_path }}/matrix-backup-borg.timer"
  74. mode: 0644
  75. register: matrix_backup_borg_systemd_timer_result
  76. - name: Ensure systemd reloaded after matrix-backup-borg.service installation
  77. service:
  78. daemon_reload: true
  79. when: "matrix_backup_borg_systemd_service_result.changed|bool"
  80. - name: Ensure matrix-backup-borg.service enabled
  81. service:
  82. enabled: yes
  83. name: matrix-backup-borg.service
  84. - name: Ensure matrix-backup-borg.timer enabled
  85. service:
  86. enabled: yes
  87. name: matrix-backup-borg.timer