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

102 строки
4.2 KiB

  1. ---
  2. - ansible.builtin.set_fact:
  3. matrix_bot_honoroit_requires_restart: false
  4. - when: "matrix_bot_honoroit_database_engine == 'postgres'"
  5. block:
  6. - name: Check if an SQLite database already exists
  7. ansible.builtin.stat:
  8. path: "{{ matrix_bot_honoroit_sqlite_database_path_local }}"
  9. register: matrix_bot_honoroit_sqlite_database_path_local_stat_result
  10. - when: "matrix_bot_honoroit_sqlite_database_path_local_stat_result.stat.exists | bool"
  11. block:
  12. - ansible.builtin.include_role:
  13. name: galaxy/com.devture.ansible.role.postgres
  14. tasks_from: migrate_db_to_postgres
  15. vars:
  16. devture_postgres_db_migration_request:
  17. src: "{{ matrix_bot_honoroit_sqlite_database_path_local }}"
  18. dst: "{{ matrix_bot_honoroit_database_connection_string }}"
  19. caller: "{{ role_path | basename }}"
  20. engine_variable_name: 'matrix_bot_honoroit_database_engine'
  21. engine_old: 'sqlite'
  22. systemd_services_to_stop: ['matrix-bot-honoroit.service']
  23. - ansible.builtin.set_fact:
  24. matrix_bot_honoroit_requires_restart: true
  25. - name: Ensure honoroit paths exist
  26. ansible.builtin.file:
  27. path: "{{ item.path }}"
  28. state: directory
  29. mode: 0750
  30. owner: "{{ matrix_user_username }}"
  31. group: "{{ matrix_user_groupname }}"
  32. with_items:
  33. - {path: "{{ matrix_bot_honoroit_config_path }}", when: true}
  34. - {path: "{{ matrix_bot_honoroit_data_path }}", when: true}
  35. - {path: "{{ matrix_bot_honoroit_data_store_path }}", when: true}
  36. - {path: "{{ matrix_bot_honoroit_docker_src_files_path }}", when: true}
  37. when: "item.when | bool"
  38. - name: Ensure honoroit support files installed
  39. ansible.builtin.template:
  40. src: "{{ role_path }}/templates/{{ item }}.j2"
  41. dest: "{{ matrix_bot_honoroit_config_path }}/{{ item }}"
  42. owner: "{{ matrix_user_username }}"
  43. group: "{{ matrix_user_groupname }}"
  44. mode: 0640
  45. with_items:
  46. - env
  47. - labels
  48. - name: Ensure honoroit image is pulled
  49. community.docker.docker_image:
  50. name: "{{ matrix_bot_honoroit_docker_image }}"
  51. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  52. force_source: "{{ matrix_bot_honoroit_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  53. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_honoroit_docker_image_force_pull }}"
  54. when: "not matrix_bot_honoroit_container_image_self_build | bool"
  55. register: result
  56. retries: "{{ devture_playbook_help_container_retries_count }}"
  57. delay: "{{ devture_playbook_help_container_retries_delay }}"
  58. until: result is not failed
  59. - name: Ensure honoroit repository is present on self-build
  60. ansible.builtin.git:
  61. repo: "{{ matrix_bot_honoroit_docker_repo }}"
  62. version: "{{ matrix_bot_honoroit_docker_repo_version }}"
  63. dest: "{{ matrix_bot_honoroit_docker_src_files_path }}"
  64. force: "yes"
  65. become: true
  66. become_user: "{{ matrix_user_username }}"
  67. register: matrix_bot_honoroit_git_pull_results
  68. when: "matrix_bot_honoroit_container_image_self_build | bool"
  69. - name: Ensure honoroit image is built
  70. community.docker.docker_image:
  71. name: "{{ matrix_bot_honoroit_docker_image }}"
  72. source: build
  73. force_source: "{{ matrix_bot_honoroit_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  74. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_git_pull_results.changed }}"
  75. build:
  76. dockerfile: Dockerfile
  77. path: "{{ matrix_bot_honoroit_docker_src_files_path }}"
  78. pull: true
  79. when: "matrix_bot_honoroit_container_image_self_build | bool"
  80. - name: Ensure matrix-bot-honoroit.service installed
  81. ansible.builtin.template:
  82. src: "{{ role_path }}/templates/systemd/matrix-bot-honoroit.service.j2"
  83. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-honoroit.service"
  84. mode: 0644
  85. register: matrix_bot_honoroit_systemd_service_result
  86. - name: Ensure matrix-bot-honoroit.service restarted, if necessary
  87. ansible.builtin.service:
  88. name: "matrix-bot-honoroit.service"
  89. state: restarted
  90. daemon_reload: true
  91. when: "matrix_bot_honoroit_requires_restart | bool"