Matrix Docker Ansible eploy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

103 lignes
3.9 KiB

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