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.
 
 

95 lines
3.9 KiB

  1. ---
  2. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
  3. # We don't want to fail in such cases.
  4. - name: Fail if matrix-synapse role already executed
  5. fail:
  6. msg: >-
  7. The matrix-bridge-mautrix-twitter role needs to execute before the matrix-synapse role.
  8. when: "matrix_synapse_role_executed|default(False)"
  9. - set_fact:
  10. matrix_mautrix_twitter_requires_restart: false
  11. - name: Ensure Mautrix Twitter image is pulled
  12. docker_image:
  13. name: "{{ matrix_mautrix_twitter_docker_image }}"
  14. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  15. force_source: "{{ matrix_mautrix_twitter_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  16. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mautrix_twitter_docker_image_force_pull }}"
  17. when: matrix_mautrix_twitter_enabled|bool and not matrix_mautrix_twitter_container_image_self_build
  18. register: result
  19. retries: "{{ matrix_container_retries_count }}"
  20. delay: "{{ matrix_container_retries_delay }}"
  21. until: result is not failed
  22. - name: Ensure Mautrix Twitter paths exist
  23. file:
  24. path: "{{ item.path }}"
  25. state: directory
  26. mode: 0750
  27. owner: "{{ matrix_user_username }}"
  28. group: "{{ matrix_user_groupname }}"
  29. with_items:
  30. - {path: "{{ matrix_mautrix_twitter_base_path }}", when: true}
  31. - {path: "{{ matrix_mautrix_twitter_config_path }}", when: true}
  32. - {path: "{{ matrix_mautrix_twitter_data_path }}", when: true}
  33. - {path: "{{ matrix_mautrix_twitter_docker_src_files_path }}", when: "{{ matrix_mautrix_twitter_container_image_self_build }}"}
  34. when: item.when|bool
  35. - name: Ensure Mautrix Twitter repository is present on self-build
  36. git:
  37. repo: "{{ matrix_mautrix_twitter_container_image_self_build_repo }}"
  38. dest: "{{ matrix_mautrix_twitter_docker_src_files_path }}"
  39. # version: "{{ matrix_coturn_docker_image.split(':')[1] }}"
  40. force: "yes"
  41. become: true
  42. become_user: "{{ matrix_user_username }}"
  43. register: matrix_mautrix_twitter_git_pull_results
  44. when: "matrix_mautrix_twitter_enabled|bool and matrix_mautrix_twitter_container_image_self_build"
  45. - name: Ensure Mautrix Twitter Docker image is built
  46. docker_image:
  47. name: "{{ matrix_mautrix_twitter_docker_image }}"
  48. source: build
  49. force_source: "{{ matrix_mautrix_twitter_git_pull_results.changed }}"
  50. build:
  51. dockerfile: Dockerfile
  52. path: "{{ matrix_mautrix_twitter_docker_src_files_path }}"
  53. pull: true
  54. when: "matrix_mautrix_twitter_enabled|bool and matrix_mautrix_twitter_container_image_self_build|bool"
  55. - name: Ensure mautrix-twitter config.yaml installed
  56. copy:
  57. content: "{{ matrix_mautrix_twitter_configuration|to_nice_yaml(indent=2, width=999999) }}"
  58. dest: "{{ matrix_mautrix_twitter_config_path }}/config.yaml"
  59. mode: 0644
  60. owner: "{{ matrix_user_username }}"
  61. group: "{{ matrix_user_groupname }}"
  62. - name: Ensure mautrix-twitter registration.yaml installed
  63. copy:
  64. content: "{{ matrix_mautrix_twitter_registration|to_nice_yaml(indent=2, width=999999) }}"
  65. dest: "{{ matrix_mautrix_twitter_config_path }}/registration.yaml"
  66. mode: 0644
  67. owner: "{{ matrix_user_username }}"
  68. group: "{{ matrix_user_groupname }}"
  69. - name: Ensure matrix-mautrix-twitter.service installed
  70. template:
  71. src: "{{ role_path }}/templates/systemd/matrix-mautrix-twitter.service.j2"
  72. dest: "{{ matrix_systemd_path }}/matrix-mautrix-twitter.service"
  73. mode: 0644
  74. register: matrix_mautrix_twitter_systemd_service_result
  75. - name: Ensure systemd reloaded after matrix-mautrix-twitter.service installation
  76. service:
  77. daemon_reload: true
  78. when: "matrix_mautrix_twitter_systemd_service_result.changed"
  79. - name: Ensure matrix-mautrix-twitter.service restarted, if necessary
  80. service:
  81. name: "matrix-mautrix-twitter.service"
  82. state: restarted
  83. when: "matrix_mautrix_twitter_requires_restart|bool"