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.
 
 

69 lines
2.8 KiB

  1. ---
  2. - name: Ensure matrix-prometheus image is pulled
  3. docker_image:
  4. name: "{{ matrix_prometheus_docker_image }}"
  5. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  6. force_source: "{{ matrix_prometheus_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  7. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_prometheus_docker_image_force_pull }}"
  8. - name: Ensure Prometheus paths exists
  9. file:
  10. path: "{{ item }}"
  11. state: directory
  12. mode: 0750
  13. owner: "{{ matrix_user_username }}"
  14. group: "{{ matrix_user_groupname }}"
  15. with_items:
  16. - "{{ matrix_prometheus_base_path }}"
  17. - "{{ matrix_prometheus_config_path }}"
  18. - "{{ matrix_prometheus_data_path }}"
  19. - block:
  20. # Well, this actually creates the network if it doesn't exist, but..
  21. # The network should have been created by `matrix-base` already.
  22. # We don't rely on that other call and its result, because it runs
  23. # on `--tags=setup-all`, but will get skipped during `--tags=setup-prometheus`.
  24. - name: Fetch Matrix Docker network details
  25. docker_network:
  26. name: "{{ matrix_docker_network }}"
  27. driver: bridge
  28. register: matrix_docker_network_info
  29. # The `matrix_docker_network_info.ansible_facts.docker_network` workaround is for Ansible < 2.8.
  30. # See: https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/907
  31. - set_fact:
  32. matrix_prometheus_scraper_node_targets: ["{{ (matrix_docker_network_info.network|default(matrix_docker_network_info.ansible_facts.docker_network)).IPAM.Config[0].Gateway }}:9100"]
  33. when: "matrix_prometheus_scraper_node_enabled|bool and matrix_prometheus_scraper_node_targets|length == 0"
  34. - name: Download synapse-v2.rules
  35. get_url:
  36. url: "{{ matrix_prometheus_scraper_synapse_rules_download_url }}"
  37. dest: "{{ matrix_prometheus_config_path }}/synapse-v2.rules"
  38. force: true
  39. mode: 0440
  40. owner: "{{ matrix_user_username }}"
  41. group: "{{ matrix_user_groupname }}"
  42. when: "matrix_prometheus_scraper_synapse_rules_enabled|bool"
  43. - name: Ensure prometheus.yml installed
  44. copy:
  45. content: "{{ matrix_prometheus_configuration|to_nice_yaml }}"
  46. dest: "{{ matrix_prometheus_config_path }}/prometheus.yml"
  47. mode: 0644
  48. owner: "{{ matrix_user_username }}"
  49. group: "{{ matrix_user_groupname }}"
  50. - name: Ensure matrix-prometheus.service installed
  51. template:
  52. src: "{{ role_path }}/templates/systemd/matrix-prometheus.service.j2"
  53. dest: "{{ matrix_systemd_path }}/matrix-prometheus.service"
  54. mode: 0644
  55. register: matrix_prometheus_systemd_service_result
  56. - name: Ensure systemd reloaded after matrix-prometheus.service installation
  57. service:
  58. daemon_reload: yes
  59. when: "matrix_prometheus_systemd_service_result.changed|bool"