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

139 строки
6.0 KiB

  1. ---
  2. - name: Ensure cactus comments paths exist
  3. ansible.builtin.file:
  4. path: "{{ item.path }}"
  5. state: directory
  6. mode: 0750
  7. owner: "{{ matrix_user_username }}"
  8. group: "{{ matrix_user_groupname }}"
  9. with_items:
  10. - {path: "{{ matrix_cactus_comments_base_path }}", when: true}
  11. - {path: "{{ matrix_cactus_comments_client_path }}", when: true}
  12. - {path: "{{ matrix_cactus_comments_container_tmp_path }}", when: true}
  13. - {path: "{{ matrix_cactus_comments_docker_src_files_path }}", when: matrix_cactus_comments_container_image_self_build}
  14. when: "item.when | bool"
  15. - name: Ensure cactus comments environment file created
  16. ansible.builtin.template:
  17. src: "{{ role_path }}/templates/env.j2"
  18. dest: "{{ matrix_cactus_comments_app_service_env_file }}"
  19. owner: "{{ matrix_user_username }}"
  20. group: "{{ matrix_user_groupname }}"
  21. mode: 0640
  22. - name: Ensure cactus comments appservice file created
  23. ansible.builtin.template:
  24. src: "{{ role_path }}/templates/cactus_appservice.yaml.j2"
  25. dest: "{{ matrix_cactus_comments_app_service_config_file }}"
  26. owner: "{{ matrix_user_username }}"
  27. group: "{{ matrix_user_groupname }}"
  28. mode: 0640
  29. - name: Ensure cactus comments image is pulled
  30. docker_image:
  31. name: "{{ matrix_cactus_comments_docker_image }}"
  32. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  33. force_source: "{{ matrix_cactus_comments_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  34. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_cactus_comments_docker_image_force_pull }}"
  35. when: "not matrix_cactus_comments_container_image_self_build | bool"
  36. register: result
  37. retries: "{{ matrix_container_retries_count }}"
  38. delay: "{{ matrix_container_retries_delay }}"
  39. until: result is not failed
  40. - name: Ensure cactus comments repository is present on self-build
  41. ansible.builtin.git:
  42. repo: "{{ matrix_cactus_comments_docker_repo }}"
  43. version: "{{ matrix_cactus_comments_docker_repo_version }}"
  44. dest: "{{ matrix_cactus_comments_docker_src_files_path }}"
  45. force: "yes"
  46. become: true
  47. become_user: "{{ matrix_user_username }}"
  48. register: matrix_cactus_comments_git_pull_results
  49. when: "matrix_cactus_comments_container_image_self_build | bool"
  50. - name: Ensure cactus comments image is built
  51. docker_image:
  52. name: "{{ matrix_cactus_comments_docker_image }}"
  53. source: build
  54. force_source: "{{ matrix_cactus_comments_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  55. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_git_pull_results.changed }}"
  56. build:
  57. dockerfile: Dockerfile
  58. path: "{{ matrix_cactus_comments_docker_src_files_path }}"
  59. pull: true
  60. when: "matrix_cactus_comments_container_image_self_build | bool"
  61. - block:
  62. - name: Download client binary to local folder
  63. ansible.builtin.get_url:
  64. url: "https://gitlab.com/cactus-comments/cactus-client/-/archive/v{{ matrix_cactus_comments_client_version }}/cactus-client-v{{ matrix_cactus_comments_client_version }}.tar.gz"
  65. dest: "/tmp/cactus-comments-{{ matrix_cactus_comments_client_version }}.tar.gz"
  66. mode: '0644'
  67. register: _download_client
  68. until: _download_client is succeeded
  69. retries: 5
  70. delay: 2
  71. check_mode: false
  72. - name: Unpack client
  73. ansible.builtin.unarchive:
  74. src: "/tmp/cactus-comments-{{ matrix_cactus_comments_client_version }}.tar.gz"
  75. dest: "/tmp/"
  76. remote_src: true
  77. mode: 0600
  78. check_mode: false
  79. - name: Propagate client javascript file
  80. ansible.builtin.copy:
  81. src: "/tmp/cactus-client-v{{ matrix_cactus_comments_client_version }}/src/cactus.js"
  82. remote_src: true
  83. dest: "{{ matrix_cactus_comments_client_path }}/cactus.js"
  84. mode: "{{ matrix_cactus_comments_client_file_permissions }}"
  85. owner: "{{ matrix_user_username }}"
  86. group: "{{ matrix_user_groupname }}"
  87. - name: Propagate client style file
  88. ansible.builtin.copy:
  89. src: "/tmp/cactus-client-v{{ matrix_cactus_comments_client_version }}/src/style.css"
  90. remote_src: true
  91. dest: "{{ matrix_cactus_comments_client_path }}/style.css"
  92. mode: "{{ matrix_cactus_comments_client_file_permissions }}"
  93. owner: "{{ matrix_user_username }}"
  94. group: "{{ matrix_user_groupname }}"
  95. when: matrix_cactus_comments_client_local_dir | length == 0
  96. - block:
  97. - name: Propagate locally distributed client javascreipt
  98. ansible.builtin.copy:
  99. src: "{{ matrix_cactus_comments_client_local_dir }}/src/cactus.js"
  100. dest: "{{ matrix_cactus_comments_client_path }}/cactus.js"
  101. mode: "{{ matrix_cactus_comments_client_file_permissions }}"
  102. owner: "{{ matrix_user_username }}"
  103. group: "{{ matrix_user_groupname }}"
  104. - name: Propagate locally distributed client style.css
  105. ansible.builtin.copy:
  106. src: "{{ matrix_cactus_comments_client_local_dir }}/src/style.css"
  107. dest: "{{ matrix_cactus_comments_client_path }}/style.css"
  108. mode: "{{ matrix_cactus_comments_client_file_permissions }}"
  109. owner: "{{ matrix_user_username }}"
  110. group: "{{ matrix_user_groupname }}"
  111. when: matrix_cactus_comments_client_local_dir | length > 0
  112. - name: Ensure matrix-cactus-comments.service installed
  113. ansible.builtin.template:
  114. src: "{{ role_path }}/templates/systemd/matrix-cactus-comments.service.j2"
  115. dest: "{{ matrix_systemd_path }}/matrix-cactus-comments.service"
  116. mode: 0644
  117. register: matrix_cactus_comments_systemd_service_result
  118. - name: Ensure systemd reloaded after matrix-cactus-comments.service installation
  119. ansible.builtin.service:
  120. daemon_reload: true
  121. when: "matrix_cactus_comments_systemd_service_result.changed | bool"
  122. - name: Ensure matrix-cactus-comments.service restarted, if necessary
  123. ansible.builtin.service:
  124. name: "matrix-cactus-comments.service"
  125. state: restarted