Matrix Docker Ansible eploy
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

99 řádky
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 environment variables file created
  39. ansible.builtin.template:
  40. src: "{{ role_path }}/templates/env.j2"
  41. dest: "{{ matrix_bot_honoroit_config_path }}/env"
  42. owner: "{{ matrix_user_username }}"
  43. group: "{{ matrix_user_groupname }}"
  44. mode: 0640
  45. - name: Ensure honoroit image is pulled
  46. community.docker.docker_image:
  47. name: "{{ matrix_bot_honoroit_docker_image }}"
  48. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  49. force_source: "{{ matrix_bot_honoroit_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  50. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_honoroit_docker_image_force_pull }}"
  51. when: "not matrix_bot_honoroit_container_image_self_build | bool"
  52. register: result
  53. retries: "{{ devture_playbook_help_container_retries_count }}"
  54. delay: "{{ devture_playbook_help_container_retries_delay }}"
  55. until: result is not failed
  56. - name: Ensure honoroit repository is present on self-build
  57. ansible.builtin.git:
  58. repo: "{{ matrix_bot_honoroit_docker_repo }}"
  59. version: "{{ matrix_bot_honoroit_docker_repo_version }}"
  60. dest: "{{ matrix_bot_honoroit_docker_src_files_path }}"
  61. force: "yes"
  62. become: true
  63. become_user: "{{ matrix_user_username }}"
  64. register: matrix_bot_honoroit_git_pull_results
  65. when: "matrix_bot_honoroit_container_image_self_build | bool"
  66. - name: Ensure honoroit image is built
  67. community.docker.docker_image:
  68. name: "{{ matrix_bot_honoroit_docker_image }}"
  69. source: build
  70. force_source: "{{ matrix_bot_honoroit_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  71. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_git_pull_results.changed }}"
  72. build:
  73. dockerfile: Dockerfile
  74. path: "{{ matrix_bot_honoroit_docker_src_files_path }}"
  75. pull: true
  76. when: "matrix_bot_honoroit_container_image_self_build | bool"
  77. - name: Ensure matrix-bot-honoroit.service installed
  78. ansible.builtin.template:
  79. src: "{{ role_path }}/templates/systemd/matrix-bot-honoroit.service.j2"
  80. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-honoroit.service"
  81. mode: 0644
  82. register: matrix_bot_honoroit_systemd_service_result
  83. - name: Ensure matrix-bot-honoroit.service restarted, if necessary
  84. ansible.builtin.service:
  85. name: "matrix-bot-honoroit.service"
  86. state: restarted
  87. daemon_reload: true
  88. when: "matrix_bot_honoroit_requires_restart | bool"