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.
 
 

106 líneas
4.4 KiB

  1. ---
  2. - ansible.builtin.set_fact:
  3. matrix_bot_buscarron_requires_restart: false
  4. - when: "matrix_bot_buscarron_database_engine == 'postgres'"
  5. block:
  6. - name: Check if an SQLite database already exists
  7. ansible.builtin.stat:
  8. path: "{{ matrix_bot_buscarron_sqlite_database_path_local }}"
  9. register: matrix_bot_buscarron_sqlite_database_path_local_stat_result
  10. - when: "matrix_bot_buscarron_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_buscarron_sqlite_database_path_local }}"
  18. dst: "{{ matrix_bot_buscarron_database_connection_string }}"
  19. caller: "{{ role_path | basename }}"
  20. engine_variable_name: 'matrix_bot_buscarron_database_engine'
  21. engine_old: 'sqlite'
  22. systemd_services_to_stop: ['matrix-bot-buscarron.service']
  23. - ansible.builtin.set_fact:
  24. matrix_bot_buscarron_requires_restart: true
  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 support files installed
  39. ansible.builtin.template:
  40. src: "{{ role_path }}/templates/{{ item }}.j2"
  41. dest: "{{ matrix_bot_buscarron_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 buscarron image is pulled
  49. community.docker.docker_image:
  50. name: "{{ matrix_bot_buscarron_docker_image }}"
  51. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  52. force_source: "{{ matrix_bot_buscarron_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_buscarron_docker_image_force_pull }}"
  54. when: "not matrix_bot_buscarron_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 buscarron repository is present on self-build
  60. ansible.builtin.git:
  61. repo: "{{ matrix_bot_buscarron_docker_repo }}"
  62. version: "{{ matrix_bot_buscarron_docker_repo_version }}"
  63. dest: "{{ matrix_bot_buscarron_docker_src_files_path }}"
  64. force: "yes"
  65. become: true
  66. become_user: "{{ matrix_user_username }}"
  67. register: matrix_bot_buscarron_git_pull_results
  68. when: "matrix_bot_buscarron_container_image_self_build | bool"
  69. - name: Ensure buscarron image is built
  70. community.docker.docker_image:
  71. name: "{{ matrix_bot_buscarron_docker_image }}"
  72. source: build
  73. force_source: "{{ matrix_bot_buscarron_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_buscarron_docker_src_files_path }}"
  78. pull: true
  79. when: "matrix_bot_buscarron_container_image_self_build | bool"
  80. - name: Ensure matrix-bot-buscarron.service installed
  81. ansible.builtin.template:
  82. src: "{{ role_path }}/templates/systemd/matrix-bot-buscarron.service.j2"
  83. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-buscarron.service"
  84. mode: 0644
  85. - name: Ensure buscarron container network is created
  86. community.general.docker_network:
  87. name: "{{ matrix_bot_buscarron_container_network }}"
  88. driver: bridge
  89. - name: Ensure matrix-bot-buscarron.service restarted, if necessary
  90. ansible.builtin.service:
  91. name: "matrix-bot-buscarron.service"
  92. state: restarted
  93. daemon_reload: true
  94. when: "matrix_bot_buscarron_requires_restart | bool"