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

89 строки
3.5 KiB

  1. ---
  2. - import_tasks: "{{ role_path }}/../matrix-base/tasks/util/ensure_openssl_installed.yml"
  3. - name: Ensure hookshot image is pulled
  4. docker_image:
  5. name: "{{ matrix_hookshot_docker_image }}"
  6. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  7. force_source: "{{ matrix_hookshot_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  8. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_hookshot_docker_image_force_pull }}"
  9. register: result
  10. retries: "{{ matrix_container_retries_count }}"
  11. delay: "{{ matrix_container_retries_delay }}"
  12. until: result is not failed
  13. - name: Ensure hookshot paths exist
  14. file:
  15. path: "{{ item }}"
  16. state: directory
  17. mode: 0750
  18. owner: "{{ matrix_user_username }}"
  19. group: "{{ matrix_user_groupname }}"
  20. with_items:
  21. - "{{ matrix_hookshot_base_path }}"
  22. - name: Check if hookshot passkey exists
  23. stat:
  24. path: "{{ matrix_hookshot_base_path }}/passkey.pem"
  25. register: hookshot_passkey_file
  26. - name: Generate hookshot passkey if it doesn't exist
  27. shell: "{{ matrix_host_command_openssl }} genpkey -out {{ matrix_hookshot_base_path }}/passkey.pem -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:4096"
  28. become: true
  29. become_user: "{{ matrix_user_username }}"
  30. when: "not hookshot_passkey_file.stat.exists"
  31. - name: Ensure hookshot config.yml installed if provided
  32. copy:
  33. content: "{{ matrix_hookshot_configuration|to_nice_yaml(indent=2, width=999999) }}"
  34. dest: "{{ matrix_hookshot_base_path }}/config.yml"
  35. mode: 0644
  36. owner: "{{ matrix_user_username }}"
  37. group: "{{ matrix_user_groupname }}"
  38. - name: Validate hookshot config.yml
  39. command: |
  40. {{ matrix_host_command_docker }} run
  41. --rm
  42. --name={{ matrix_hookshot_container_url }}-validate
  43. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  44. --cap-drop=ALL
  45. -v {{ matrix_hookshot_base_path }}/config.yml:/config.yml
  46. {{ matrix_hookshot_docker_image }} node Config/Config.js /config.yml
  47. register: hookshot_config_validation_result
  48. - name: Fail if hookshot config.yml invalid
  49. fail:
  50. msg: "Your hookshot configuration did not pass validation:\n{{ hookshot_config_validation_result.stdout }}\n{{ hookshot_config_validation_result.stderr }}"
  51. when: "hookshot_config_validation_result.rc > 0"
  52. - name: Ensure hookshot registration.yml installed if provided
  53. copy:
  54. content: "{{ matrix_hookshot_registration|to_nice_yaml(indent=2, width=999999) }}"
  55. dest: "{{ matrix_hookshot_base_path }}/registration.yml"
  56. mode: 0644
  57. owner: "{{ matrix_user_username }}"
  58. group: "{{ matrix_user_groupname }}"
  59. - name: Ensure hookshot github private key file installed if github is enabled
  60. copy:
  61. content: "{{ matrix_hookshot_github_private_key }}"
  62. dest: "{{ matrix_hookshot_base_path }}/{{ matrix_hookshot_github_private_key_file }}"
  63. mode: 0400
  64. owner: "{{ matrix_user_username }}"
  65. group: "{{ matrix_user_groupname }}"
  66. when: matrix_hookshot_github_enabled|bool and matrix_hookshot_github_private_key|length > 0
  67. - name: Ensure matrix-hookshot.service installed
  68. template:
  69. src: "{{ role_path }}/templates/systemd/matrix-hookshot.service.j2"
  70. dest: "{{ matrix_systemd_path }}/matrix-hookshot.service"
  71. mode: 0644
  72. register: matrix_hookshot_systemd_service_result
  73. - name: Ensure systemd reloaded after matrix-hookshot.service installation
  74. service:
  75. daemon_reload: true
  76. when: matrix_hookshot_systemd_service_result.changed