Skip to content

Commit

Permalink
Add option to remove example check configs (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
rockaut authored May 16, 2023
1 parent a1b2116 commit e172075
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ datadog_additional_checks: []
# set this to `true` to delete default checks
datadog_disable_default_checks: false

# set this to `true` to delete example checks
datadog_disable_example_checks: false

# default user/group
datadog_user: dd-agent
datadog_group: dd-agent
Expand Down
8 changes: 8 additions & 0 deletions tasks/_agent-linux-macos-shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
when: datadog_manage_config and datadog_disable_default_checks and item not in datadog_tracked_checks
notify: "{{ _dd_notify_agent }}"

- name: Delete all example checks
file:
path: "{{ _dd_config_dir }}/conf.d/{{ item }}.d/conf.yaml.example"
state: absent
loop: "{{ datadog_conf_directories.files | map(attribute='path') | list | map('basename') | list | map('regex_replace', '^(.*).d$', '\\1') | list }}"
when: datadog_manage_config and datadog_disable_example_checks and item not in datadog_tracked_checks
notify: "{{ _dd_notify_agent }}"

- name: Ensure configuration directories are present for each Datadog check
file:
dest: "{{ _dd_config_dir }}/conf.d/{{ item }}.d"
Expand Down
8 changes: 8 additions & 0 deletions tasks/agent-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
when: datadog_manage_config and datadog_disable_default_checks and item not in datadog_tracked_checks
notify: restart datadog-agent-win

- name: Delete example checks
win_file:
path: "{{ ansible_facts.env['ProgramData'] }}\\Datadog\\conf.d\\{{ item }}.d\\conf.yaml.example"
state: absent
loop: "{{ datadog_conf_directories.files | map(attribute='path') | list | map('win_basename') | list | map('regex_replace', '^(.*).d$', '\\1') | list }}"
when: datadog_manage_config and datadog_disable_example_checks and item not in datadog_tracked_checks
notify: restart datadog-agent-win

- name: Ensure configuration directories are present for each Datadog check
win_file:
path: "{{ datadog_windows_config_root }}\\conf.d\\{{ item }}.d"
Expand Down

0 comments on commit e172075

Please sign in to comment.