LoginSignup
2
3

More than 3 years have passed since last update.

AWSのサーバーにDataDogをAnsibleで導入する

Last updated at Posted at 2019-07-06

環境

  • Ansible 2.7.10
  • Amazon Linux 2 AMI (HVM), SSD Volume Type, ami-0c3fd0f5d33134a76

Playbook

datadog/tasks/main.yml
---
- name: enable datadog repo
  copy: src=../files/datadog.repo dest=/etc/yum.repos.d/datadog.repo
  become: yes

- name: install datadog
  yum:
    name: datadog-agent
    update_cache: yes
    state: present
  become: yes

- name: copy datadog config
  copy:
    src: /etc/datadog-agent/datadog.yaml.example
    dest: /etc/datadog-agent/datadog.yaml
    remote_src: yes
  become: yes

- name: update datadog config
  lineinfile:
    path: /etc/datadog-agent/datadog.yaml
    regexp: '^api_key:.*'
    line: "api_key: (API KEY)"
    remote_src: yes
  become: yes

- name: restart datadog
  systemd:
    name: datadog-agent.service
    state: restarted
  become: yes
datadog/files/datadog.repo
[datadog]
name = Datadog, Inc.
baseurl = https://yum.datadoghq.com/stable/6/x86_64/
enabled=1
gpgcheck=1
gpgkey=https://yum.datadoghq.com/DATADOG_RPM_KEY.public

参考

追記

頑張って書かなくてもAnsible Galaxyあった。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3