debian.yml 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. - name: Install telegraf prerequsistes
  2. apt:
  3. pkg:
  4. - apt-transport-https
  5. - curl
  6. - name: Add influx repo key
  7. shell: curl -sL https://repos.influxdata.com/influxdb.key | apt-key add -
  8. #- name: Check system version
  9. # shell: source /etc/os-release
  10. # args:
  11. # executable: /bin/bash
  12. #
  13. #- set_fact: VERSION_ID="{{ lookup('env','VERSION_ID') }}"
  14. - name: memorize debian version variable
  15. shell: cat /etc/debian_version | cut -d. -f1
  16. register: debian_version
  17. - set_fact:
  18. debian_version={{ debian_version.stdout }}
  19. - name: add repo for debian 7
  20. when: "{{ debian_version }} == 7"
  21. shell: echo "deb https://repos.influxdata.com/debian wheezy stable" | tee /etc/apt/sources.list.d/influxdb.list
  22. - name: add repo for debian 8
  23. when: "{{ debian_version }} == 8"
  24. shell: echo "deb https://repos.influxdata.com/debian jessie stable" | tee /etc/apt/sources.list.d/influxdb.list
  25. - name: add repo for debian 9
  26. when: "{{ debian_version }} == 9"
  27. shell: echo "deb https://repos.influxdata.com/debian stretch stable" | tee /etc/apt/sources.list.d/influxdb.list
  28. - name: Update repositories cache
  29. apt:
  30. update_cache: yes
  31. - name: telegraf
  32. apt:
  33. pkg:
  34. - telegraf
  35. #- name: create telegraf basic config
  36. # shell: telegraf -sample-config -input-filter cpu:mem:swap:net:netstat:disk:diskio:docker:system:processes:kernel:sysstat:conntrack:nstat:iptables:sensors -output-filter influxdb > /etc/telegraf/telegraf.conf
  37. - name: restart telegraf
  38. systemd:
  39. state: restarted
  40. name: telegraf
  41. - name: restart telegraf
  42. systemd:
  43. enabled: yes
  44. name: telegraf
  45. - name: display help next steps
  46. vars:
  47. contents: "{{ lookup('file', 'repo/telegraf_settings') }}"
  48. debug: msg="{{ contents.split('\n') }}"