Matrix Docker Ansible eploy
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

104 líneas
4.3 KiB

  1. ---
  2. - ansible.builtin.set_fact:
  3. matrix_bot_buscarron_requires_restart: false
  4. - block:
  5. - name: Check if an SQLite database already exists
  6. ansible.builtin.stat:
  7. path: "{{ matrix_bot_buscarron_sqlite_database_path_local }}"
  8. register: matrix_bot_buscarron_sqlite_database_path_local_stat_result
  9. - block:
  10. - ansible.builtin.set_fact:
  11. matrix_postgres_db_migration_request:
  12. src: "{{ matrix_bot_buscarron_sqlite_database_path_local }}"
  13. dst: "{{ matrix_bot_buscarron_database_connection_string }}"
  14. caller: "{{ role_path | basename }}"
  15. engine_variable_name: 'matrix_bot_buscarron_database_engine'
  16. engine_old: 'sqlite'
  17. systemd_services_to_stop: ['matrix-bot-buscarron.service']
  18. - ansible.builtin.import_role:
  19. name: matrix-postgres
  20. tasks_from: migrate_db_to_postgres
  21. - ansible.builtin.set_fact:
  22. matrix_bot_buscarron_requires_restart: true
  23. when: "matrix_bot_buscarron_sqlite_database_path_local_stat_result.stat.exists | bool"
  24. when: "matrix_bot_buscarron_database_engine == 'postgres'"
  25. - name: Ensure buscarron 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_buscarron_config_path }}", when: true}
  34. - {path: "{{ matrix_bot_buscarron_data_path }}", when: true}
  35. - {path: "{{ matrix_bot_buscarron_data_store_path }}", when: true}
  36. - {path: "{{ matrix_bot_buscarron_docker_src_files_path }}", when: true}
  37. when: "item.when | bool"
  38. - name: Ensure buscarron environment variables file created
  39. ansible.builtin.template:
  40. src: "{{ role_path }}/templates/env.j2"
  41. dest: "{{ matrix_bot_buscarron_config_path }}/env"
  42. owner: "{{ matrix_user_username }}"
  43. group: "{{ matrix_user_groupname }}"
  44. mode: 0640
  45. - name: Ensure buscarron image is pulled
  46. docker_image:
  47. name: "{{ matrix_bot_buscarron_docker_image }}"
  48. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  49. force_source: "{{ matrix_bot_buscarron_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_buscarron_docker_image_force_pull }}"
  51. when: "not matrix_bot_buscarron_container_image_self_build | bool"
  52. register: result
  53. retries: "{{ matrix_container_retries_count }}"
  54. delay: "{{ matrix_container_retries_delay }}"
  55. until: result is not failed
  56. - name: Ensure buscarron repository is present on self-build
  57. ansible.builtin.git:
  58. repo: "{{ matrix_bot_buscarron_docker_repo }}"
  59. version: "{{ matrix_bot_buscarron_docker_repo_version }}"
  60. dest: "{{ matrix_bot_buscarron_docker_src_files_path }}"
  61. force: "yes"
  62. become: true
  63. become_user: "{{ matrix_user_username }}"
  64. register: matrix_bot_buscarron_git_pull_results
  65. when: "matrix_bot_buscarron_container_image_self_build | bool"
  66. - name: Ensure buscarron image is built
  67. docker_image:
  68. name: "{{ matrix_bot_buscarron_docker_image }}"
  69. source: build
  70. force_source: "{{ matrix_bot_buscarron_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_buscarron_docker_src_files_path }}"
  75. pull: true
  76. when: "matrix_bot_buscarron_container_image_self_build | bool"
  77. - name: Ensure matrix-bot-buscarron.service installed
  78. ansible.builtin.template:
  79. src: "{{ role_path }}/templates/systemd/matrix-bot-buscarron.service.j2"
  80. dest: "{{ matrix_systemd_path }}/matrix-bot-buscarron.service"
  81. mode: 0644
  82. register: matrix_bot_buscarron_systemd_service_result
  83. - name: Ensure systemd reloaded after matrix-bot-buscarron.service installation
  84. ansible.builtin.service:
  85. daemon_reload: true
  86. when: "matrix_bot_buscarron_systemd_service_result.changed | bool"
  87. - name: Ensure matrix-bot-buscarron.service restarted, if necessary
  88. ansible.builtin.service:
  89. name: "matrix-bot-buscarron.service"
  90. state: restarted
  91. when: "matrix_bot_buscarron_requires_restart | bool"