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.
 
 

94 regels
3.4 KiB

  1. ---
  2. - name: Ensure Appservice IRC image is pulled
  3. docker_image:
  4. name: "{{ matrix_appservice_irc_docker_image }}"
  5. when: "matrix_appservice_irc_enabled"
  6. - name: Ensure Appservice IRC configuration path exists
  7. file:
  8. path: "{{ matrix_appservice_irc_base_path }}"
  9. state: directory
  10. mode: 0750
  11. owner: "{{ matrix_user_username }}"
  12. group: "{{ matrix_user_username }}"
  13. when: "matrix_appservice_irc_enabled"
  14. - name: Ensure Matrix Appservice IRC config installed
  15. copy:
  16. content: "{{ matrix_appservice_irc_configuration|to_nice_yaml }}"
  17. dest: "{{ matrix_appservice_irc_base_path }}/config.yaml"
  18. mode: 0644
  19. owner: "{{ matrix_user_username }}"
  20. group: "{{ matrix_user_username }}"
  21. when: "matrix_appservice_irc_enabled"
  22. - name: Check if matrix-appservice-irc passkey exists
  23. stat:
  24. path: "{{ matrix_appservice_irc_base_path }}/passkey.pem"
  25. register: irc_passkey_file
  26. when: "matrix_appservice_irc_enabled"
  27. - name: Generate matrix-appservice-irc passkey if it doesn't exist
  28. shell: /usr/bin/openssl genpkey -out {{ matrix_appservice_irc_base_path }}/passkey.pem -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:2048
  29. when: "matrix_appservice_irc_enabled and not irc_passkey_file.stat.exists"
  30. - name: Ensure matrix-appservice-irc.service installed
  31. template:
  32. src: "{{ role_path }}/templates/ext/appservice-irc/systemd/matrix-appservice-irc.service.j2"
  33. dest: "/etc/systemd/system/matrix-appservice-irc.service"
  34. mode: 0644
  35. register: matrix_appservice_irc_systemd_service_result
  36. when: "matrix_appservice_irc_enabled"
  37. - name: Ensure systemd reloaded after matrix-appservice-irc.service installation
  38. service:
  39. daemon_reload: yes
  40. when: "matrix_appservice_irc_enabled and matrix_appservice_irc_systemd_service_result.changed"
  41. - name: Check if a matrix-appservice-irc registration file exists
  42. stat:
  43. path: "{{ matrix_appservice_irc_base_path }}/registration.yaml"
  44. register: appservice_irc_registration_file
  45. when: "matrix_appservice_irc_enabled"
  46. - name: Generate matrix-appservice-irc registration.yaml if it doesn't exist
  47. shell: >-
  48. /usr/bin/docker run --rm --name matrix-appservice-irc-gen
  49. -v {{ matrix_appservice_irc_base_path }}:/data:z
  50. {{ matrix_appservice_irc_docker_image }}
  51. node app.js
  52. -r
  53. -f /data/registration.yaml
  54. -u "http://matrix-appservice-irc:9999"
  55. -c /data/config.yaml
  56. -l irc_bot
  57. when: "matrix_appservice_irc_enabled and not appservice_irc_registration_file.stat.exists"
  58. - set_fact:
  59. matrix_synapse_app_service_config_file_appservice_irc: '/app-registration/appservice-irc.yml'
  60. when: "matrix_appservice_irc_enabled"
  61. - set_fact:
  62. matrix_synapse_container_additional_volumes: >
  63. {{ matrix_synapse_container_additional_volumes }}
  64. +
  65. {{ [{'src': '{{ matrix_appservice_irc_base_path }}/registration.yaml', 'dst': '{{ matrix_synapse_app_service_config_file_appservice_irc }}', 'options': 'ro'}] }}
  66. when: "matrix_appservice_irc_enabled"
  67. - set_fact:
  68. matrix_synapse_app_service_config_files: >
  69. {{ matrix_synapse_app_service_config_files }}
  70. +
  71. {{ ["{{ matrix_synapse_app_service_config_file_appservice_irc }}"] | to_nice_json }}
  72. when: "matrix_appservice_irc_enabled"
  73. #
  74. # Tasks related to getting rid of matrix-appservice-irc (if it was previously enabled)
  75. #
  76. - name: Ensure matrix-appservice-irc.service doesn't exist
  77. file:
  78. path: "/etc/systemd/system/matrix-appservice-irc.service"
  79. state: absent
  80. when: "not matrix_appservice_irc_enabled"