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

136 строки
6.1 KiB

  1. ---
  2. - ansible.builtin.set_fact:
  3. matrix_go_skype_bridge_requires_restart: false
  4. - when: "matrix_go_skype_bridge_database_engine == 'postgres'"
  5. block:
  6. - name: Check if an SQLite database already exists
  7. ansible.builtin.stat:
  8. path: "{{ matrix_go_skype_bridge_sqlite_database_path_local }}"
  9. register: matrix_go_skype_bridge_sqlite_database_path_local_stat_result
  10. - when: "matrix_go_skype_bridge_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_go_skype_bridge_sqlite_database_path_local }}"
  18. dst: "{{ matrix_go_skype_bridge_database_connection_string }}"
  19. caller: "{{ role_path | basename }}"
  20. engine_variable_name: 'matrix_go_skype_bridge_database_engine'
  21. engine_old: 'sqlite'
  22. systemd_services_to_stop: ['matrix-go-skype-bridge.service']
  23. pgloader_options: ['--with "quote identifiers"']
  24. - ansible.builtin.set_fact:
  25. matrix_go_skype_bridge_requires_restart: true
  26. - name: Ensure Go Skype Bridge paths exists
  27. ansible.builtin.file:
  28. path: "{{ item.path }}"
  29. state: directory
  30. mode: 0750
  31. owner: "{{ matrix_user_username }}"
  32. group: "{{ matrix_user_groupname }}"
  33. with_items:
  34. - {path: "{{ matrix_go_skype_bridge_base_path }}", when: true}
  35. - {path: "{{ matrix_go_skype_bridge_config_path }}", when: true}
  36. - {path: "{{ matrix_go_skype_bridge_data_path }}", when: true}
  37. - {path: "{{ matrix_go_skype_bridge_docker_src_files_path }}", when: "{{ matrix_go_skype_bridge_container_image_self_build }}"}
  38. when: item.when | bool
  39. - name: Ensure Go Skype Bridge image is pulled
  40. community.docker.docker_image:
  41. name: "{{ matrix_go_skype_bridge_docker_image }}"
  42. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  43. force_source: "{{ matrix_go_skype_bridge_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  44. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_go_skype_bridge_docker_image_force_pull }}"
  45. when: not matrix_go_skype_bridge_container_image_self_build
  46. register: result
  47. retries: "{{ devture_playbook_help_container_retries_count }}"
  48. delay: "{{ devture_playbook_help_container_retries_delay }}"
  49. until: result is not failed
  50. - name: Ensure Go Skype Bridge repository is present on self-build
  51. ansible.builtin.git:
  52. repo: "{{ matrix_go_skype_bridge_container_image_self_build_repo }}"
  53. dest: "{{ matrix_go_skype_bridge_docker_src_files_path }}"
  54. version: "{{ matrix_go_skype_bridge_container_image_self_build_branch }}"
  55. force: "yes"
  56. become: true
  57. become_user: "{{ matrix_user_username }}"
  58. register: matrix_go_skype_bridge_git_pull_results
  59. when: "matrix_go_skype_bridge_container_image_self_build | bool"
  60. - name: Ensure Go Skype Bridge Docker image is built
  61. community.docker.docker_image:
  62. name: "{{ matrix_go_skype_bridge_docker_image }}"
  63. source: build
  64. force_source: "{{ matrix_go_skype_bridge_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  65. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_go_skype_bridge_git_pull_results.changed }}"
  66. build:
  67. dockerfile: Dockerfile
  68. path: "{{ matrix_go_skype_bridge_docker_src_files_path }}"
  69. pull: true
  70. when: "matrix_go_skype_bridge_container_image_self_build | bool"
  71. - name: Check if an old database file exists
  72. ansible.builtin.stat:
  73. path: "{{ matrix_go_skype_bridge_base_path }}/go-skype-bridge.db"
  74. register: matrix_go_skype_bridge_stat_database
  75. - name: Check if an old matrix state file exists
  76. ansible.builtin.stat:
  77. path: "{{ matrix_go_skype_bridge_base_path }}/mx-state.json"
  78. register: matrix_go_skype_bridge_stat_mx_state
  79. - name: (Data relocation) Ensure matrix-go-skype-bridge.service is stopped
  80. ansible.builtin.service:
  81. name: matrix-go-skype-bridge
  82. state: stopped
  83. enabled: false
  84. daemon_reload: true
  85. failed_when: false
  86. when: "matrix_go_skype_bridge_stat_database.stat.exists"
  87. - name: (Data relocation) Move go-skype-bridge database file to ./data directory
  88. ansible.builtin.command: "mv {{ matrix_go_skype_bridge_base_path }}/go-skype-bridge.db {{ matrix_go_skype_bridge_data_path }}/go-skype-bridge.db"
  89. when: "matrix_go_skype_bridge_stat_database.stat.exists"
  90. - name: (Data relocation) Move go-skype-bridge mx-state file to ./data directory
  91. ansible.builtin.command: "mv {{ matrix_go_skype_bridge_base_path }}/mx-state.json {{ matrix_go_skype_bridge_data_path }}/mx-state.json"
  92. when: "matrix_go_skype_bridge_stat_mx_state.stat.exists"
  93. - name: Ensure go-skype-bridge config.yaml installed
  94. ansible.builtin.copy:
  95. content: "{{ matrix_go_skype_bridge_configuration | to_nice_yaml(indent=2, width=999999) }}"
  96. dest: "{{ matrix_go_skype_bridge_config_path }}/config.yaml"
  97. mode: 0644
  98. owner: "{{ matrix_user_username }}"
  99. group: "{{ matrix_user_groupname }}"
  100. - name: Ensure go-skype-bridge registration.yaml installed
  101. ansible.builtin.copy:
  102. content: "{{ matrix_go_skype_bridge_registration | to_nice_yaml(indent=2, width=999999) }}"
  103. dest: "{{ matrix_go_skype_bridge_config_path }}/registration.yaml"
  104. mode: 0644
  105. owner: "{{ matrix_user_username }}"
  106. group: "{{ matrix_user_groupname }}"
  107. - name: Ensure matrix-go-skype-bridge.service installed
  108. ansible.builtin.template:
  109. src: "{{ role_path }}/templates/systemd/matrix-go-skype-bridge.service.j2"
  110. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-go-skype-bridge.service"
  111. mode: 0644
  112. register: matrix_go_skype_bridge_systemd_service_result
  113. - name: Ensure matrix-go-skype-bridge.service restarted, if necessary
  114. ansible.builtin.service:
  115. name: "matrix-go-skype-bridge.service"
  116. state: restarted
  117. daemon_reload: true
  118. when: "matrix_go_skype_bridge_requires_restart | bool"