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.
 
 

74 lines
3.3 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. when: "matrix_appservice_discord_enabled"
  28. - stat:
  29. path: "{{ matrix_appservice_discord_base_path }}/discord-registration.yaml"
  30. register: appservice_discord_registration_file
  31. - name: Generate matrix-appservice-discord discord-registration.yaml if it doesn't exist
  32. 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
  33. when: "matrix_appservice_discord_enabled and appservice_discord_registration_file.stat.exists == False"
  34. - set_fact:
  35. matrix_synapse_app_service_config_file_appservice_discord: '{{ matrix_appservice_discord_base_path }}/discord-registration.yml'
  36. - stat:
  37. path: "{{ matrix_appservice_discord_base_path }}/invite_link"
  38. register: appservice_discord_link_generated
  39. - name: Generate your discord invite link invite link
  40. 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"
  41. when: "matrix_appservice_discord_enabled and appservice_discord_link_generated.stat.exists == False"
  42. - set_fact:
  43. matrix_synapse_container_additional_volumes: >
  44. {{ matrix_synapse_container_additional_volumes }}
  45. +
  46. {{ [{'src': '{{ matrix_appservice_discord_base_path }}/discord-registration.yaml', 'dst': '{{ matrix_synapse_app_service_config_file_appservice_discord }}', 'options': 'ro'}] }}
  47. when: "matrix_appservice_discord_enabled"
  48. - set_fact:
  49. matrix_synapse_app_service_config_files: >
  50. {{ matrix_synapse_app_service_config_files }}
  51. +
  52. {{ ["{{ matrix_synapse_app_service_config_file_appservice_discord }}"] | to_nice_json }}
  53. when: "matrix_appservice_discord_enabled"
  54. #
  55. # Tasks related to getting rid of matrix-appservice-discord (if it was previously enabled)
  56. #
  57. - name: Ensure matrix-appservice-discord.service doesn't exist
  58. file:
  59. path: "/etc/systemd/system/matrix-appservice-discord.service"
  60. state: absent
  61. when: "not matrix_appservice_discord_enabled"