Matrix Docker Ansible eploy
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

93 linhas
3.7 KiB

  1. ---
  2. - set_fact:
  3. matrix_bot_honoroit_requires_restart: false
  4. - block:
  5. - name: Check if an SQLite database already exists
  6. stat:
  7. path: "{{ matrix_bot_honoroit_sqlite_database_path_local }}"
  8. register: matrix_bot_honoroit_sqlite_database_path_local_stat_result
  9. - block:
  10. - set_fact:
  11. matrix_postgres_db_migration_request:
  12. src: "{{ matrix_bot_honoroit_sqlite_database_path_local }}"
  13. dst: "{{ matrix_bot_honoroit_database_connection_string }}"
  14. caller: "{{ role_path|basename }}"
  15. engine_variable_name: 'matrix_bot_honoroit_database_engine'
  16. engine_old: 'sqlite'
  17. systemd_services_to_stop: ['matrix-bot-honoroit.service']
  18. - import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/migrate_db_to_postgres.yml"
  19. - set_fact:
  20. matrix_bot_honoroit_requires_restart: true
  21. when: "matrix_bot_honoroit_sqlite_database_path_local_stat_result.stat.exists|bool"
  22. when: "matrix_bot_honoroit_database_engine == 'postgres'"
  23. - name: Ensure honoroit paths exist
  24. file:
  25. path: "{{ item.path }}"
  26. state: directory
  27. mode: 0750
  28. owner: "{{ matrix_user_username }}"
  29. group: "{{ matrix_user_groupname }}"
  30. with_items:
  31. - {path: "{{ matrix_bot_honoroit_config_path }}", when: true}
  32. - {path: "{{ matrix_bot_honoroit_data_path }}", when: true}
  33. - {path: "{{ matrix_bot_honoroit_data_store_path }}", when: true}
  34. - {path: "{{ matrix_bot_honoroit_docker_src_files_path }}", when: true}
  35. when: "item.when|bool"
  36. - name: Ensure honoroit environment variables file created
  37. template:
  38. src: "{{ role_path }}/templates/env.j2"
  39. dest: "{{ matrix_bot_honoroit_config_path }}/env"
  40. mode: 0640
  41. - name: Ensure honoroit image is pulled
  42. docker_image:
  43. name: "{{ matrix_bot_honoroit_docker_image }}"
  44. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  45. force_source: "{{ matrix_bot_honoroit_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  46. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_honoroit_docker_image_force_pull }}"
  47. when: "not matrix_bot_honoroit_container_image_self_build|bool"
  48. - name: Ensure honoroit repository is present on self-build
  49. git:
  50. repo: "{{ matrix_bot_honoroit_docker_repo }}"
  51. dest: "{{ matrix_bot_honoroit_docker_src_files_path }}"
  52. force: "yes"
  53. register: matrix_bot_honoroit_git_pull_results
  54. when: "matrix_bot_honoroit_container_image_self_build|bool"
  55. - name: Ensure honoroit image is built
  56. docker_image:
  57. name: "{{ matrix_bot_honoroit_docker_image }}"
  58. source: build
  59. force_source: "{{ matrix_bot_honoroit_git_pull_results.changed 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_mailer_git_pull_results.changed }}"
  61. build:
  62. dockerfile: Dockerfile
  63. path: "{{ matrix_bot_honoroit_docker_src_files_path }}"
  64. pull: true
  65. when: "matrix_bot_honoroit_container_image_self_build|bool"
  66. - name: Ensure matrix-bot-honoroit.service installed
  67. template:
  68. src: "{{ role_path }}/templates/systemd/matrix-bot-honoroit.service.j2"
  69. dest: "{{ matrix_systemd_path }}/matrix-bot-honoroit.service"
  70. mode: 0644
  71. register: matrix_bot_honoroit_systemd_service_result
  72. - name: Ensure systemd reloaded after matrix-bot-honoroit.service installation
  73. service:
  74. daemon_reload: true
  75. when: "matrix_bot_honoroit_systemd_service_result.changed|bool"
  76. - name: Ensure matrix-bot-honoroit.service restarted, if necessary
  77. service:
  78. name: "matrix-bot-honoroit.service"
  79. state: restarted
  80. when: "matrix_bot_honoroit_requires_restart|bool"