Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

92 строки
3.4 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-irc role needs to execute before the matrix-synapse role.
  8. when: "matrix_synapse_role_executed|default(False)"
  9. - name: Ensure Appservice IRC image is pulled
  10. docker_image:
  11. name: "{{ matrix_appservice_irc_docker_image }}"
  12. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  13. - name: Ensure Appservice IRC base directory exists
  14. file:
  15. path: "{{ matrix_appservice_irc_base_path }}"
  16. state: directory
  17. mode: 0750
  18. owner: "{{ matrix_user_username }}"
  19. group: "{{ matrix_user_username }}"
  20. - name: Ensure Matrix Appservice IRC config installed
  21. copy:
  22. content: "{{ matrix_appservice_irc_configuration|to_nice_yaml }}"
  23. dest: "{{ matrix_appservice_irc_base_path }}/config.yaml"
  24. mode: 0644
  25. owner: "{{ matrix_user_username }}"
  26. group: "{{ matrix_user_username }}"
  27. - name: Check if matrix-appservice-irc passkey exists
  28. stat:
  29. path: "{{ matrix_appservice_irc_base_path }}/passkey.pem"
  30. register: irc_passkey_file
  31. - name: Generate matrix-appservice-irc passkey if it doesn't exist
  32. shell: /usr/bin/openssl genpkey -out {{ matrix_appservice_irc_base_path }}/passkey.pem -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:2048
  33. when: "not irc_passkey_file.stat.exists"
  34. - name: Ensure matrix-appservice-irc.service installed
  35. template:
  36. src: "{{ role_path }}/templates/systemd/matrix-appservice-irc.service.j2"
  37. dest: "/etc/systemd/system/matrix-appservice-irc.service"
  38. mode: 0644
  39. register: matrix_appservice_irc_systemd_service_result
  40. - name: Ensure systemd reloaded after matrix-appservice-irc.service installation
  41. service:
  42. daemon_reload: yes
  43. when: "matrix_appservice_irc_systemd_service_result.changed"
  44. - name: Check if a matrix-appservice-irc registration file exists
  45. stat:
  46. path: "{{ matrix_appservice_irc_base_path }}/registration.yaml"
  47. register: appservice_irc_registration_file
  48. - name: Generate matrix-appservice-irc registration.yaml if it doesn't exist
  49. shell: >-
  50. /usr/bin/docker run --rm --name matrix-appservice-irc-gen
  51. --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
  52. --cap-drop=ALL \
  53. -v {{ matrix_appservice_irc_base_path }}:/data:z
  54. {{ matrix_appservice_irc_docker_image }}
  55. node app.js
  56. -r
  57. -f /data/registration.yaml
  58. -u "http://matrix-appservice-irc:9999"
  59. -c /data/config.yaml
  60. -l irc_bot
  61. when: "not appservice_irc_registration_file.stat.exists"
  62. # If the matrix-synapse role is not used, these variables may not exist.
  63. - set_fact:
  64. matrix_synapse_container_extra_arguments: >
  65. {{ matrix_synapse_container_extra_arguments|default([]) }}
  66. +
  67. {{ ["--mount type=bind,src={{ matrix_appservice_irc_base_path }}/registration.yaml,dst=/matrix-appservice-irc-registration.yaml,ro"] }}
  68. matrix_synapse_app_service_config_files: >
  69. {{ matrix_synapse_app_service_config_files|default([]) }}
  70. +
  71. {{ ["/matrix-appservice-irc-registration.yaml"] }}
  72. - name: Ensure IRC configuration directory permissions are correct
  73. file:
  74. path: "{{ matrix_appservice_irc_base_path }}"
  75. state: directory
  76. owner: "{{ matrix_user_username }}"
  77. group: "{{ matrix_user_username }}"
  78. recurse: true