Matrix Docker Ansible eploy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

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