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

142 строки
6.3 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:
  89. cmd: "mv {{ matrix_go_skype_bridge_base_path }}/go-skype-bridge.db {{ matrix_go_skype_bridge_data_path }}/go-skype-bridge.db"
  90. creates: "{{ matrix_go_skype_bridge_data_path }}/go-skype-bridge.db"
  91. removes: "{{ matrix_go_skype_bridge_base_path }}/go-skype-bridge.db"
  92. when: "matrix_go_skype_bridge_stat_database.stat.exists"
  93. - name: (Data relocation) Move go-skype-bridge mx-state file to ./data directory
  94. ansible.builtin.command:
  95. cmd: "mv {{ matrix_go_skype_bridge_base_path }}/mx-state.json {{ matrix_go_skype_bridge_data_path }}/mx-state.json"
  96. creates: "{{ matrix_go_skype_bridge_data_path }}/mx-state.json"
  97. removes: "{{ matrix_go_skype_bridge_base_path }}/mx-state.json"
  98. when: "matrix_go_skype_bridge_stat_mx_state.stat.exists"
  99. - name: Ensure go-skype-bridge config.yaml installed
  100. ansible.builtin.copy:
  101. content: "{{ matrix_go_skype_bridge_configuration | to_nice_yaml(indent=2, width=999999) }}"
  102. dest: "{{ matrix_go_skype_bridge_config_path }}/config.yaml"
  103. mode: 0644
  104. owner: "{{ matrix_user_username }}"
  105. group: "{{ matrix_user_groupname }}"
  106. - name: Ensure go-skype-bridge registration.yaml installed
  107. ansible.builtin.copy:
  108. content: "{{ matrix_go_skype_bridge_registration | to_nice_yaml(indent=2, width=999999) }}"
  109. dest: "{{ matrix_go_skype_bridge_config_path }}/registration.yaml"
  110. mode: 0644
  111. owner: "{{ matrix_user_username }}"
  112. group: "{{ matrix_user_groupname }}"
  113. - name: Ensure matrix-go-skype-bridge.service installed
  114. ansible.builtin.template:
  115. src: "{{ role_path }}/templates/systemd/matrix-go-skype-bridge.service.j2"
  116. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-go-skype-bridge.service"
  117. mode: 0644
  118. register: matrix_go_skype_bridge_systemd_service_result
  119. - name: Ensure matrix-go-skype-bridge.service restarted, if necessary
  120. ansible.builtin.service:
  121. name: "matrix-go-skype-bridge.service"
  122. state: restarted
  123. daemon_reload: true
  124. when: "matrix_go_skype_bridge_requires_restart | bool"