環境
- 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あった。