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

refactor: deploy datadog role using anisble galaxy #7132

Closed
wants to merge 4 commits into from
Closed
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
25 changes: 3 additions & 22 deletions playbooks/roles/datadog/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
---
DATADOG_API_KEY: "SPECIFY_KEY_HERE"

DATADOG_SITE: datadoghq.com

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:
- apt-transport-https
- curl
- gnupg

DATADOG_MONGODB_MONITORING: false
datadog_api_key: "{{ datadog_api_key }}"
datadog_config: "{{ datadog_config }}"
datadog_checks: "{{ datadog_checks }}"
5 changes: 0 additions & 5 deletions playbooks/roles/datadog/handlers/main.yml

This file was deleted.

84 changes: 7 additions & 77 deletions playbooks/roles/datadog/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,82 +13,12 @@
# - common
# - datadog
#
- name: Install debian needed pkgs
apt:
name: "{{ datadog_debian_pkgs }}"
state: present
tags:
- datadog

- name: Add apt key for datadog
apt_key:
id: "33EE313BAD9589B7"
url: "{{ COMMON_UBUNTU_APT_KEYSERVER }}{{ datadog_apt_key }}"
state: present
tags:
- datadog
- name: Install Datadog role from Ansible Galaxy
ansible.builtin.command: ansible-galaxy install datadog.datadog
delegate_to: localhost
become: false

- name: Install apt repository for datadog
apt_repository:
repo: 'deb http://apt.datadoghq.com/ stable 7'
state: present
update_cache: yes
tags:
- datadog

- name: Install datadog agent
apt:
name: "datadog-agent={{ DATADOG_AGENT_VERSION }}"
tags:
- datadog

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

- name: Update api-key
lineinfile:
dest: "/etc/datadog-agent/datadog.yaml"
regexp: "^api_key:.*"
line: "api_key: {{ DATADOG_API_KEY }}"
no_log: true
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
no_log: true
notify:
- restart the datadog service
tags:
- datadog
when: DATADOG_MONGODB_MONITORING | default(false) | bool

- name: Ensure started and enabled
service:
name: datadog-agent
state: started
enabled: yes
tags:
- datadog
- name: Install datadog Agent
include_role:
name: datadog.datadog
9 changes: 0 additions & 9 deletions playbooks/roles/datadog/templates/conf.yaml.j2

This file was deleted.

Loading