dj-wasabi / ansible-telegraf

Installing and configuring Telegraf via Ansible for RedHat/Debian/Ubuntu/Windows/Suse.
MIT License
134 stars 116 forks source link

telegraf_agent_aws_tags creates an invalid Telegraf configuration #128

Closed Puneeth-n closed 4 years ago

Puneeth-n commented 4 years ago

Module commit: 08b1c627107179874338c69aa6d4219d527019a2

Telegraf version:

root@ip-10-10-37-179:/opt/ct/jenkins# telegraf --version
Telegraf 1.14.5 (git: HEAD e77ce3d1)

Configuration:

    - role: dj-wasabi.telegraf
      tags:
        - register
      vars:
        telegraf_agent_docker: False
        telegraf_agent_package_state: latest
        telegraf_agent_interval: 60
        telegraf_agent_aws_tags: "{{ True if ansible_system_vendor in ['Xen', 'Amazon EC2'] else False }}"

        telegraf_global_tags:
          - tag_name: type
            tag_value: jenkins-node
          - tag_name: host
            tag_value: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
        telegraf_plugins_default:
          - plugin: cpu
            config:
              - percpu = true
              - totalcpu = true
          - plugin: disk
            tagpass:
              - fstype = [ "ext4", "xfs" ]
            tagdrop:
              - path = [ "/etc", "/etc/telegraf", "/etc/hostname", "/etc/hosts", "/etc/resolv.conf" ]
          - plugin: io
          - plugin: diskio
          - plugin: mem
          - plugin: system
          - plugin: swap
          - plugin: net
          - plugin: netstat
          - plugin: processes
          - plugin: docker
            config:
              - endpoint = "unix:///var/run/docker.sock"
              - timeout = "5s"

Error:

root@ip-10-10-37-179:/opt/ct/jenkins# telegraf --test
2020-07-10T12:10:18Z I! Starting Telegraf 1.14.5
2020-07-10T12:10:18Z I! Using config file: /etc/telegraf/telegraf.conf
2020-07-10T12:10:18Z E! [telegraf] Error running agent: Error parsing /etc/telegraf/telegraf.conf, line 8: invalid TOML syntax
root@ip-10-10-37-179:/opt/ct/jenkins# cat /etc/telegraf/telegraf.conf
### MANAGED BY dj-wasabi.telegraf ANSIBLE ROLE ###

[global_tags]
    type = "jenkins-node"
    host = "10.10.37.179"

   Name = "jenkins-node-packer-ami-1594382147"
   aws:ec2:fleet-id = "fleet-a220eec6-fe8b-a982-8c30-23a2263d55ae"
   aws:ec2launchtemplate:id = "lt-0fed73d26801b6895"
   aws:ec2launchtemplate:version = "1"

# Configuration for telegraf agent
[agent]
    interval = "60s"
    debug = false
    hostname = "ip-10-10-37-179.eu-west-1.compute.internal"
    round_interval = true
    flush_interval = "10s"
    flush_jitter = "0s"
    collection_jitter = "0s"
    metric_batch_size = 1000
    metric_buffer_limit = 10000
    quiet = false
    logfile = ""
    omit_hostname = false
Puneeth-n commented 4 years ago

The issue is these tags:

   aws:ec2:fleet-id = "fleet-a220eec6-fe8b-a982-8c30-23a2263d55ae"
   aws:ec2launchtemplate:id = "lt-0fed73d26801b6895"
   aws:ec2launchtemplate:version = "1"