-
Notifications
You must be signed in to change notification settings - Fork 54
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
[pillar] Revamp pillar file structure & allow arbitrary keys in datadog.yaml #35
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
{% if pillar.datadog.checks[check_name].init_config is not defined -%} | ||
{% from "datadog/map.jinja" import datadog_checks with context -%} | ||
|
||
{% if datadog_checks[check_name].init_config is not defined -%} | ||
init_config: | ||
{% endif -%} | ||
|
||
{{ pillar.datadog.checks[check_name] | yaml(False) }} | ||
{{ datadog_checks[check_name] | yaml(False) }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% from "datadog/map.jinja" import datadog_config with context -%} | ||
|
||
[Main] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How was agent 5 working before without this file? :o There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We took the example file that the package provides (or the |
||
dd_url: https://app.datadoghq.com | ||
|
||
{% if datadog_config.api_key is not defined -%} | ||
api_key: | ||
{% else -%} | ||
api_key: {{ datadog_config.api_key }} | ||
{% endif -%} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% from "datadog/map.jinja" import datadog_config with context -%} | ||
|
||
{% if datadog_config.api_key is not defined -%} | ||
api_key: | ||
{% endif -%} | ||
|
||
{% if datadog_config | length -%} | ||
{{ datadog_config | yaml(False) }} | ||
{% endif -%} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
include: | ||
- datadog.config | ||
- datadog.install | ||
- datadog.config | ||
- datadog.service |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,48 +7,56 @@ | |
|
||
{% set default_settings = { | ||
'datadog': { | ||
'pkg_name': 'datadog-agent', | ||
'service_name': 'datadog-agent', | ||
'api_key': 'aaaaaaaabbbbbbbbccccccccdddddddd', | ||
'agent_version': 'latest', | ||
'config': {}, | ||
'checks': {}, | ||
'install_settings': { | ||
'agent_version': 'latest', | ||
'pkg_name': 'datadog-agent', | ||
'service_name': 'datadog-agent', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They were here when I started maintaining the repo, but I agree that they should be hardcoded. But I didn't want to mix the cleanup of the repo with this change ; I'll do the cleanup in another PR |
||
}, | ||
|
||
} | ||
}%} | ||
|
||
{# Merge os_family_map into the default settings #} | ||
{% do default_settings.datadog.update(os_family_map) %} | ||
{% do default_settings.datadog.update(os_family_map) %} | ||
|
||
{# Merge in datadog pillar #} | ||
{% set datadog_settings = salt['pillar.get']('datadog', default=default_settings.datadog, merge=True) %} | ||
{% set datadog = salt['pillar.get']('datadog', default=default_settings.datadog, merge=True) %} | ||
{% set datadog_config = datadog['config'] %} | ||
{% set datadog_checks = datadog['checks'] %} | ||
{% set datadog_install_settings = datadog['install_settings'] %} | ||
|
||
{# Determine if we're looking for the latest package or a specific version #} | ||
{%- if datadog_settings.agent_version == 'latest' %} | ||
{%- if datadog_install_settings.agent_version == 'latest' %} | ||
{%- set latest_agent_version = true %} | ||
{%- else %} | ||
{%- set latest_agent_version = false %} | ||
{%- set parsed_version = datadog_settings.agent_version | regex_match('(([0-9]+)\.[0-9]+\.[0-9]+)(?:~(rc|beta)\.([0-9]+-[0-9]+))?') %} | ||
{%- set parsed_version = datadog_install_settings.agent_version | regex_match('(([0-9]+)\.[0-9]+\.[0-9]+)(?:~(rc|beta)\.([0-9]+-[0-9]+))?') %} | ||
{%- endif %} | ||
|
||
|
||
{# Determine defaults depending on specified version #} | ||
{% if 'config_folder' not in datadog_settings %} | ||
{% if 'config_folder' not in datadog_install_settings %} | ||
{%- if latest_agent_version or parsed_version[1] == '6' %} | ||
{% do datadog_settings.update({'config_folder': '/etc/datadog-agent'}) %} | ||
{% do datadog_install_settings.update({'config_folder': '/etc/datadog-agent'}) %} | ||
{%- else %} | ||
{% do datadog_settings.update({'config_folder': '/etc/dd-agent'}) %} | ||
{% do datadog_install_settings.update({'config_folder': '/etc/dd-agent'}) %} | ||
{%- endif %} | ||
{% endif %} | ||
|
||
{% if 'config_file' not in datadog_settings %} | ||
{% if 'config_file' not in datadog_install_settings %} | ||
{%- if latest_agent_version or parsed_version[1] == '6' %} | ||
{% do datadog_settings.update({'config_file': 'datadog.yaml'}) %} | ||
{% do datadog_install_settings.update({'config_file': 'datadog.yaml'}) %} | ||
{%- else %} | ||
{% do datadog_settings.update({'config_file': 'datadog.conf'}) %} | ||
{% do datadog_install_settings.update({'config_file': 'datadog.conf'}) %} | ||
{%- endif %} | ||
{% endif %} | ||
|
||
{% if 'checks_confd' not in datadog_settings %} | ||
{% if 'checks_confd' not in datadog_install_settings %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For For There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above: I'll get rid of For |
||
{%- if latest_agent_version or parsed_version[1] == '6' %} | ||
{% do datadog_settings.update({'checks_confd': '/etc/datadog-agent/conf.d'}) %} | ||
{% do datadog_install_settings.update({'checks_confd': '/etc/datadog-agent/conf.d'}) %} | ||
{%- else %} | ||
{% do datadog_settings.update({'checks_confd': '/etc/dd-agent/conf.d'}) %} | ||
{% do datadog_install_settings.update({'checks_confd': '/etc/dd-agent/conf.d'}) %} | ||
{%- endif %} | ||
{% endif %} | ||
{% endif %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{% from "datadog/map.jinja" import datadog_settings with context %} | ||
{% set config_file_path = '%s/%s'|format(datadog_settings.config_folder, datadog_settings.config_file) -%} | ||
{% from "datadog/map.jinja" import datadog_install_settings, datadog_checks with context %} | ||
{% set config_file_path = '%s/%s'|format(datadog_install_settings.config_folder, datadog_install_settings.config_file) -%} | ||
|
||
datadog-agent-service: | ||
service.running: | ||
- name: {{ datadog_settings.service_name }} | ||
- name: {{ datadog_install_settings.service_name }} | ||
- enable: True | ||
- watch: | ||
- pkg: {{ datadog_settings.pkg_name }} | ||
- pkg: {{ datadog_install_settings.pkg_name }} | ||
- file: {{ config_file_path }} | ||
{%- if datadog_settings.checks is defined %} | ||
- file: {{ datadog_settings.checks_confd }}/* | ||
{%- if datadog_checks | length %} | ||
- file: {{ datadog_install_settings.checks_confd }}/* | ||
{% endif %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{% from "datadog/map.jinja" import datadog_settings with context %} | ||
{% from "datadog/map.jinja" import datadog_install_settings with context %} | ||
|
||
datadog-uninstall: | ||
service.dead: | ||
- name: {{ datadog_settings.service_name }} | ||
- name: {{ datadog_install_settings.service_name }} | ||
- enable: False | ||
pkg.removed: | ||
- pkgs: | ||
- {{ datadog_settings.pkg_name }} | ||
- {{ datadog_install_settings.pkg_name }} | ||
- require: | ||
- service: datadog-uninstall |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
datadog: | ||
api_key: aaaaaaaabbbbbbbbccccccccdddddddd | ||
site: datadoghq.com | ||
python_version: 2 | ||
config: | ||
api_key: aaaaaaaabbbbbbbbccccccccdddddddd | ||
site: datadoghq.com | ||
python_version: 2 | ||
|
||
checks: | ||
directory: | ||
instances: | ||
- directory: "/srv/pillar" | ||
name: "pillars" | ||
|
||
install_settings: | ||
agent_version: latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be parsed_version[0]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parsed_version[0]
contains the full match of the regex defined here: https://github.com/DataDog/datadog-formula/pull/35/files#diff-541c639658b352ec59d46a0868aa02d2R35parsed_version[1]
contains the first capture group, which is the major version number