Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Feature add host tags #24

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions datadog/config.sls
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

{% from "datadog/map.jinja" import datadog with context %}

datadog-example:
Expand All @@ -10,18 +8,50 @@ datadog-example:
- require:
- pkg: datadog-pkg

{% if datadog.api_key is defined %}
datadog-conf:
datadog-api_key-conf:
file.replace:
- name: {{ datadog.config }}
- pattern: "api_key:(.*)"
{% if datadog.api_key is defined %}
- repl: "api_key: {{ datadog.api_key }}"
{% else %}
- repl: "# api_key: "
{% endif %}
- count: 1
- watch:
- pkg: datadog-pkg
- require:
- cmd: datadog-example

datadog-hostname-conf:
file.replace:
- name: {{ datadog.config }}
- pattern: |
(\#\s)?hostname\:(.*)
{% if datadog.hostname is defined %}
- repl: |
hostname: {{ datadog.hostname }}
{% else %}
- repl: |
"# hostname: none"
{% endif %}
- count: 1
- watch:
- pkg: datadog-pkg

datadog-tags-conf:
file.replace:
- name: {{ datadog.config }}
- pattern: |
(\#\s)?tags\:(.*)
{% if datadog.tags %}
- repl: |
tags: {{ datadog.tags|join(", ") }}
{% else %}
- repl: |
"# tags: none"
{% endif %}
- count: 1
- watch:
- pkg: datadog-pkg

{% if datadog.checks is defined %}
{% for check_name in datadog.checks %}
Expand Down
3 changes: 3 additions & 0 deletions datadog/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ datadog:
checks_config: '/etc/dd-agent/conf.d'
service:
name: datadog-agent
docker:
image: datadog/agent
tag: latest
api_key: aaaaaaaabbbbbbbbccccccccdddddddd
10 changes: 10 additions & 0 deletions datadog/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,13 @@ datadog-pkg:
- refresh: True
- require:
- pkgrepo: datadog-repo

#
# DD docker-agent
#
#docker run -d --name dd-agent -v /var/run/docker.sock:/var/run/docker.sock:ro -v /proc/:/host/proc/:ro -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro -e DD_API_KEY=2494bbd7f3f567e4142cb25ef9d9f389 datadog/agent:latest
# docker-agent-present:
# docker_image.present:
# - image: {{ config.docker.image }}
# - tag: {{ config.docker.tag }}
# - force: true # ensure its always pulled
4 changes: 4 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
datadog:
api_key: aaaaaaaabbbbbbbbccccccccdddddddd
hostname: {{ grains.id }} # or done include to have it automatically be calculated
tags:
- env:staging
- team:sunny
checks:
process:
init_config:
Expand Down