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

73 строки
3.2 KiB

  1. ---
  2. - name: Ensure matrix-registration-bot paths exist
  3. 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_bot_matrix_registration_bot_config_path }}", when: true}
  11. - {path: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}", when: true}
  12. when: "item.when|bool"
  13. - name: Ensure matrix-registration-bot environment variables file created
  14. template:
  15. src: "{{ role_path }}/templates/env.j2"
  16. dest: "{{ matrix_bot_matrix_registration_bot_config_path }}/env"
  17. owner: "{{ matrix_user_username }}"
  18. group: "{{ matrix_user_groupname }}"
  19. mode: 0640
  20. - name: Ensure matrix-registration-bot image is pulled
  21. docker_image:
  22. name: "{{ matrix_bot_matrix_registration_bot_docker_image }}"
  23. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  24. force_source: "{{ matrix_bot_matrix_registration_bot_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  25. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_matrix_registration_bot_docker_image_force_pull }}"
  26. when: "not matrix_bot_matrix_registration_bot_container_image_self_build|bool"
  27. register: result
  28. retries: "{{ matrix_container_retries_count }}"
  29. delay: "{{ matrix_container_retries_delay }}"
  30. until: result is not failed
  31. - name: Ensure matrix-registration-bot repository is present on self-build
  32. git:
  33. repo: "{{ matrix_bot_matrix_registration_bot_docker_repo }}"
  34. dest: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}"
  35. force: "yes"
  36. become: true
  37. become_user: "{{ matrix_user_username }}"
  38. register: matrix_bot_matrix_registration_bot_git_pull_results
  39. when: "matrix_bot_matrix_registration_bot_container_image_self_build|bool"
  40. - name: Ensure matrix-registration-bot image is built
  41. docker_image:
  42. name: "{{ matrix_bot_matrix_registration_bot_docker_image }}"
  43. source: build
  44. force_source: "{{ matrix_bot_matrix_registration_bot_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  45. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_git_pull_results.changed }}"
  46. build:
  47. dockerfile: Dockerfile
  48. path: "{{ matrix_bot_matrix_registration_bot_docker_src_files_path }}"
  49. pull: true
  50. when: "matrix_bot_matrix_registration_bot_container_image_self_build|bool"
  51. - name: Ensure matrix-bot-matrix-registration-bot.service installed
  52. template:
  53. src: "{{ role_path }}/templates/systemd/matrix-bot-matrix-registration-bot.service.j2"
  54. dest: "{{ matrix_systemd_path }}/matrix-bot-matrix-registration-bot.service"
  55. mode: 0644
  56. register: matrix_bot_matrix_registration_bot_systemd_service_result
  57. - name: Ensure systemd reloaded after matrix-bot-matrix-registration-bot.service installation
  58. service:
  59. daemon_reload: true
  60. when: "matrix_bot_matrix_registration_bot_systemd_service_result.changed|bool"
  61. - name: Ensure matrix-bot-matrix-registration-bot.service restarted, if necessary
  62. service:
  63. name: "matrix-bot-matrix-registration-bot.service"
  64. state: restarted