Matrix Docker Ansible eploy
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

99 líneas
4.2 KiB

  1. ---
  2. - block:
  3. - name: Check if an SQLite database already exists
  4. stat:
  5. path: "{{ matrix_appservice_discord_data_path }}/{{ matrix_appservice_discord_database_filename_name }}"
  6. register: matrix_appservice_discord_stat_sqlite_db
  7. - name: Fail if an SQLite database already exists when using Postgres
  8. fail:
  9. msg: >-
  10. matrix_appservice_discord_database_engine has been set to `postgres` (which is our new default now).
  11. However, we've discovered an existing SQLite database in {{ matrix_appservice_discord_data_path }}/{{ matrix_appservice_discord_database_filename_name }}.
  12. It appears that you've been using this bridge with the SQLite engine until now.
  13. To continue using SQLite, opt into it explicitly: add `matrix_appservice_discord_database_engine: sqlite` to your vars.yml file.
  14. To migrate to Postgres: TODO - migration instructions here.
  15. when: "matrix_appservice_discord_database_engine == 'postgres'"
  16. - name: Ensure Appservice Discord image is pulled
  17. docker_image:
  18. name: "{{ matrix_appservice_discord_docker_image }}"
  19. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  20. force_source: "{{ matrix_appservice_discord_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  21. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_appservice_discord_docker_image_force_pull }}"
  22. - name: Ensure AppService Discord paths exist
  23. file:
  24. path: "{{ item }}"
  25. state: directory
  26. mode: 0750
  27. owner: "{{ matrix_user_username }}"
  28. group: "{{ matrix_user_groupname }}"
  29. with_items:
  30. - "{{ matrix_appservice_discord_base_path }}"
  31. - "{{ matrix_appservice_discord_config_path }}"
  32. - "{{ matrix_appservice_discord_data_path }}"
  33. - name: Check if an old database file already exists
  34. stat:
  35. path: "{{ matrix_appservice_discord_base_path }}/discord.db"
  36. register: matrix_appservice_discord_stat_db
  37. - name: (Data relocation) Ensure matrix-appservice-discord.service is stopped
  38. service:
  39. name: matrix-appservice-discord
  40. state: stopped
  41. daemon_reload: yes
  42. failed_when: false
  43. when: "matrix_appservice_discord_stat_db.stat.exists"
  44. - name: (Data relocation) Move AppService Discord discord.db file to ./data directory
  45. command: "mv {{ matrix_appservice_discord_base_path }}/{{ item }} {{ matrix_appservice_discord_data_path }}/{{ item }}"
  46. with_items:
  47. - discord.db
  48. - user-store.db
  49. - room-store.db
  50. when: "matrix_appservice_discord_stat_db.stat.exists"
  51. - name: Ensure AppService Discord config.yaml installed
  52. copy:
  53. content: "{{ matrix_appservice_discord_configuration|to_nice_yaml }}"
  54. dest: "{{ matrix_appservice_discord_config_path }}/config.yaml"
  55. mode: 0644
  56. owner: "{{ matrix_user_username }}"
  57. group: "{{ matrix_user_groupname }}"
  58. - name: Ensure AppService Discord registration.yaml installed
  59. copy:
  60. content: "{{ matrix_appservice_discord_registration|to_nice_yaml }}"
  61. dest: "{{ matrix_appservice_discord_config_path }}/registration.yaml"
  62. mode: 0644
  63. owner: "{{ matrix_user_username }}"
  64. group: "{{ matrix_user_groupname }}"
  65. # If `matrix_appservice_discord_client_id` hasn't changed, the same invite link would be generated.
  66. # We intentionally suppress Ansible changes.
  67. - name: Generate AppService Discord invite link
  68. shell: >-
  69. {{ matrix_host_command_docker }} run --rm --name matrix-appservice-discord-link-gen
  70. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  71. --cap-drop=ALL
  72. --mount type=bind,src={{ matrix_appservice_discord_config_path }},dst=/cfg
  73. -w /cfg
  74. {{ matrix_appservice_discord_docker_image }}
  75. /bin/sh -c "node /build/tools/addbot.js > /cfg/invite_link"
  76. changed_when: false
  77. - name: Ensure matrix-appservice-discord.service installed
  78. template:
  79. src: "{{ role_path }}/templates/systemd/matrix-appservice-discord.service.j2"
  80. dest: "{{ matrix_systemd_path }}/matrix-appservice-discord.service"
  81. mode: 0644
  82. register: matrix_appservice_discord_systemd_service_result
  83. - name: Ensure systemd reloaded after matrix-appservice-discord.service installation
  84. service:
  85. daemon_reload: yes
  86. when: "matrix_appservice_discord_systemd_service_result.changed"