Matrix Docker Ansible eploy
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

148 righe
6.2 KiB

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