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.
 
 

67 lines
2.6 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. - set_fact:
  30. matrix_prometheus_scraper_node_targets: ["{{ matrix_docker_network_info.network.IPAM.Config[0].Gateway }}:9100"]
  31. when: "matrix_prometheus_scraper_node_enabled|bool and matrix_prometheus_scraper_node_targets|length == 0"
  32. - name: Download synapse-v2.rules
  33. get_url:
  34. url: "{{ matrix_prometheus_scraper_synapse_rules_download_url }}"
  35. dest: "{{ matrix_prometheus_config_path }}/synapse-v2.rules"
  36. force: true
  37. mode: 0440
  38. owner: "{{ matrix_user_username }}"
  39. group: "{{ matrix_user_groupname }}"
  40. when: "matrix_prometheus_scraper_synapse_rules_enabled|bool"
  41. - name: Ensure prometheus.yml installed
  42. copy:
  43. content: "{{ matrix_prometheus_configuration|to_nice_yaml }}"
  44. dest: "{{ matrix_prometheus_config_path }}/prometheus.yml"
  45. mode: 0644
  46. owner: "{{ matrix_user_username }}"
  47. group: "{{ matrix_user_groupname }}"
  48. - name: Ensure matrix-prometheus.service installed
  49. template:
  50. src: "{{ role_path }}/templates/systemd/matrix-prometheus.service.j2"
  51. dest: "{{ matrix_systemd_path }}/matrix-prometheus.service"
  52. mode: 0644
  53. register: matrix_prometheus_systemd_service_result
  54. - name: Ensure systemd reloaded after matrix-prometheus.service installation
  55. service:
  56. daemon_reload: yes
  57. when: "matrix_prometheus_systemd_service_result.changed|bool"