Matrix Docker Ansible eploy
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

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