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

104 строки
4.7 KiB

  1. ---
  2. - name: Ensure Matrix Authentication Service paths exist
  3. ansible.builtin.file:
  4. path: "{{ item.path }}"
  5. state: directory
  6. mode: 0750
  7. owner: "{{ matrix_user_username }}"
  8. group: "{{ matrix_user_groupname }}"
  9. with_items:
  10. - {path: "{{ matrix_authentication_service_base_path }}", when: true}
  11. - {path: "{{ matrix_authentication_service_bin_path }}", when: true}
  12. - {path: "{{ matrix_authentication_service_config_path }}", when: true}
  13. - {path: "{{ matrix_authentication_service_data_path }}", when: true}
  14. - {path: "{{ matrix_authentication_service_data_keys_path }}", when: true}
  15. - {path: "{{ matrix_authentication_service_container_src_files_path }}", when: "{{ matrix_authentication_service_container_image_self_build }}"}
  16. when: "item.when | bool"
  17. - when: matrix_authentication_service_key_management_enabled | bool
  18. block:
  19. - name: Ensure openssl installed
  20. ansible.builtin.package:
  21. name: openssl
  22. state: present
  23. - name: Prepare private key
  24. ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/prepare_key.yml"
  25. with_items: "{{ matrix_authentication_service_key_management_list }}"
  26. loop_control:
  27. loop_var: private_key_definition
  28. - name: Ensure Matrix Authentication Service configuration installed
  29. ansible.builtin.copy:
  30. content: "{{ matrix_authentication_service_configuration | to_nice_yaml(indent=2, width=999999) }}"
  31. dest: "{{ matrix_authentication_service_config_path }}/config.yaml"
  32. mode: 0644
  33. owner: "{{ matrix_user_username }}"
  34. group: "{{ matrix_user_groupname }}"
  35. - name: Ensure Matrix Authentication Service support files created
  36. ansible.builtin.template:
  37. src: "{{ item.src }}"
  38. dest: "{{ item.dest }}"
  39. mode: "{{ item.mode }}"
  40. owner: "{{ matrix_user_username }}"
  41. group: "{{ matrix_user_groupname }}"
  42. with_items:
  43. - src: "{{ role_path }}/templates/env.j2"
  44. dest: "{{ matrix_authentication_service_config_path }}/env"
  45. mode: '0644'
  46. - src: "{{ role_path }}/templates/labels.j2"
  47. dest: "{{ matrix_authentication_service_config_path }}/labels"
  48. mode: '0644'
  49. - src: "{{ role_path }}/templates/bin/register-user.j2"
  50. dest: "{{ matrix_authentication_service_bin_path }}/register-user"
  51. mode: '0755'
  52. - src: "{{ role_path }}/templates/bin/mas-cli.j2"
  53. dest: "{{ matrix_authentication_service_bin_path }}/mas-cli"
  54. mode: '0755'
  55. - name: Ensure Matrix Authentication Service container image is pulled
  56. community.docker.docker_image:
  57. name: "{{ matrix_authentication_service_container_image }}"
  58. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  59. force_source: "{{ matrix_authentication_service_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  60. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_authentication_service_container_image_force_pull }}"
  61. when: "not matrix_authentication_service_container_image_self_build | bool"
  62. register: result
  63. retries: "{{ devture_playbook_help_container_retries_count }}"
  64. delay: "{{ devture_playbook_help_container_retries_delay }}"
  65. until: result is not failed
  66. - when: "matrix_authentication_service_container_image_self_build | bool"
  67. block:
  68. - name: Ensure Matrix Authentication Service repository is present on self-build
  69. ansible.builtin.git:
  70. repo: "{{ matrix_authentication_service_container_repo }}"
  71. version: "{{ matrix_authentication_service_container_repo_version }}"
  72. dest: "{{ matrix_authentication_service_container_src_files_path }}"
  73. force: "yes"
  74. become: true
  75. become_user: "{{ matrix_user_username }}"
  76. - name: Ensure Matrix Authentication Service container image is built
  77. ansible.builtin.command:
  78. cmd: |-
  79. {{ devture_systemd_docker_base_host_command_docker }} buildx build
  80. --tag={{ matrix_authentication_service_container_image }}
  81. --file={{ matrix_authentication_service_container_src_files_path }}/Dockerfile
  82. {{ matrix_authentication_service_container_src_files_path }}
  83. changed_when: true
  84. - name: Ensure Matrix Authentication Service container network is created
  85. community.general.docker_network:
  86. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  87. name: "{{ matrix_authentication_service_container_network }}"
  88. driver: bridge
  89. - name: Ensure matrix-authentication-service.service installed
  90. ansible.builtin.template:
  91. src: "{{ role_path }}/templates/systemd/matrix-authentication-service.service.j2"
  92. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-authentication-service.service"
  93. mode: 0644