Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

69 lines
3.0 KiB

  1. ---
  2. - name: Ensure Email2Matrix paths exist
  3. ansible.builtin.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_email2matrix_base_path }}", when: true}
  11. - {path: "{{ matrix_email2matrix_config_dir_path }}", when: true}
  12. - {path: "{{ matrix_email2matrix_docker_src_files_path }}", when: "{{ matrix_email2matrix_container_image_self_build }}"}
  13. when: "item.when | bool"
  14. - name: Ensure Email2Matrix configuration file created
  15. ansible.builtin.template:
  16. src: "{{ role_path }}/templates/config.json.j2"
  17. dest: "{{ matrix_email2matrix_config_dir_path }}/config.json"
  18. owner: "{{ matrix_user_username }}"
  19. group: "{{ matrix_user_groupname }}"
  20. mode: 0640
  21. - name: Ensure Email2Matrix image is pulled
  22. community.docker.docker_image:
  23. name: "{{ matrix_email2matrix_docker_image }}"
  24. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  25. force_source: "{{ matrix_email2matrix_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  26. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_email2matrix_docker_image_force_pull }}"
  27. when: "not matrix_email2matrix_container_image_self_build | bool"
  28. register: result
  29. retries: "{{ devture_playbook_help_container_retries_count }}"
  30. delay: "{{ devture_playbook_help_container_retries_delay }}"
  31. until: result is not failed
  32. - name: Ensure Email2Matrix repository is present on self-build
  33. ansible.builtin.git:
  34. repo: "{{ matrix_email2matrix_container_image_self_build_repo }}"
  35. dest: "{{ matrix_email2matrix_docker_src_files_path }}"
  36. version: "{{ matrix_email2matrix_container_image_self_build_branch }}"
  37. force: "yes"
  38. become: true
  39. become_user: "{{ matrix_user_username }}"
  40. register: matrix_email2matrix_git_pull_results
  41. when: "matrix_email2matrix_container_image_self_build | bool"
  42. - name: Ensure Email2Matrix Docker image is built
  43. community.docker.docker_image:
  44. name: "{{ matrix_email2matrix_docker_image }}"
  45. source: build
  46. force_source: "{{ matrix_email2matrix_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  47. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_email2matrix_git_pull_results.changed }}"
  48. build:
  49. dockerfile: etc/docker/Dockerfile
  50. path: "{{ matrix_email2matrix_docker_src_files_path }}"
  51. pull: true
  52. when: "matrix_email2matrix_container_image_self_build | bool"
  53. - name: Ensure matrix-email2matrix container network is created
  54. community.general.docker_network:
  55. name: "{{ matrix_email2matrix_container_network }}"
  56. driver: bridge
  57. - name: Ensure matrix-email2matrix.service installed
  58. ansible.builtin.template:
  59. src: "{{ role_path }}/templates/systemd/matrix-email2matrix.service.j2"
  60. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-email2matrix.service"
  61. mode: 0644