main.yml 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ---
  2. # tasks file for node_exporter
  3. - name: Download and unpack node_exporter
  4. unarchive:
  5. src: "{{ node_exporter_download_url }}"
  6. dest: /tmp
  7. remote_src: True
  8. - name: Copy node_exporter to /usr/local/bin
  9. copy:
  10. remote_src: True
  11. src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ node_exporter_arch }}/node_exporter"
  12. dest: /usr/local/bin
  13. mode: 0744
  14. notify: Restart node_exporter
  15. - name: Ensure systemd service is up to date
  16. register: node_exporter_systemd
  17. template:
  18. src: node_exporter.service.j2
  19. dest: /etc/systemd/system/node_exporter.service
  20. notify: Restart node_exporter
  21. - name: Reload systemd
  22. when: node_exporter_systemd|changed
  23. shell: systemctl daemon-reload
  24. - name: Ensure node_exporter is running and enabled
  25. service:
  26. name: node_exporter
  27. state: running
  28. enabled: yes
  29. - name: Ensure node_exporter nginx config is up to date
  30. template:
  31. src: node_exporter_nginx.j2
  32. dest: "/etc/nginx/site-include/{{ ansible_fqdn }}/node_exporter.conf"
  33. notify: Reload nginx