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.
 
 

80 lines
3.5 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. - stat:
  34. path: "{{ matrix_appservice_discord_base_path }}/discord-registration.yaml"
  35. register: appservice_discord_registration_file
  36. - name: Generate matrix-appservice-discord discord-registration.yaml if it doesn't exist
  37. shell: /usr/bin/docker run --rm --name matrix-appservice-discord-gen -v {{ matrix_appservice_discord_base_path }}:/data:z {{ matrix_appservice_discord_docker_image }} node build/src/discordas.js -r -u "http://matrix-appservice-discord:9005" -c /data/config.yaml -f /data/discord-registration.yaml -l discord_bot
  38. when: "matrix_appservice_discord_enabled and appservice_discord_registration_file.stat.exists == False"
  39. - set_fact:
  40. matrix_synapse_app_service_config_file_appservice_discord: '{{ matrix_appservice_discord_base_path }}/discord-registration.yml'
  41. - stat:
  42. path: "{{ matrix_appservice_discord_base_path }}/invite_link"
  43. register: appservice_discord_link_generated
  44. - name: Generate your discord invite link invite link
  45. shell: /usr/bin/docker run --rm --name matrix-appservice-discord-link-gen -v {{ matrix_appservice_discord_base_path }}:/data -w /data {{ matrix_appservice_discord_docker_image }} /bin/sh -c "node .././build/tools/addbot.js > invite_link"
  46. when: "matrix_appservice_discord_enabled and appservice_discord_link_generated.stat.exists == False"
  47. - set_fact:
  48. matrix_synapse_container_additional_volumes: >
  49. {{ matrix_synapse_container_additional_volumes }}
  50. +
  51. {{ [{'src': '{{ matrix_appservice_discord_base_path }}/discord-registration.yaml', 'dst': '{{ matrix_synapse_app_service_config_file_appservice_discord }}', 'options': 'ro'}] }}
  52. when: "matrix_appservice_discord_enabled"
  53. - set_fact:
  54. matrix_synapse_app_service_config_files: >
  55. {{ matrix_synapse_app_service_config_files }}
  56. +
  57. {{ ["{{ matrix_synapse_app_service_config_file_appservice_discord }}"] | to_nice_json }}
  58. when: "matrix_appservice_discord_enabled"
  59. #
  60. # Tasks related to getting rid of matrix-appservice-discord (if it was previously enabled)
  61. #
  62. - name: Ensure matrix-appservice-discord.service doesn't exist
  63. file:
  64. path: "/etc/systemd/system/matrix-appservice-discord.service"
  65. state: absent
  66. when: "not matrix_appservice_discord_enabled"