Matrix Docker Ansible eploy
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

115 wiersze
3.9 KiB

  1. ---
  2. #
  3. # Tasks related to setting up matrix-grafana
  4. #
  5. - name: Ensure matrix-grafana image is pulled
  6. docker_image:
  7. name: "{{ matrix_grafana_docker_image }}"
  8. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  9. force_source: "{{ matrix_grafana_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  10. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_grafana_docker_image_force_pull }}"
  11. when: "matrix_grafana_enabled|bool"
  12. register: result
  13. retries: "{{ matrix_container_retries_count }}"
  14. delay: "{{ matrix_container_retries_delay }}"
  15. until: result is not failed
  16. - name: Ensure grafana paths exists
  17. file:
  18. path: "{{ item }}"
  19. state: directory
  20. mode: 0750
  21. owner: "{{ matrix_user_username }}"
  22. group: "{{ matrix_user_groupname }}"
  23. with_items:
  24. - "{{ matrix_grafana_base_path }}"
  25. - "{{ matrix_grafana_config_path }}"
  26. - "{{ matrix_grafana_config_path }}/provisioning"
  27. - "{{ matrix_grafana_config_path }}/provisioning/datasources"
  28. - "{{ matrix_grafana_config_path }}/provisioning/dashboards"
  29. - "{{ matrix_grafana_config_path }}/dashboards"
  30. - "{{ matrix_grafana_data_path }}"
  31. when: matrix_grafana_enabled|bool
  32. - name: Ensure grafana.ini present
  33. template:
  34. src: "{{ role_path }}/templates/grafana.ini.j2"
  35. dest: "{{ matrix_grafana_config_path }}/grafana.ini"
  36. mode: 0440
  37. owner: "{{ matrix_user_username }}"
  38. group: "{{ matrix_user_groupname }}"
  39. when: matrix_grafana_enabled|bool
  40. - name: Ensure provisioning/datasources/default.yaml present
  41. template:
  42. src: "{{ role_path }}/templates/datasources.yaml.j2"
  43. dest: "{{ matrix_grafana_config_path }}/provisioning/datasources/default.yaml"
  44. mode: 0440
  45. owner: "{{ matrix_user_username }}"
  46. group: "{{ matrix_user_groupname }}"
  47. when: matrix_grafana_enabled|bool
  48. - name: Ensure provisioning/dashboards/default.yaml present
  49. template:
  50. src: "{{ role_path }}/templates/dashboards.yaml.j2"
  51. dest: "{{ matrix_grafana_config_path }}/provisioning/dashboards/default.yaml"
  52. mode: 0440
  53. owner: "{{ matrix_user_username }}"
  54. group: "{{ matrix_user_groupname }}"
  55. when: matrix_grafana_enabled|bool
  56. - name: Ensure dashboard(s) downloaded
  57. get_url:
  58. url: "{{ item }}"
  59. dest: "{{ matrix_grafana_config_path }}/dashboards/"
  60. force: true
  61. mode: 0440
  62. owner: "{{ matrix_user_username }}"
  63. group: "{{ matrix_user_groupname }}"
  64. with_items: "{{ matrix_grafana_dashboard_download_urls_all }}"
  65. when: matrix_grafana_enabled|bool
  66. - name: Ensure matrix-grafana.service installed
  67. template:
  68. src: "{{ role_path }}/templates/systemd/matrix-grafana.service.j2"
  69. dest: "{{ matrix_systemd_path }}/matrix-grafana.service"
  70. mode: 0644
  71. register: matrix_grafana_systemd_service_result
  72. when: matrix_grafana_enabled|bool
  73. - name: Ensure systemd reloaded after matrix-grafana.service installation
  74. service:
  75. daemon_reload: true
  76. when: "matrix_grafana_enabled|bool and matrix_grafana_systemd_service_result.changed"
  77. #
  78. # Tasks related to getting rid of matrix-grafana (if it was previously enabled)
  79. #
  80. - name: Check existence of matrix-grafana service
  81. stat:
  82. path: "{{ matrix_systemd_path }}/matrix-grafana.service"
  83. register: matrix_grafana_service_stat
  84. - name: Ensure matrix-grafana is stopped
  85. service:
  86. name: matrix-grafana
  87. state: stopped
  88. enabled: false
  89. daemon_reload: true
  90. register: stopping_result
  91. when: "not matrix_grafana_enabled|bool and matrix_grafana_service_stat.stat.exists"
  92. - name: Ensure matrix-grafana.service doesn't exist
  93. file:
  94. path: "{{ matrix_systemd_path }}/matrix-grafana.service"
  95. state: absent
  96. when: "not matrix_grafana_enabled|bool and matrix_grafana_service_stat.stat.exists"
  97. - name: Ensure systemd reloaded after matrix-grafana.service removal
  98. service:
  99. daemon_reload: true
  100. when: "not matrix_grafana_enabled|bool and matrix_grafana_service_stat.stat.exists"