debian.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. - name: Install telegraf prerequsistes
  2. apt:
  3. pkg:
  4. - apt-transport-https
  5. - curl
  6. - gnupg2
  7. - name: Add influx repo key
  8. shell: curl -sL https://repos.influxdata.com/influxdb.key | apt-key add -
  9. #- name: Check system version
  10. # shell: source /etc/os-release
  11. # args:
  12. # executable: /bin/bash
  13. #
  14. #- set_fact: VERSION_ID="{{ lookup('env','VERSION_ID') }}"
  15. - name: memorize debian version variable
  16. shell: cat /etc/debian_version | cut -d. -f1
  17. register: debian_version
  18. - set_fact:
  19. debian_version={{ debian_version.stdout }}
  20. - name: add repo for debian 7
  21. when: "{{ debian_version }} == 7"
  22. shell: echo "deb https://repos.influxdata.com/debian wheezy stable" | tee /etc/apt/sources.list.d/influxdb.list
  23. - name: add repo for debian 8
  24. when: "{{ debian_version }} == 8"
  25. shell: echo "deb https://repos.influxdata.com/debian jessie stable" | tee /etc/apt/sources.list.d/influxdb.list
  26. - name: add repo for debian 9
  27. when: "{{ debian_version }} == 9"
  28. shell: echo "deb https://repos.influxdata.com/debian stretch stable" | tee /etc/apt/sources.list.d/influxdb.list
  29. - name: add repo for debian 10
  30. when: "{{ debian_version }} == 10"
  31. shell: echo "deb https://repos.influxdata.com/debian $(lsb_release -cs) stable"|sudo tee /etc/apt/sources.list.d/influxdb.list
  32. - name: add repo for debian 11
  33. when: "{{ debian_version }} == 11"
  34. shell: echo "deb https://repos.influxdata.com/debian $(lsb_release -cs) stable"|sudo tee /etc/apt/sources.list.d/influxdb.list
  35. - name: Update repositories cache
  36. apt:
  37. update_cache: yes
  38. - name: telegraf
  39. apt:
  40. pkg:
  41. - telegraf
  42. #- name: create telegraf basic config
  43. # 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
  44. - name: restart telegraf
  45. systemd:
  46. state: restarted
  47. name: telegraf
  48. - name: restart telegraf
  49. systemd:
  50. enabled: yes
  51. name: telegraf
  52. #- name: display help next steps
  53. # vars:
  54. # contents: "{{ lookup('file', 'repo/telegraf_settings') }}"
  55. # debug: msg="{{ contents.split('\n') }}"