Matrix Docker Ansible eploy
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

133 satır
6.5 KiB

  1. # SPDX-FileCopyrightText: 2021 - 2024 Slavi Pantaleev
  2. # SPDX-FileCopyrightText: 2021 Alexandar Mechev
  3. # SPDX-FileCopyrightText: 2022 Cody Wyatt Neiman
  4. # SPDX-FileCopyrightText: 2022 Jim Myhrberg
  5. # SPDX-FileCopyrightText: 2022 Marko Weltzer
  6. # SPDX-FileCopyrightText: 2022 Nikita Chernyi
  7. # SPDX-FileCopyrightText: 2022 Sebastian Gumprich
  8. # SPDX-FileCopyrightText: 2024 David Mehren
  9. #
  10. # SPDX-License-Identifier: AGPL-3.0-or-later
  11. ---
  12. - name: Ensure Beeper LinkedIn paths exists
  13. ansible.builtin.file:
  14. path: "{{ item.path }}"
  15. state: directory
  16. mode: '0750'
  17. owner: "{{ matrix_user_name }}"
  18. group: "{{ matrix_group_name }}"
  19. with_items:
  20. - {path: "{{ matrix_bridge_beeper_linkedin_base_path }}", when: true}
  21. - {path: "{{ matrix_bridge_beeper_linkedin_config_path }}", when: true}
  22. - {path: "{{ matrix_bridge_beeper_linkedin_data_path }}", when: true}
  23. - {path: "{{ matrix_bridge_beeper_linkedin_container_src_files_path }}", when: "{{ matrix_bridge_beeper_linkedin_container_image_self_build }}"}
  24. when: "item.when | bool"
  25. - name: Ensure beeper-linkedin config.yaml installed
  26. ansible.builtin.copy:
  27. content: "{{ matrix_bridge_beeper_linkedin_configuration | to_nice_yaml(indent=2, width=999999) }}"
  28. dest: "{{ matrix_bridge_beeper_linkedin_config_path }}/config.yaml"
  29. mode: '0644'
  30. owner: "{{ matrix_user_name }}"
  31. group: "{{ matrix_group_name }}"
  32. register: matrix_bridge_beeper_linkedin_config_result
  33. - name: Ensure beeper-linkedin registration.yaml installed
  34. ansible.builtin.copy:
  35. content: "{{ matrix_bridge_beeper_linkedin_registration | to_nice_yaml(indent=2, width=999999) }}"
  36. dest: "{{ matrix_bridge_beeper_linkedin_config_path }}/registration.yaml"
  37. mode: '0644'
  38. owner: "{{ matrix_user_name }}"
  39. group: "{{ matrix_group_name }}"
  40. register: matrix_bridge_beeper_linkedin_registration_result
  41. - name: Ensure Beeper LinkedIn container image is pulled
  42. community.docker.docker_image_pull:
  43. name: "{{ matrix_bridge_beeper_linkedin_container_image }}"
  44. pull: always
  45. when: "not matrix_bridge_beeper_linkedin_container_image_self_build | bool"
  46. register: matrix_bridge_beeper_linkedin_container_image_pull_result
  47. retries: "{{ devture_playbook_help_container_retries_count }}"
  48. delay: "{{ devture_playbook_help_container_retries_delay }}"
  49. until: matrix_bridge_beeper_linkedin_container_image_pull_result is not failed
  50. - when: "matrix_bridge_beeper_linkedin_container_image_self_build | bool"
  51. block:
  52. # A checkout owned by a different user (a uid change, an earlier clone by another user, etc.) would make the git task below fail on ownership or permissions.
  53. - name: Ensure Beeper LinkedIn repository ownership is correct on self-build
  54. ansible.builtin.file:
  55. path: "{{ matrix_bridge_beeper_linkedin_container_src_files_path }}"
  56. state: directory
  57. owner: "{{ matrix_user_name }}"
  58. group: "{{ matrix_group_name }}"
  59. recurse: true
  60. - name: Ensure Beeper LinkedIn repository is present on self-build
  61. ansible.builtin.git:
  62. repo: "{{ matrix_bridge_beeper_linkedin_container_image_self_build_repo }}"
  63. dest: "{{ matrix_bridge_beeper_linkedin_container_src_files_path }}"
  64. version: "{{ matrix_bridge_beeper_linkedin_container_image_self_build_branch }}"
  65. force: "yes"
  66. become: true
  67. become_user: "{{ matrix_user_name }}"
  68. # Keep this even though the task above normalizes ownership. Git may still see an ownership mismatch when Ansible becomes an unprivileged user (see #5065).
  69. environment:
  70. GIT_CONFIG_COUNT: "1"
  71. GIT_CONFIG_KEY_0: safe.directory
  72. GIT_CONFIG_VALUE_0: "{{ matrix_bridge_beeper_linkedin_container_src_files_path }}"
  73. register: matrix_bridge_beeper_linkedin_git_pull_results
  74. # Building the container image (using the default Dockerfile) requires that a docker-requirements.txt file be generated.
  75. # See: https://github.com/beeper/linkedin/blob/94442db17ccb9769b377cdb8e4bf1cb3955781d7/.gitlab-ci.yml#L30-40
  76. - name: Ensure docker-requirements.txt is generated before building Beeper LinkedIn container image
  77. ansible.builtin.command:
  78. cmd: |
  79. {{ devture_systemd_docker_base_host_command_docker }} run
  80. --rm
  81. --entrypoint=/bin/sh
  82. --mount type=bind,src={{ matrix_bridge_beeper_linkedin_container_src_files_path }},dst=/work
  83. -w /work
  84. docker.io/python:3.9.6-buster
  85. -c "pip install poetry && poetry export --without-hashes -E e2be -E images -E metrics | sed 's/==.*//g' > docker-requirements.txt"
  86. register: matrix_bridge_beeper_linkedin_generate_docker_requirements_result
  87. changed_when: matrix_bridge_beeper_linkedin_generate_docker_requirements_result.rc == 0
  88. - name: Ensure Beeper LinkedIn container image is built
  89. community.docker.docker_image_build:
  90. name: "{{ matrix_bridge_beeper_linkedin_container_image }}"
  91. dockerfile: Dockerfile
  92. path: "{{ matrix_bridge_beeper_linkedin_container_src_files_path }}"
  93. pull: true
  94. rebuild: "{{ 'always' if matrix_bridge_beeper_linkedin_git_pull_results.changed | bool else 'never' }}"
  95. args:
  96. TARGETARCH: "{{ matrix_architecture }}"
  97. register: matrix_bridge_beeper_linkedin_container_image_build_result
  98. - name: Ensure beeper-linkedin container network is created
  99. when: matrix_bridge_beeper_linkedin_container_network != 'host'
  100. community.general.docker_network:
  101. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  102. name: "{{ matrix_bridge_beeper_linkedin_container_network }}"
  103. driver: bridge
  104. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  105. - name: Ensure matrix-beeper-linkedin.service installed
  106. ansible.builtin.template:
  107. src: "{{ role_path }}/templates/systemd/matrix-beeper-linkedin.service.j2"
  108. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-beeper-linkedin.service"
  109. mode: '0644'
  110. register: matrix_bridge_beeper_linkedin_systemd_service_result
  111. - name: Determine whether matrix-beeper-linkedin needs a restart
  112. ansible.builtin.set_fact:
  113. matrix_bridge_beeper_linkedin_restart_necessary: >-
  114. {{
  115. matrix_bridge_beeper_linkedin_config_result.changed | default(false)
  116. or matrix_bridge_beeper_linkedin_registration_result.changed | default(false)
  117. or matrix_bridge_beeper_linkedin_systemd_service_result.changed | default(false)
  118. or matrix_bridge_beeper_linkedin_container_image_pull_result.changed | default(false)
  119. or matrix_bridge_beeper_linkedin_container_image_build_result.changed | default(false)
  120. }}