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.
 
 

104 satır
4.0 KiB

  1. ---
  2. #
  3. # Tasks related to setting up matrix-registration
  4. #
  5. - name: Ensure matrix-registration paths exist
  6. file:
  7. path: "{{ item.path }}"
  8. state: directory
  9. mode: 0750
  10. owner: "{{ matrix_user_username }}"
  11. group: "{{ matrix_user_groupname }}"
  12. with_items:
  13. - { path: "{{ matrix_registration_base_path }}", when: true }
  14. - { path: "{{ matrix_registration_config_path }}", when: true }
  15. - { path: "{{ matrix_registration_data_path }}", when: true }
  16. - { path: "{{ matrix_registration_docker_src_files_path }}", when: "{{ matrix_registration_container_image_self_build }}"}
  17. when: matrix_registration_enabled|bool and item.when
  18. - name: Ensure matrix-registration image is pulled
  19. docker_image:
  20. name: "{{ matrix_registration_docker_image }}"
  21. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  22. force_source: "{{ matrix_registration_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  23. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_registration_docker_image_force_pull }}"
  24. when: "matrix_registration_enabled|bool and not matrix_registration_container_image_self_build|bool"
  25. - name: Ensure matrix-registration repository is present when self-building
  26. git:
  27. repo: "{{ matrix_registration_container_image_self_build_repo }}"
  28. dest: "{{ matrix_registration_docker_src_files_path }}"
  29. version: "{{ matrix_registration_version }}"
  30. force: "yes"
  31. register: matrix_registration_git_pull_results
  32. when: "matrix_registration_enabled|bool and matrix_registration_container_image_self_build|bool"
  33. - name: Ensure matrix-registration Docker image is built
  34. docker_image:
  35. name: "{{ matrix_registration_docker_image }}"
  36. source: build
  37. force_source: "{{ matrix_registration_git_pull_results.changed }}"
  38. build:
  39. dockerfile: Dockerfile
  40. path: "{{ matrix_registration_docker_src_files_path }}"
  41. pull: yes
  42. when: "matrix_registration_enabled|bool and matrix_registration_container_image_self_build|bool"
  43. - name: Ensure matrix-registration config installed
  44. copy:
  45. content: "{{ matrix_registration_configuration|to_nice_yaml }}"
  46. dest: "{{ matrix_registration_config_path }}/config.yaml"
  47. mode: 0644
  48. owner: "{{ matrix_user_username }}"
  49. group: "{{ matrix_user_groupname }}"
  50. when: matrix_registration_enabled|bool
  51. - name: Ensure matrix-registration.service installed
  52. template:
  53. src: "{{ role_path }}/templates/systemd/matrix-registration.service.j2"
  54. dest: "{{ matrix_systemd_path }}/matrix-registration.service"
  55. mode: 0644
  56. register: matrix_registration_systemd_service_result
  57. when: matrix_registration_enabled|bool
  58. - name: Ensure systemd reloaded after matrix-registration.service installation
  59. service:
  60. daemon_reload: yes
  61. when: "matrix_registration_enabled|bool and matrix_registration_systemd_service_result.changed"
  62. #
  63. # Tasks related to getting rid of matrix-registration (if it was previously enabled)
  64. #
  65. - name: Check existence of matrix-registration service
  66. stat:
  67. path: "{{ matrix_systemd_path }}/matrix-registration.service"
  68. register: matrix_registration_service_stat
  69. - name: Ensure matrix-registration is stopped
  70. service:
  71. name: matrix-registration
  72. state: stopped
  73. daemon_reload: yes
  74. register: stopping_result
  75. when: "not matrix_registration_enabled|bool and matrix_registration_service_stat.stat.exists"
  76. - name: Ensure matrix-registration.service doesn't exist
  77. file:
  78. path: "{{ matrix_systemd_path }}/matrix-registration.service"
  79. state: absent
  80. when: "not matrix_registration_enabled|bool and matrix_registration_service_stat.stat.exists"
  81. - name: Ensure systemd reloaded after matrix-registration.service removal
  82. service:
  83. daemon_reload: yes
  84. when: "not matrix_registration_enabled|bool and matrix_registration_service_stat.stat.exists"
  85. - name: Ensure matrix-registration Docker image doesn't exist
  86. docker_image:
  87. name: "{{ matrix_registration_docker_image }}"
  88. state: absent
  89. when: "not matrix_registration_enabled|bool"