Matrix Docker Ansible eploy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

103 lignes
4.0 KiB

  1. ---
  2. - name: Ensure Appservice Discord image is pulled
  3. docker_image:
  4. name: "{{ matrix_appservice_discord_docker_image }}"
  5. when: "matrix_appservice_discord_enabled"
  6. - name: Ensure Appservice Discord configuration path exists
  7. file:
  8. path: "{{ matrix_appservice_discord_base_path }}"
  9. state: directory
  10. mode: 0750
  11. owner: "{{ matrix_user_username }}"
  12. group: "{{ matrix_user_username }}"
  13. when: "matrix_appservice_discord_enabled"
  14. - name: Ensure Matrix Appservice Discord config installed
  15. copy:
  16. content: "{{ matrix_appservice_discord_configuration|to_nice_yaml }}"
  17. dest: "{{ matrix_appservice_discord_base_path }}/config.yaml"
  18. mode: 0644
  19. owner: "{{ matrix_user_username }}"
  20. group: "{{ matrix_user_username }}"
  21. when: "matrix_appservice_discord_enabled"
  22. - name: Ensure matrix-appservice-discord.service installed
  23. template:
  24. src: "{{ role_path }}/templates/ext/appservice-discord/systemd/matrix-appservice-discord.service.j2"
  25. dest: "/etc/systemd/system/matrix-appservice-discord.service"
  26. mode: 0644
  27. register: matrix_appservice_discord_systemd_service_result
  28. when: "matrix_appservice_discord_enabled"
  29. - name: Ensure systemd reloaded after matrix-appservice-discord.service installation
  30. service:
  31. daemon_reload: yes
  32. when: "matrix_appservice_discord_enabled and matrix_appservice_discord_systemd_service_result.changed"
  33. - name: Check if a matrix-appservice-discord registration file exists
  34. stat:
  35. path: "{{ matrix_appservice_discord_base_path }}/discord-registration.yaml"
  36. register: appservice_discord_registration_file
  37. when: "matrix_appservice_discord_enabled"
  38. - name: Generate matrix-appservice-discord discord-registration.yaml if it doesn't exist
  39. shell: >-
  40. /usr/bin/docker run --rm --name matrix-appservice-discord-gen
  41. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  42. --cap-drop=ALL
  43. -v {{ matrix_appservice_discord_base_path }}:/data:z
  44. {{ matrix_appservice_discord_docker_image }}
  45. node build/src/discordas.js
  46. -r
  47. -u "http://matrix-appservice-discord:9005"
  48. -c /data/config.yaml
  49. -f /data/discord-registration.yaml
  50. -l discord_bot
  51. when: "matrix_appservice_discord_enabled and not appservice_discord_registration_file.stat.exists"
  52. - set_fact:
  53. matrix_synapse_app_service_config_file_appservice_discord: '{{ matrix_appservice_discord_base_path }}/discord-registration.yml'
  54. when: "matrix_appservice_discord_enabled"
  55. - name: Check if a matrix-appservice-discord invite_link file exists
  56. stat:
  57. path: "{{ matrix_appservice_discord_base_path }}/invite_link"
  58. register: appservice_discord_link_generated
  59. when: "matrix_appservice_discord_enabled"
  60. - name: Generate your discord invite link
  61. shell: >-
  62. /usr/bin/docker run --rm --name matrix-appservice-discord-link-gen
  63. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  64. --cap-drop=ALL
  65. -v {{ matrix_appservice_discord_base_path }}:/data
  66. -w /data
  67. {{ matrix_appservice_discord_docker_image }}
  68. /bin/sh -c "node .././build/tools/addbot.js > invite_link"
  69. when: "matrix_appservice_discord_enabled and not appservice_discord_link_generated.stat.exists"
  70. - set_fact:
  71. matrix_synapse_container_additional_volumes: >
  72. {{ matrix_synapse_container_additional_volumes }}
  73. +
  74. {{ [{'src': '{{ matrix_appservice_discord_base_path }}/discord-registration.yaml', 'dst': '{{ matrix_synapse_app_service_config_file_appservice_discord }}', 'options': 'ro'}] }}
  75. when: "matrix_appservice_discord_enabled"
  76. - set_fact:
  77. matrix_synapse_app_service_config_files: >
  78. {{ matrix_synapse_app_service_config_files }}
  79. +
  80. {{ ["{{ matrix_synapse_app_service_config_file_appservice_discord }}"] | to_nice_json }}
  81. when: "matrix_appservice_discord_enabled"
  82. #
  83. # Tasks related to getting rid of matrix-appservice-discord (if it was previously enabled)
  84. #
  85. - name: Ensure matrix-appservice-discord.service doesn't exist
  86. file:
  87. path: "/etc/systemd/system/matrix-appservice-discord.service"
  88. state: absent
  89. when: "not matrix_appservice_discord_enabled"