Matrix Docker Ansible eploy
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

119 líneas
4.1 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. register: result
  67. retries: "{{ matrix_geturl_retries_count }}"
  68. delay: "{{ matrix_geturl_retries_delay }}"
  69. until: result is not failed
  70. - name: Ensure matrix-grafana.service installed
  71. template:
  72. src: "{{ role_path }}/templates/systemd/matrix-grafana.service.j2"
  73. dest: "{{ matrix_systemd_path }}/matrix-grafana.service"
  74. mode: 0644
  75. register: matrix_grafana_systemd_service_result
  76. when: matrix_grafana_enabled|bool
  77. - name: Ensure systemd reloaded after matrix-grafana.service installation
  78. service:
  79. daemon_reload: true
  80. when: "matrix_grafana_enabled|bool and matrix_grafana_systemd_service_result.changed"
  81. #
  82. # Tasks related to getting rid of matrix-grafana (if it was previously enabled)
  83. #
  84. - name: Check existence of matrix-grafana service
  85. stat:
  86. path: "{{ matrix_systemd_path }}/matrix-grafana.service"
  87. register: matrix_grafana_service_stat
  88. - name: Ensure matrix-grafana is stopped
  89. service:
  90. name: matrix-grafana
  91. state: stopped
  92. enabled: false
  93. daemon_reload: true
  94. register: stopping_result
  95. when: "not matrix_grafana_enabled|bool and matrix_grafana_service_stat.stat.exists"
  96. - name: Ensure matrix-grafana.service doesn't exist
  97. file:
  98. path: "{{ matrix_systemd_path }}/matrix-grafana.service"
  99. state: absent
  100. when: "not matrix_grafana_enabled|bool and matrix_grafana_service_stat.stat.exists"
  101. - name: Ensure systemd reloaded after matrix-grafana.service removal
  102. service:
  103. daemon_reload: true
  104. when: "not matrix_grafana_enabled|bool and matrix_grafana_service_stat.stat.exists"