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

101 строка
4.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-beeper-linkedin role needs to execute before the matrix-synapse role.
  8. when: "matrix_synapse_role_executed|default(False)"
  9. - name: Ensure Beeper LinkedIn paths exists
  10. file:
  11. path: "{{ item.path }}"
  12. state: directory
  13. mode: 0750
  14. owner: "{{ matrix_user_username }}"
  15. group: "{{ matrix_user_groupname }}"
  16. with_items:
  17. - {path: "{{ matrix_beeper_linkedin_base_path }}", when: true}
  18. - {path: "{{ matrix_beeper_linkedin_config_path }}", when: true}
  19. - {path: "{{ matrix_beeper_linkedin_data_path }}", when: true}
  20. - {path: "{{ matrix_beeper_linkedin_docker_src_files_path }}", when: "{{ matrix_beeper_linkedin_container_image_self_build }}"}
  21. when: "item.when|bool"
  22. - name: Ensure Beeper LinkedIn image is pulled
  23. docker_image:
  24. name: "{{ matrix_beeper_linkedin_docker_image }}"
  25. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  26. force_source: "{{ matrix_beeper_linkedin_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  27. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_beeper_linkedin_docker_image_force_pull }}"
  28. when: "not matrix_beeper_linkedin_container_image_self_build|bool"
  29. register: result
  30. retries: "{{ matrix_container_retries_count }}"
  31. delay: "{{ matrix_container_retries_delay }}"
  32. until: result is not failed
  33. - block:
  34. - name: Ensure Beeper LinkedIn repository is present on self-build
  35. git:
  36. repo: "{{ matrix_beeper_linkedin_container_image_self_build_repo }}"
  37. dest: "{{ matrix_beeper_linkedin_docker_src_files_path }}"
  38. version: "{{ matrix_beeper_linkedin_container_image_self_build_branch }}"
  39. force: "yes"
  40. become: true
  41. become_user: "{{ matrix_user_username }}"
  42. register: matrix_beeper_linkedin_git_pull_results
  43. # Building the container image (using the default Dockerfile) requires that a docker-requirements.txt file be generated.
  44. # See: https://gitlab.com/beeper/linkedin/-/blob/94442db17ccb9769b377cdb8e4bf1cb3955781d7/.gitlab-ci.yml#L30-40
  45. - name: Ensure docker-requirements.txt is generated before building Beeper LinkedIn Docker Image
  46. command: |
  47. {{ matrix_host_command_docker }} run \
  48. --rm \
  49. --entrypoint=/bin/sh \
  50. --mount type=bind,src={{ matrix_beeper_linkedin_docker_src_files_path }},dst=/work \
  51. -w /work \
  52. docker.io/python:3.9.6-buster \
  53. -c "pip install poetry && poetry export --without-hashes -E e2be -E images -E metrics | sed 's/==.*//g' > docker-requirements.txt"
  54. - name: Ensure Beeper LinkedIn Docker image is built
  55. docker_image:
  56. name: "{{ matrix_beeper_linkedin_docker_image }}"
  57. source: build
  58. force_source: "{{ matrix_beeper_linkedin_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  59. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_beeper_linkedin_git_pull_results.changed }}"
  60. build:
  61. dockerfile: Dockerfile
  62. path: "{{ matrix_beeper_linkedin_docker_src_files_path }}"
  63. pull: true
  64. args:
  65. TARGETARCH: "{{ matrix_architecture }}"
  66. when: "matrix_beeper_linkedin_container_image_self_build|bool"
  67. - name: Ensure beeper-linkedin config.yaml installed
  68. copy:
  69. content: "{{ matrix_beeper_linkedin_configuration|to_nice_yaml(indent=2, width=999999) }}"
  70. dest: "{{ matrix_beeper_linkedin_config_path }}/config.yaml"
  71. mode: 0644
  72. owner: "{{ matrix_user_username }}"
  73. group: "{{ matrix_user_groupname }}"
  74. - name: Ensure beeper-linkedin registration.yaml installed
  75. copy:
  76. content: "{{ matrix_beeper_linkedin_registration|to_nice_yaml(indent=2, width=999999) }}"
  77. dest: "{{ matrix_beeper_linkedin_config_path }}/registration.yaml"
  78. mode: 0644
  79. owner: "{{ matrix_user_username }}"
  80. group: "{{ matrix_user_groupname }}"
  81. - name: Ensure matrix-beeper-linkedin.service installed
  82. template:
  83. src: "{{ role_path }}/templates/systemd/matrix-beeper-linkedin.service.j2"
  84. dest: "{{ matrix_systemd_path }}/matrix-beeper-linkedin.service"
  85. mode: 0644
  86. register: matrix_beeper_linkedin_systemd_service_result
  87. - name: Ensure systemd reloaded after matrix-beeper-linkedin.service installation
  88. service:
  89. daemon_reload: true
  90. when: "matrix_beeper_linkedin_systemd_service_result.changed"