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.
 
 

109 rivejä
4.5 KiB

  1. # SPDX-FileCopyrightText: 2021 - 2024 Slavi Pantaleev
  2. # SPDX-FileCopyrightText: 2021 Matthew Cengia
  3. # SPDX-FileCopyrightText: 2022 Jim Myhrberg
  4. # SPDX-FileCopyrightText: 2022 Marko Weltzer
  5. # SPDX-FileCopyrightText: 2022 Nikita Chernyi
  6. # SPDX-FileCopyrightText: 2022 Sebastian Gumprich
  7. # SPDX-FileCopyrightText: 2024 David Mehren
  8. #
  9. # SPDX-License-Identifier: AGPL-3.0-or-later
  10. ---
  11. - ansible.builtin.set_fact:
  12. matrix_mautrix_twitter_requires_restart: false
  13. - name: Ensure Mautrix Twitter image is pulled
  14. community.docker.docker_image:
  15. name: "{{ matrix_mautrix_twitter_docker_image }}"
  16. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  17. force_source: "{{ matrix_mautrix_twitter_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  18. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mautrix_twitter_docker_image_force_pull }}"
  19. when: matrix_mautrix_twitter_enabled | bool and not matrix_mautrix_twitter_container_image_self_build
  20. register: result
  21. retries: "{{ devture_playbook_help_container_retries_count }}"
  22. delay: "{{ devture_playbook_help_container_retries_delay }}"
  23. until: result is not failed
  24. - name: Ensure Mautrix Twitter paths exist
  25. ansible.builtin.file:
  26. path: "{{ item.path }}"
  27. state: directory
  28. mode: 0750
  29. owner: "{{ matrix_user_name }}"
  30. group: "{{ matrix_group_name }}"
  31. with_items:
  32. - {path: "{{ matrix_mautrix_twitter_base_path }}", when: true}
  33. - {path: "{{ matrix_mautrix_twitter_config_path }}", when: true}
  34. - {path: "{{ matrix_mautrix_twitter_data_path }}", when: true}
  35. - {path: "{{ matrix_mautrix_twitter_docker_src_files_path }}", when: "{{ matrix_mautrix_twitter_container_image_self_build }}"}
  36. when: item.when | bool
  37. - name: Ensure Mautrix Twitter repository is present on self-build
  38. ansible.builtin.git:
  39. repo: "{{ matrix_mautrix_twitter_container_image_self_build_repo }}"
  40. version: "{{ matrix_mautrix_twitter_container_image_self_build_repo_version }}"
  41. dest: "{{ matrix_mautrix_twitter_docker_src_files_path }}"
  42. force: "yes"
  43. become: true
  44. become_user: "{{ matrix_user_name }}"
  45. register: matrix_mautrix_twitter_git_pull_results
  46. when: "matrix_mautrix_twitter_enabled | bool and matrix_mautrix_twitter_container_image_self_build"
  47. - name: Ensure Mautrix Twitter Docker image is built
  48. community.docker.docker_image:
  49. name: "{{ matrix_mautrix_twitter_docker_image }}"
  50. source: build
  51. force_source: "{{ matrix_mautrix_twitter_git_pull_results.changed }}"
  52. build:
  53. dockerfile: Dockerfile
  54. path: "{{ matrix_mautrix_twitter_docker_src_files_path }}"
  55. pull: true
  56. when: "matrix_mautrix_twitter_enabled | bool and matrix_mautrix_twitter_container_image_self_build | bool"
  57. - name: Ensure mautrix-twitter config.yaml installed
  58. ansible.builtin.copy:
  59. content: "{{ matrix_mautrix_twitter_configuration | to_nice_yaml(indent=2, width=999999) }}"
  60. dest: "{{ matrix_mautrix_twitter_config_path }}/config.yaml"
  61. mode: 0644
  62. owner: "{{ matrix_user_name }}"
  63. group: "{{ matrix_group_name }}"
  64. - name: Ensure mautrix-twitter registration.yaml installed
  65. ansible.builtin.copy:
  66. content: "{{ matrix_mautrix_twitter_registration | to_nice_yaml(indent=2, width=999999) }}"
  67. dest: "{{ matrix_mautrix_twitter_config_path }}/registration.yaml"
  68. mode: 0644
  69. owner: "{{ matrix_user_name }}"
  70. group: "{{ matrix_group_name }}"
  71. - name: Ensure mautrix-twitter support files installed
  72. ansible.builtin.template:
  73. src: "{{ role_path }}/templates/{{ item }}.j2"
  74. dest: "{{ matrix_mautrix_twitter_base_path }}/{{ item }}"
  75. mode: 0640
  76. owner: "{{ matrix_user_name }}"
  77. group: "{{ matrix_group_name }}"
  78. with_items:
  79. - labels
  80. - name: Ensure matrix-mautrix-twitter container network is created
  81. community.general.docker_network:
  82. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  83. name: "{{ matrix_mautrix_twitter_container_network }}"
  84. driver: bridge
  85. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  86. - name: Ensure matrix-mautrix-twitter.service installed
  87. ansible.builtin.template:
  88. src: "{{ role_path }}/templates/systemd/matrix-mautrix-twitter.service.j2"
  89. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-mautrix-twitter.service"
  90. mode: 0644
  91. - name: Ensure matrix-mautrix-twitter.service restarted, if necessary
  92. ansible.builtin.service:
  93. name: "matrix-mautrix-twitter.service"
  94. state: restarted
  95. daemon_reload: true
  96. when: "matrix_mautrix_twitter_requires_restart | bool"