Matrix Docker Ansible eploy
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 

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