Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

77 lines
3.0 KiB

  1. ---
  2. - set_fact:
  3. matrix_bot_mjolnir_requires_restart: false
  4. - name: Ensure matrix-bot-mjolnir paths exist
  5. file:
  6. path: "{{ item.path }}"
  7. state: directory
  8. mode: 0750
  9. owner: "{{ matrix_user_username }}"
  10. group: "{{ matrix_user_groupname }}"
  11. with_items:
  12. - {path: "{{ matrix_bot_mjolnir_base_path }}", when: true}
  13. - {path: "{{ matrix_bot_mjolnir_config_path }}", when: true}
  14. - {path: "{{ matrix_bot_mjolnir_data_path }}", when: true}
  15. - {path: "{{ matrix_bot_mjolnir_docker_src_files_path }}", when: "{{ matrix_bot_mjolnir_container_image_self_build }}"}
  16. when: "item.when|bool"
  17. - name: Ensure mjolnir Docker image is pulled
  18. docker_image:
  19. name: "{{ matrix_bot_mjolnir_docker_image }}"
  20. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  21. force_source: "{{ matrix_bot_mjolnir_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  22. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_mjolnir_docker_image_force_pull }}"
  23. when: "not matrix_bot_mjolnir_container_image_self_build|bool"
  24. register: result
  25. retries: "{{ matrix_container_retries_count }}"
  26. delay: "{{ matrix_container_retries_delay }}"
  27. until: result is not failed
  28. - name: Ensure mjolnir repository is present on self-build
  29. git:
  30. repo: "{{ matrix_bot_mjolnir_container_image_self_build_repo }}"
  31. dest: "{{ matrix_bot_mjolnir_docker_src_files_path }}"
  32. version: "{{ matrix_bot_mjolnir_docker_image.split(':')[1] }}"
  33. force: "yes"
  34. register: matrix_bot_mjolnir_git_pull_results
  35. when: "matrix_bot_mjolnir_container_image_self_build|bool"
  36. - name: Ensure mjolnir Docker image is built
  37. docker_image:
  38. name: "{{ matrix_bot_mjolnir_docker_image }}"
  39. source: build
  40. force_source: "{{ matrix_bot_mjolnir_git_pull_results.changed }}"
  41. build:
  42. dockerfile: Dockerfile
  43. path: "{{ matrix_bot_mjolnir_docker_src_files_path }}"
  44. pull: true
  45. when: "matrix_bot_mjolnir_container_image_self_build|bool"
  46. - name: Ensure matrix-bot-mjolnir config installed
  47. copy:
  48. content: "{{ matrix_bot_mjolnir_configuration|to_nice_yaml(indent=2, width=999999) }}"
  49. dest: "{{ matrix_bot_mjolnir_config_path }}/production.yaml"
  50. mode: 0644
  51. owner: "{{ matrix_user_username }}"
  52. group: "{{ matrix_user_groupname }}"
  53. - name: Ensure matrix-bot-mjolnir.service installed
  54. template:
  55. src: "{{ role_path }}/templates/systemd/matrix-bot-mjolnir.service.j2"
  56. dest: "{{ matrix_systemd_path }}/matrix-bot-mjolnir.service"
  57. mode: 0644
  58. register: matrix_bot_mjolnir_systemd_service_result
  59. - name: Ensure systemd reloaded after matrix-bot-mjolnir.service installation
  60. service:
  61. daemon_reload: true
  62. when: "matrix_bot_mjolnir_systemd_service_result.changed|bool"
  63. - name: Ensure matrix-bot-mjolnir.service restarted, if necessary
  64. service:
  65. name: "matrix-bot-mjolnir.service"
  66. state: restarted
  67. when: "matrix_bot_mjolnir_requires_restart|bool"