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.

32 lines
1.1 KiB

  1. ---
  2. # Role to deploy prometheus node and add them to a prometheus server
  3. - name: Import OS variables
  4. include_vars: "{{ ansible_os_family }}.yml"
  5. - name: install node exporter
  6. package:
  7. name: "{{ prometheus_exporter_package }}"
  8. state: latest
  9. notify: enable exporter
  10. - import_tasks: debian.yml
  11. when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
  12. - import_tasks: redhat.yml
  13. when: ansible_distribution == 'CentOS' or ansible_distribution == 'CloudLinux' or ansible_distribution == 'Virtuozzo'
  14. - name: import discovery file to server
  15. template:
  16. src: sd_file.yml.j2
  17. dest: "{{ prometheus_sd_directory }}/{{ ansible_nodename }}.yml"
  18. delegate_to: "{{ prometheus_server }}"
  19. - name: add nodename to server hosts
  20. lineinfile:
  21. path: /etc/hosts
  22. regexp: '{{ prometheus_exporter_listen_address }} {{ ansible_nodename }}'
  23. state: present
  24. line: '{{ prometheus_exporter_listen_address }} {{ ansible_nodename }}'
  25. delegate_to: "{{ prometheus_server }}"
  26. when: prometheus_exporter_listen_address is defined and prometheus_exporter_listen_address != "0.0.0.0"
  27. notify: reload server