Matrix Docker Ansible eploy
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

93 linhas
3.8 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. register: matrix_mautrix_twitter_git_pull_results
  42. when: "matrix_mautrix_twitter_enabled|bool and matrix_mautrix_twitter_container_image_self_build"
  43. - name: Ensure Mautrix Twitter Docker image is built
  44. docker_image:
  45. name: "{{ matrix_mautrix_twitter_docker_image }}"
  46. source: build
  47. force_source: "{{ matrix_mautrix_twitter_git_pull_results.changed }}"
  48. build:
  49. dockerfile: Dockerfile
  50. path: "{{ matrix_mautrix_twitter_docker_src_files_path }}"
  51. pull: true
  52. when: "matrix_mautrix_twitter_enabled|bool and matrix_mautrix_twitter_container_image_self_build|bool"
  53. - name: Ensure mautrix-twitter config.yaml installed
  54. copy:
  55. content: "{{ matrix_mautrix_twitter_configuration|to_nice_yaml(indent=2, width=999999) }}"
  56. dest: "{{ matrix_mautrix_twitter_config_path }}/config.yaml"
  57. mode: 0644
  58. owner: "{{ matrix_user_username }}"
  59. group: "{{ matrix_user_groupname }}"
  60. - name: Ensure mautrix-twitter registration.yaml installed
  61. copy:
  62. content: "{{ matrix_mautrix_twitter_registration|to_nice_yaml(indent=2, width=999999) }}"
  63. dest: "{{ matrix_mautrix_twitter_config_path }}/registration.yaml"
  64. mode: 0644
  65. owner: "{{ matrix_user_username }}"
  66. group: "{{ matrix_user_groupname }}"
  67. - name: Ensure matrix-mautrix-twitter.service installed
  68. template:
  69. src: "{{ role_path }}/templates/systemd/matrix-mautrix-twitter.service.j2"
  70. dest: "{{ matrix_systemd_path }}/matrix-mautrix-twitter.service"
  71. mode: 0644
  72. register: matrix_mautrix_twitter_systemd_service_result
  73. - name: Ensure systemd reloaded after matrix-mautrix-twitter.service installation
  74. service:
  75. daemon_reload: true
  76. when: "matrix_mautrix_twitter_systemd_service_result.changed"
  77. - name: Ensure matrix-mautrix-twitter.service restarted, if necessary
  78. service:
  79. name: "matrix-mautrix-twitter.service"
  80. state: restarted
  81. when: "matrix_mautrix_twitter_requires_restart|bool"