- name: Install telegraf prerequsistes apt: pkg: - apt-transport-https - curl - name: Add influx repo key shell: curl -sL https://repos.influxdata.com/influxdb.key | apt-key add - #- name: Check system version # shell: source /etc/os-release # args: # executable: /bin/bash # #- set_fact: VERSION_ID="{{ lookup('env','VERSION_ID') }}" - name: memorize debian version variable shell: cat /etc/debian_version | cut -d. -f1 register: debian_version - set_fact: debian_version={{ debian_version.stdout }} - name: add repo for debian 7 when: "{{ debian_version }} == 7" shell: echo "deb https://repos.influxdata.com/debian wheezy stable" | tee /etc/apt/sources.list.d/influxdb.list - name: add repo for debian 8 when: "{{ debian_version }} == 8" shell: echo "deb https://repos.influxdata.com/debian jessie stable" | tee /etc/apt/sources.list.d/influxdb.list - name: add repo for debian 9 when: "{{ debian_version }} == 9" shell: echo "deb https://repos.influxdata.com/debian stretch stable" | tee /etc/apt/sources.list.d/influxdb.list - name: Update repositories cache apt: update_cache: yes - name: telegraf apt: pkg: - telegraf - name: create telegraf basic config 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 - name: restart telegraf systemd: state: restarted name: telegraf - name: restart telegraf systemd: enabled: yes name: telegraf #- name: display public key # vars: # debug: # msg: # - 'telegraf now installed, edit /etc/telegraf/telegraf.conf adding:' # - '[[outputs.influxdb]]' # - ' urls = ["http://172.20.1.168:8086"]' # - ' database = "telegraf_vcn_int"' # - ' username = "telegraf_akari"' # - ' password = "FCw7izWVan8cnh3upuwxtn15pnlhjWY2"' - name: display help next steps vars: contents: "{{ lookup('file', 'repo/telegraf_settings') }}" debug: msg="{{ contents.split('\n') }}"