Matrix Docker Ansible eploy
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

100 wiersze
3.6 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. - name: Ensure borg passwd is created
  21. template:
  22. src: "{{ role_path }}/templates/passwd.j2"
  23. dest: "{{ matrix_backup_borg_config_path }}/passwd"
  24. owner: "{{ matrix_user_username }}"
  25. group: "{{ matrix_user_groupname }}"
  26. mode: 0640
  27. - name: Ensure borg ssh key is created
  28. template:
  29. src: "{{ role_path }}/templates/sshkey.j2"
  30. dest: "{{ matrix_backup_borg_config_path }}/sshkey"
  31. owner: "{{ matrix_user_username }}"
  32. group: "{{ matrix_user_groupname }}"
  33. mode: 0600
  34. - name: Ensure borg image is pulled
  35. docker_image:
  36. name: "{{ matrix_backup_borg_docker_image }}"
  37. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  38. force_source: "{{ matrix_backup_borg_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  39. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_backup_borg_docker_image_force_pull }}"
  40. when: "not matrix_backup_borg_container_image_self_build|bool"
  41. register: result
  42. retries: "{{ matrix_container_retries_count }}"
  43. delay: "{{ matrix_container_retries_delay }}"
  44. until: result is not failed
  45. - name: Ensure borg repository is present on self-build
  46. git:
  47. repo: "{{ matrix_backup_borg_docker_repo }}"
  48. dest: "{{ matrix_backup_borg_docker_src_files_path }}"
  49. force: "yes"
  50. become: true
  51. become_user: "{{ matrix_user_username }}"
  52. register: matrix_backup_borg_git_pull_results
  53. when: "matrix_backup_borg_container_image_self_build|bool"
  54. - name: Ensure borg image is built
  55. docker_image:
  56. name: "{{ matrix_backup_borg_docker_image }}"
  57. source: build
  58. force_source: "{{ matrix_backup_borg_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  59. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_git_pull_results.changed }}"
  60. build:
  61. dockerfile: Dockerfile
  62. path: "{{ matrix_backup_borg_docker_src_files_path }}"
  63. pull: true
  64. when: "matrix_backup_borg_container_image_self_build|bool"
  65. - name: Ensure matrix-backup-borg.service installed
  66. template:
  67. src: "{{ role_path }}/templates/systemd/matrix-backup-borg.service.j2"
  68. dest: "{{ matrix_systemd_path }}/matrix-backup-borg.service"
  69. mode: 0644
  70. register: matrix_backup_borg_systemd_service_result
  71. - name: Ensure matrix-backup-borg.timer installed
  72. template:
  73. src: "{{ role_path }}/templates/systemd/matrix-backup-borg.timer.j2"
  74. dest: "{{ matrix_systemd_path }}/matrix-backup-borg.timer"
  75. mode: 0644
  76. register: matrix_backup_borg_systemd_timer_result
  77. - name: Ensure systemd reloaded after matrix-backup-borg.service installation
  78. service:
  79. daemon_reload: true
  80. when: "matrix_backup_borg_systemd_service_result.changed|bool"
  81. - name: Ensure matrix-backup-borg.service enabled
  82. service:
  83. enabled: true
  84. name: matrix-backup-borg.service
  85. - name: Ensure matrix-backup-borg.timer enabled
  86. service:
  87. enabled: true
  88. name: matrix-backup-borg.timer