ansible-datadog icon indicating copy to clipboard operation
ansible-datadog copied to clipboard

Append tags to datadog.yaml instead of overwriting it with a new file.

Open tostroski opened this issue 2 years ago • 3 comments

I am trying to simplify our datadog rollout with ansible. I am running into an issue where I need multiple data_dog checks on the same host and when the second integration gets installed, it wipes out my main agent datadog.yaml file.

Here is the stripped down example of my playbook:

- name: Deploy Datanode Integration
  hosts: node
  roles:
    - { role: datadog.datadog }
  vars:
    datadog_api_key: "{{ dd_api_key }}"
    datadog_agent_version: "{{ dd_agent_version }}"
    datadog_config:
      tags:
        - service:hdfs_datanode
      logs_enabled: false  # available with Agent v6 and v7
    datadog_checks:
      hdfs_datanode:
        init_config:
        instances:
          - hdfs_datanode_jmx_uri: http://{{ inventory_hostname }}:{{ port }}

- name: Deploy Kafka Integration
  hosts: kafka
  roles:
    - { role: datadog.datadog }
  vars:
    datadog_api_key: "{{ dd_api_key }}"
    datadog_agent_version: "{{ dd_agent_version }}"
    datadog_config:
      tags:
        - service:kafka
      logs_enabled: false  # available with Agent v6 and v7
    datadog_checks:
      kafka:
        init_config:
            is_jmx: true
            collect_default_metrics: true
            new_gc_metrics: true
        instances:
          - host: "{{ inventory_hostname }}"
            port: {{ port }}

The issue is that if a host belongs to both the node group and the kafka group, the node groups tags get wiped out when the kafka group runs.

Is there a way to append the tags in the datadog.yaml file or is there a better way to do this?

Thanks!

tostroski avatar Apr 19 '22 00:04 tostroski

Hi 👋 I think you're basically hitting a variation of https://github.com/DataDog/ansible-datadog/issues/366, which as noted in comment https://github.com/DataDog/ansible-datadog/issues/366#issuecomment-878863752 is more of an Ansible issue rather than issue with the DD role. The referenced issue contains some suggested workarounds that you might be able to use - can you take a look and see if anything there might be helpful?

bkabrda avatar Apr 19 '22 08:04 bkabrda

Thanks for the fast reply! I agree, they are vary similar. I did review #366 before opening this issue, i was not sure how well it would scale into a larger production environment. I will dig into it a bit more.

tostroski avatar Apr 19 '22 11:04 tostroski

Sounds good. I'll also keep this in mind and let you know if I figure out a better way to do these things.

bkabrda avatar Apr 19 '22 11:04 bkabrda