Matrix Docker Ansible eploy
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 

93 rindas
3.8 KiB

  1. ---
  2. - ansible.builtin.set_fact:
  3. matrix_bot_draupnir_requires_restart: false
  4. - name: Ensure matrix-bot-draupnir paths exist
  5. ansible.builtin.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_draupnir_base_path }}", when: true}
  13. - {path: "{{ matrix_bot_draupnir_config_path }}", when: true}
  14. - {path: "{{ matrix_bot_draupnir_data_path }}", when: true}
  15. - {path: "{{ matrix_bot_draupnir_docker_src_files_path }}", when: "{{ matrix_bot_draupnir_container_image_self_build }}"}
  16. when: "item.when | bool"
  17. - name: Ensure matrix-bot-draupnir support files installed
  18. ansible.builtin.template:
  19. src: "{{ item.src }}"
  20. dest: "{{ item.dest }}"
  21. owner: "{{ matrix_user_username }}"
  22. group: "{{ matrix_user_groupname }}"
  23. mode: 0644
  24. with_items:
  25. - src: "{{ role_path }}/templates/labels.j2"
  26. dest: "{{ matrix_bot_draupnir_base_path }}/labels"
  27. - name: Ensure Draupnir Docker image is pulled
  28. community.docker.docker_image:
  29. name: "{{ matrix_bot_draupnir_docker_image }}"
  30. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  31. force_source: "{{ matrix_bot_draupnir_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  32. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_draupnir_docker_image_force_pull }}"
  33. when: "not matrix_bot_draupnir_container_image_self_build | bool"
  34. register: result
  35. retries: "{{ devture_playbook_help_container_retries_count }}"
  36. delay: "{{ devture_playbook_help_container_retries_delay }}"
  37. until: result is not failed
  38. - name: Ensure Draupnir repository is present on self-build
  39. ansible.builtin.git:
  40. repo: "{{ matrix_bot_draupnir_container_image_self_build_repo }}"
  41. dest: "{{ matrix_bot_draupnir_docker_src_files_path }}"
  42. version: "{{ matrix_bot_draupnir_docker_image.split(':')[1] }}"
  43. force: "yes"
  44. become: true
  45. become_user: "{{ matrix_user_username }}"
  46. register: matrix_bot_draupnir_git_pull_results
  47. when: "matrix_bot_draupnir_container_image_self_build | bool"
  48. - name: Ensure Draupnir Docker image is built
  49. community.docker.docker_image:
  50. name: "{{ matrix_bot_draupnir_docker_image }}"
  51. source: build
  52. force_source: "{{ matrix_bot_draupnir_git_pull_results.changed }}"
  53. build:
  54. dockerfile: Dockerfile
  55. path: "{{ matrix_bot_draupnir_docker_src_files_path }}"
  56. pull: true
  57. when: "matrix_bot_draupnir_container_image_self_build | bool"
  58. - name: Ensure matrix-bot-draupnir config installed
  59. ansible.builtin.copy:
  60. content: "{{ matrix_bot_draupnir_configuration | to_nice_yaml(indent=2, width=999999) }}"
  61. dest: "{{ matrix_bot_draupnir_config_path }}/production.yaml"
  62. mode: 0644
  63. owner: "{{ matrix_user_username }}"
  64. group: "{{ matrix_user_groupname }}"
  65. - name: Ensure matrix-bot-draupnir container network is created
  66. community.general.docker_network:
  67. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  68. name: "{{ matrix_bot_draupnir_container_network }}"
  69. driver: bridge
  70. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  71. - name: Ensure matrix-bot-draupnir.service installed
  72. ansible.builtin.template:
  73. src: "{{ role_path }}/templates/systemd/matrix-bot-draupnir.service.j2"
  74. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-draupnir.service"
  75. mode: 0644
  76. register: matrix_bot_draupnir_systemd_service_result
  77. - name: Ensure matrix-bot-draupnir.service restarted, if necessary
  78. ansible.builtin.service:
  79. name: "matrix-bot-draupnir.service"
  80. state: restarted
  81. daemon_reload: true
  82. when: "matrix_bot_draupnir_requires_restart | bool"