Matrix Docker Ansible eploy
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 

81 行
3.2 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-telegram role needs to execute before the matrix-synapse role.
  8. when: "matrix_synapse_role_executed|default(False)"
  9. - name: Ensure Mautrix Telegram image is pulled
  10. docker_image:
  11. name: "{{ matrix_mautrix_telegram_docker_image }}"
  12. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  13. force_source: "{{ matrix_mautrix_telegram_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  14. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mautrix_telegram_docker_image_force_pull }}"
  15. - name: Ensure Mautrix Telegram base directory exists
  16. file:
  17. path: "{{ matrix_mautrix_telegram_base_path }}"
  18. state: directory
  19. mode: 0750
  20. owner: "{{ matrix_user_username }}"
  21. group: "{{ matrix_user_username }}"
  22. - name: Check if a mautrix-telegram configuration file exists
  23. stat:
  24. path: "{{ matrix_mautrix_telegram_base_path }}/config.yaml"
  25. register: mautrix_telegram_config_file_stat
  26. - name: Ensure Matrix Mautrix telegram config installed
  27. template:
  28. src: "{{ role_path }}/templates/config.yaml.j2"
  29. dest: "{{ matrix_mautrix_telegram_base_path }}/config.yaml"
  30. mode: 0644
  31. owner: "{{ matrix_user_username }}"
  32. group: "{{ matrix_user_username }}"
  33. when: "not mautrix_telegram_config_file_stat.stat.exists"
  34. - name: (Migration) Fix up old configuration
  35. lineinfile:
  36. path: "{{ matrix_mautrix_telegram_base_path }}/config.yaml"
  37. regexp: "{{ item.regexp }}"
  38. line: "{{ item.line }}"
  39. backrefs: yes
  40. with_items:
  41. - {'regexp': '^(\s+)filename: \./mautrix-telegram.log', 'line': '\1filename: /data/mautrix-telegram.log'}
  42. - {'regexp': '^(\s+)database:', 'line': '\1database: sqlite:////data/mautrix-telegram.db'}
  43. when: "mautrix_telegram_config_file_stat.stat.exists"
  44. - name: Ensure matrix-mautrix-telegram.service installed
  45. template:
  46. src: "{{ role_path }}/templates/systemd/matrix-mautrix-telegram.service.j2"
  47. dest: "/etc/systemd/system/matrix-mautrix-telegram.service"
  48. mode: 0644
  49. register: matrix_mautrix_telegram_systemd_service_result
  50. - name: Ensure systemd reloaded after matrix-mautrix-telegram.service installation
  51. service:
  52. daemon_reload: yes
  53. when: "matrix_mautrix_telegram_systemd_service_result.changed"
  54. - name: Check if a mautrix-telegram registration file exists
  55. stat:
  56. path: "{{ matrix_mautrix_telegram_base_path }}/registration.yaml"
  57. register: mautrix_telegram_registration_file_stat
  58. - name: Generate matrix-mautrix-telegram registration.yaml if it doesn't exist
  59. shell:
  60. cmd: >-
  61. /usr/bin/docker run
  62. --rm
  63. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  64. --cap-drop=ALL
  65. --name matrix-mautrix-telegram-gen
  66. -v {{ matrix_mautrix_telegram_base_path }}:/data:z
  67. {{ matrix_mautrix_telegram_docker_image }}
  68. python3 -m mautrix_telegram -g -c /data/config.yaml -r /data/registration.yaml
  69. when: "not mautrix_telegram_registration_file_stat.stat.exists"