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

111 строки
3.8 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. - name: Ensure grafana paths exists
  13. file:
  14. path: "{{ item }}"
  15. state: directory
  16. mode: 0750
  17. owner: "{{ matrix_user_username }}"
  18. group: "{{ matrix_user_groupname }}"
  19. with_items:
  20. - "{{ matrix_grafana_base_path }}"
  21. - "{{ matrix_grafana_config_path }}"
  22. - "{{ matrix_grafana_config_path }}/provisioning"
  23. - "{{ matrix_grafana_config_path }}/provisioning/datasources"
  24. - "{{ matrix_grafana_config_path }}/provisioning/dashboards"
  25. - "{{ matrix_grafana_config_path }}/dashboards"
  26. - "{{ matrix_grafana_data_path }}"
  27. when: matrix_grafana_enabled|bool
  28. - name: Ensure grafana.ini present
  29. template:
  30. src: "{{ role_path }}/templates/grafana.ini.j2"
  31. dest: "{{ matrix_grafana_config_path }}/grafana.ini"
  32. mode: 0440
  33. owner: "{{ matrix_user_username }}"
  34. group: "{{ matrix_user_groupname }}"
  35. when: matrix_grafana_enabled|bool
  36. - name: Ensure provisioning/datasources/default.yaml present
  37. template:
  38. src: "{{ role_path }}/templates/datasources.yaml.j2"
  39. dest: "{{ matrix_grafana_config_path }}/provisioning/datasources/default.yaml"
  40. mode: 0440
  41. owner: "{{ matrix_user_username }}"
  42. group: "{{ matrix_user_groupname }}"
  43. when: matrix_grafana_enabled|bool
  44. - name: Ensure provisioning/dashboards/default.yaml present
  45. template:
  46. src: "{{ role_path }}/templates/dashboards.yaml.j2"
  47. dest: "{{ matrix_grafana_config_path }}/provisioning/dashboards/default.yaml"
  48. mode: 0440
  49. owner: "{{ matrix_user_username }}"
  50. group: "{{ matrix_user_groupname }}"
  51. when: matrix_grafana_enabled|bool
  52. - name: Ensure dashboard(s) downloaded
  53. get_url:
  54. url: "{{ item }}"
  55. dest: "{{ matrix_grafana_config_path }}/dashboards/"
  56. force: true
  57. mode: 0440
  58. owner: "{{ matrix_user_username }}"
  59. group: "{{ matrix_user_groupname }}"
  60. with_items: "{{ matrix_grafana_dashboard_download_urls }}"
  61. when: matrix_grafana_enabled|bool
  62. - name: Ensure matrix-grafana.service installed
  63. template:
  64. src: "{{ role_path }}/templates/systemd/matrix-grafana.service.j2"
  65. dest: "{{ matrix_systemd_path }}/matrix-grafana.service"
  66. mode: 0644
  67. register: matrix_grafana_systemd_service_result
  68. when: matrix_grafana_enabled|bool
  69. - name: Ensure systemd reloaded after matrix-grafana.service installation
  70. service:
  71. daemon_reload: yes
  72. when: "matrix_grafana_enabled|bool and matrix_grafana_systemd_service_result.changed"
  73. #
  74. # Tasks related to getting rid of matrix-grafana (if it was previously enabled)
  75. #
  76. - name: Check existence of matrix-grafana service
  77. stat:
  78. path: "{{ matrix_systemd_path }}/matrix-grafana.service"
  79. register: matrix_grafana_service_stat
  80. - name: Ensure matrix-grafana is stopped
  81. service:
  82. name: matrix-grafana
  83. state: stopped
  84. daemon_reload: yes
  85. register: stopping_result
  86. when: "not matrix_grafana_enabled|bool and matrix_grafana_service_stat.stat.exists"
  87. - name: Ensure matrix-grafana.service doesn't exist
  88. file:
  89. path: "{{ matrix_systemd_path }}/matrix-grafana.service"
  90. state: absent
  91. when: "not matrix_grafana_enabled|bool and matrix_grafana_service_stat.stat.exists"
  92. - name: Ensure systemd reloaded after matrix-grafana.service removal
  93. service:
  94. daemon_reload: yes
  95. when: "not matrix_grafana_enabled|bool and matrix_grafana_service_stat.stat.exists"