Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7102 from openedx/nadeem/update-datadog-role
Browse files Browse the repository at this point in the history
chore: update the Datadog role to be compatible with the latest agent
  • Loading branch information
nadeemshahzad authored Feb 14, 2024
2 parents ea07703 + 6d4c7f4 commit 54ff961
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 17 deletions.
29 changes: 19 additions & 10 deletions playbooks/roles/datadog/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
---
DATADOG_API_KEY: "SPECIFY_KEY_HERE"

DATADOG_AGENT_VERSION: '1:5.10.1-1'
DATADOG_SITE: datadoghq.com

datadog_apt_key: "0x382E94DE"
DATADOG_AGENT_VERSION: '1:7.50.3-1'

datadog_user: "dd-agent"

# Variables for Datadog MongoDB Monitoring
datadog_mongo_host: 127.0.0.1
datadog_mongo_port: 27017
datadog_mongo_username: datadog
datadog_mongo_password: password
datadog_mongo_db: admin
datadog_authsource_db: admin

datadog_apt_key: "0xAD9589B7"
datadog_debian_pkgs:
- apparmor-utils
- build-essential
- curl
- g++
- gcc
- ipython
- pkg-config
- rsyslog
- apt-transport-https
- curl
- gnupg

DATADOG_MONGODB_MONITORING: true
37 changes: 30 additions & 7 deletions playbooks/roles/datadog/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@

- name: Add apt key for datadog
apt_key:
id: "382E94DE"
id: "33EE313BAD9589B7"
url: "{{ COMMON_UBUNTU_APT_KEYSERVER }}{{ datadog_apt_key }}"
state: present
tags:
- datadog

- name: Install apt repository for datadog
apt_repository:
repo: 'deb http://apt.datadoghq.com/ stable main'
repo: 'deb http://apt.datadoghq.com/ stable 7'
state: present
update_cache: yes
tags:
Expand All @@ -43,23 +43,46 @@
- datadog

- name: Bootstrap config
shell: cp datadog.conf.example datadog.conf
shell: cp datadog.yaml.example datadog.yaml
args:
chdir: /etc/dd-agent/
creates: /etc/dd-agent/datadog.conf
chdir: /etc/datadog-agent/
creates: /etc/datadog-agent/datadog.yaml
tags:
- datadog

- name: Update api-key
lineinfile:
dest: "/etc/dd-agent/datadog.conf"
dest: "/etc/datadog-agent/datadog.yaml"
regexp: "^api_key:.*"
line: "api_key:{{ DATADOG_API_KEY }}"
line: "api_key: {{ DATADOG_API_KEY }}"
notify:
- restart the datadog service
tags:
- datadog

- name: Update site
lineinfile:
dest: "/etc/datadog-agent/datadog.yaml"
regexp: "^# site:.*"
line: "site: {{ DATADOG_SITE }}"
notify:
- restart the datadog service
tags:
- datadog

- name: Write MongoDB monitoring config
template:
src: "conf.yaml.j2"
dest: "/etc/datadog-agent/conf.d/mongo.d/conf.yaml"
owner: "{{ datadog_user }}"
group: "{{ datadog_user }}"
mode: 0644
notify:
- restart the datadog service
tags:
- datadog
when: DATADOG_MONGODB_MONITORING | default(false) | bool

- name: Ensure started and enabled
service:
name: datadog-agent
Expand Down
9 changes: 9 additions & 0 deletions playbooks/roles/datadog/templates/conf.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
init_config:
instances:
- hosts:
- {{ datadog_mongo_host }}:{{ datadog_mongo_port }}
username: {{ datadog_mongo_username }}
password: {{ datadog_mongo_password }}
database: {{ datadog_mongo_db }}
options:
authSource: {{ datadog_authsource_db }}

0 comments on commit 54ff961

Please sign in to comment.