Matrix Docker Ansible eploy
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

99 wiersze
4.5 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. register: matrix_beeper_linkedin_git_pull_results
  41. # Building the container image (using the default Dockerfile) requires that a docker-requirements.txt file be generated.
  42. # See: https://gitlab.com/beeper/linkedin/-/blob/94442db17ccb9769b377cdb8e4bf1cb3955781d7/.gitlab-ci.yml#L30-40
  43. - name: Ensure docker-requirements.txt is generated before building Beeper LinkedIn Docker Image
  44. command: |
  45. {{ matrix_host_command_docker }} run \
  46. --rm \
  47. --entrypoint=/bin/sh \
  48. --mount type=bind,src={{ matrix_beeper_linkedin_docker_src_files_path }},dst=/work \
  49. -w /work \
  50. docker.io/python:3.9.6-buster \
  51. -c "pip install poetry && poetry export --without-hashes -E e2be -E images -E metrics | sed 's/==.*//g' > docker-requirements.txt"
  52. - name: Ensure Beeper LinkedIn Docker image is built
  53. docker_image:
  54. name: "{{ matrix_beeper_linkedin_docker_image }}"
  55. source: build
  56. force_source: "{{ matrix_beeper_linkedin_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  57. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_beeper_linkedin_git_pull_results.changed }}"
  58. build:
  59. dockerfile: Dockerfile
  60. path: "{{ matrix_beeper_linkedin_docker_src_files_path }}"
  61. pull: true
  62. args:
  63. TARGETARCH: "{{ matrix_architecture }}"
  64. when: "matrix_beeper_linkedin_container_image_self_build|bool"
  65. - name: Ensure beeper-linkedin config.yaml installed
  66. copy:
  67. content: "{{ matrix_beeper_linkedin_configuration|to_nice_yaml(indent=2, width=999999) }}"
  68. dest: "{{ matrix_beeper_linkedin_config_path }}/config.yaml"
  69. mode: 0644
  70. owner: "{{ matrix_user_username }}"
  71. group: "{{ matrix_user_groupname }}"
  72. - name: Ensure beeper-linkedin registration.yaml installed
  73. copy:
  74. content: "{{ matrix_beeper_linkedin_registration|to_nice_yaml(indent=2, width=999999) }}"
  75. dest: "{{ matrix_beeper_linkedin_config_path }}/registration.yaml"
  76. mode: 0644
  77. owner: "{{ matrix_user_username }}"
  78. group: "{{ matrix_user_groupname }}"
  79. - name: Ensure matrix-beeper-linkedin.service installed
  80. template:
  81. src: "{{ role_path }}/templates/systemd/matrix-beeper-linkedin.service.j2"
  82. dest: "{{ matrix_systemd_path }}/matrix-beeper-linkedin.service"
  83. mode: 0644
  84. register: matrix_beeper_linkedin_systemd_service_result
  85. - name: Ensure systemd reloaded after matrix-beeper-linkedin.service installation
  86. service:
  87. daemon_reload: true
  88. when: "matrix_beeper_linkedin_systemd_service_result.changed"