Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

119 lines
5.1 KiB

  1. # SPDX-FileCopyrightText: 2025 MDAD project contributors
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - ansible.builtin.set_fact:
  6. matrix_steam_bridge_migration_requires_restart: false
  7. - name: Ensure Steam bridge image is pulled
  8. community.docker.docker_image:
  9. name: "{{ matrix_steam_bridge_docker_image }}"
  10. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  11. force_source: "{{ matrix_steam_bridge_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  12. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_steam_bridge_docker_image_force_pull }}"
  13. when: matrix_steam_bridge_enabled | bool and not matrix_steam_bridge_container_image_self_build
  14. register: matrix_steam_bridge_container_image_pull_result
  15. retries: "{{ devture_playbook_help_container_retries_count }}"
  16. delay: "{{ devture_playbook_help_container_retries_delay }}"
  17. until: matrix_steam_bridge_container_image_pull_result is not failed
  18. - name: Ensure Steam bridge paths exist
  19. ansible.builtin.file:
  20. path: "{{ item.path }}"
  21. state: directory
  22. mode: '0750'
  23. owner: "{{ matrix_user_name }}"
  24. group: "{{ matrix_group_name }}"
  25. with_items:
  26. - {path: "{{ matrix_steam_bridge_base_path }}", when: true}
  27. - {path: "{{ matrix_steam_bridge_config_path }}", when: true}
  28. - {path: "{{ matrix_steam_bridge_data_path }}", when: true}
  29. - {path: "{{ matrix_steam_bridge_docker_src_files_path }}", when: "{{ matrix_steam_bridge_container_image_self_build }}"}
  30. when: item.when | bool
  31. - name: Ensure Steam bridge repository is present on self-build
  32. ansible.builtin.git:
  33. repo: "{{ matrix_steam_bridge_container_image_self_build_repo }}"
  34. version: "{{ matrix_steam_bridge_container_image_self_build_repo_version }}"
  35. dest: "{{ matrix_steam_bridge_docker_src_files_path }}"
  36. force: "yes"
  37. become: true
  38. become_user: "{{ matrix_user_name }}"
  39. register: matrix_steam_bridge_git_pull_results
  40. when: "matrix_steam_bridge_enabled | bool and matrix_steam_bridge_container_image_self_build"
  41. - name: Ensure Steam bridge Docker image is built
  42. community.docker.docker_image:
  43. name: "{{ matrix_steam_bridge_docker_image }}"
  44. source: build
  45. force_source: "{{ matrix_steam_bridge_git_pull_results.changed }}"
  46. build:
  47. dockerfile: Dockerfile
  48. path: "{{ matrix_steam_bridge_docker_src_files_path }}"
  49. pull: true
  50. when: "matrix_steam_bridge_enabled | bool and matrix_steam_bridge_container_image_self_build | bool"
  51. - name: Ensure matrix-steam-bridge config.yaml installed
  52. ansible.builtin.copy:
  53. content: "{{ matrix_steam_bridge_configuration | to_nice_yaml(indent=2, width=999999) }}"
  54. dest: "{{ matrix_steam_bridge_config_path }}/config.yaml"
  55. mode: '0644'
  56. owner: "{{ matrix_user_name }}"
  57. group: "{{ matrix_group_name }}"
  58. register: matrix_steam_bridge_config_result
  59. - name: Ensure matrix-steam-bridge registration.yaml installed
  60. ansible.builtin.copy:
  61. content: "{{ matrix_steam_bridge_registration | to_nice_yaml(indent=2, width=999999) }}"
  62. dest: "{{ matrix_steam_bridge_config_path }}/registration.yaml"
  63. mode: '0644'
  64. owner: "{{ matrix_user_name }}"
  65. group: "{{ matrix_group_name }}"
  66. register: matrix_steam_bridge_registration_result
  67. - name: Ensure matrix-steam-bridge support files installed
  68. ansible.builtin.template:
  69. src: "{{ role_path }}/templates/{{ item }}.j2"
  70. dest: "{{ matrix_steam_bridge_base_path }}/{{ item }}"
  71. mode: '0640'
  72. owner: "{{ matrix_user_name }}"
  73. group: "{{ matrix_group_name }}"
  74. with_items:
  75. - labels
  76. register: matrix_steam_bridge_support_files_result
  77. - name: Ensure matrix-steam-bridge container network is created
  78. community.general.docker_network:
  79. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  80. name: "{{ matrix_steam_bridge_container_network }}"
  81. driver: bridge
  82. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  83. - name: Ensure matrix-steam-bridge.service installed
  84. ansible.builtin.template:
  85. src: "{{ role_path }}/templates/systemd/matrix-steam-bridge.service.j2"
  86. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-steam-bridge.service"
  87. mode: '0644'
  88. register: matrix_steam_bridge_systemd_service_result
  89. - name: Determine whether matrix-steam-bridge needs a restart
  90. ansible.builtin.set_fact:
  91. matrix_steam_bridge_restart_necessary: >-
  92. {{
  93. matrix_steam_bridge_migration_requires_restart | default(false)
  94. or matrix_steam_bridge_config_result.changed | default(false)
  95. or matrix_steam_bridge_registration_result.changed | default(false)
  96. or matrix_steam_bridge_support_files_result.changed | default(false)
  97. or matrix_steam_bridge_systemd_service_result.changed | default(false)
  98. or matrix_steam_bridge_container_image_pull_result.changed | default(false)
  99. }}
  100. - name: Ensure matrix-steam-bridge.service restarted, if necessary
  101. ansible.builtin.service:
  102. name: "matrix-steam-bridge.service"
  103. state: restarted
  104. daemon_reload: true
  105. when: "matrix_steam_bridge_migration_requires_restart | bool"