Matrix Docker Ansible eploy
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

113 řádky
4.6 KiB

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