main.yml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ---
  2. - name: Ensure prometheus group exists
  3. become: yes
  4. group:
  5. name: "{{ prometheus_group }}"
  6. system: yes
  7. state: present
  8. - name: Ensure prometheus user exists
  9. become: yes
  10. user:
  11. name: "{{ prometheus_user }}"
  12. group: "{{ prometheus_group }}"
  13. home: "{{ prometheus_home }}"
  14. system: yes
  15. createhome: yes
  16. state: present
  17. - name: Download and extract prometheus {{ prometheus_version }}
  18. unarchive:
  19. remote_src: yes
  20. src: "{{ prometheus_download_url }}"
  21. dest: "{{ prometheus_home }}"
  22. owner: "{{ prometheus_user }}"
  23. group: "{{ prometheus_group }}"
  24. - name: Ensure link to default prometheus directory is up to date
  25. file:
  26. state: link
  27. src: "{{ prometheus_home }}/prometheus-{{ prometheus_version }}.linux-amd64"
  28. dest: "{{ prometheus_home }}/prometheus"
  29. - name: Ensure prometheus config is up to date
  30. template:
  31. src: prometheus_config.j2
  32. dest: "{{ prometheus_home }}/config.yml"
  33. owner: "{{ prometheus_user }}"
  34. group: "{{ prometheus_group }}"
  35. notify: Restart prometheus
  36. - name: Ensure prometheus systemd unit is up to date
  37. become: yes
  38. register: prometheus_systemd
  39. template:
  40. src: prometheus.service.j2
  41. dest: /etc/systemd/system/prometheus.service
  42. notify: Restart prometheus
  43. - name: Reload systemd units
  44. become: yes
  45. when: prometheus_systemd|changed
  46. shell: systemctl daemon-reload
  47. - name: Ensure prometheus is running and enabled
  48. service:
  49. name: prometheus
  50. state: started
  51. enabled: yes
  52. - include: nginx.yml