Matrix Docker Ansible eploy
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

93 řádky
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-appservice-discord role needs to execute before the matrix-synapse role.
  8. when: "matrix_synapse_role_executed|default(False)"
  9. - name: Ensure Appservice Discord image is pulled
  10. docker_image:
  11. name: "{{ matrix_appservice_discord_docker_image }}"
  12. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  13. force_source: "{{ matrix_appservice_discord_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_appservice_discord_docker_image_force_pull }}"
  15. - name: Ensure Appservice Discord base directory exists
  16. file:
  17. path: "{{ matrix_appservice_discord_base_path }}"
  18. state: directory
  19. mode: 0750
  20. owner: "{{ matrix_user_username }}"
  21. group: "{{ matrix_user_username }}"
  22. - name: Ensure Matrix Appservice Discord config installed
  23. copy:
  24. content: "{{ matrix_appservice_discord_configuration|to_nice_yaml }}"
  25. dest: "{{ matrix_appservice_discord_base_path }}/config.yaml"
  26. mode: 0644
  27. owner: "{{ matrix_user_username }}"
  28. group: "{{ matrix_user_username }}"
  29. - name: Ensure matrix-appservice-discord.service installed
  30. template:
  31. src: "{{ role_path }}/templates/systemd/matrix-appservice-discord.service.j2"
  32. dest: "/etc/systemd/system/matrix-appservice-discord.service"
  33. mode: 0644
  34. register: matrix_appservice_discord_systemd_service_result
  35. - name: Ensure systemd reloaded after matrix-appservice-discord.service installation
  36. service:
  37. daemon_reload: yes
  38. when: "matrix_appservice_discord_systemd_service_result.changed"
  39. - name: Check if a matrix-appservice-discord registration file exists
  40. stat:
  41. path: "{{ matrix_appservice_discord_base_path }}/discord-registration.yaml"
  42. register: appservice_discord_registration_file
  43. - name: Generate matrix-appservice-discord discord-registration.yaml if it doesn't exist
  44. shell: >-
  45. /usr/bin/docker run --rm --name matrix-appservice-discord-gen
  46. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  47. --cap-drop=ALL
  48. -v {{ matrix_appservice_discord_base_path }}:/data:z
  49. {{ matrix_appservice_discord_docker_image }}
  50. node build/src/discordas.js
  51. -r
  52. -u "http://matrix-appservice-discord:9005"
  53. -c /data/config.yaml
  54. -f /data/discord-registration.yaml
  55. -l discord_bot
  56. when: "not appservice_discord_registration_file.stat.exists"
  57. - name: Check if a matrix-appservice-discord invite_link file exists
  58. stat:
  59. path: "{{ matrix_appservice_discord_base_path }}/invite_link"
  60. register: appservice_discord_link_generated
  61. - name: Generate your discord invite link
  62. shell: >-
  63. /usr/bin/docker run --rm --name matrix-appservice-discord-link-gen
  64. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  65. --cap-drop=ALL
  66. -v {{ matrix_appservice_discord_base_path }}:/data
  67. -w /data
  68. {{ matrix_appservice_discord_docker_image }}
  69. /bin/sh -c "node .././build/tools/addbot.js > invite_link"
  70. when: "not appservice_discord_link_generated.stat.exists"
  71. # If the matrix-synapse role is not used, these variables may not exist.
  72. - set_fact:
  73. matrix_synapse_container_extra_arguments: >
  74. {{ matrix_synapse_container_extra_arguments|default([]) }}
  75. +
  76. {{ ["--mount type=bind,src={{ matrix_appservice_discord_base_path }}/discord-registration.yaml,dst=/matrix-appservice-discord-registration.yaml,ro"] }}
  77. matrix_synapse_app_service_config_files: >
  78. {{ matrix_synapse_app_service_config_files|default([]) }}
  79. +
  80. {{ ["/matrix-appservice-discord-registration.yaml"] }}