Skip to content

Instantly share code, notes, and snippets.

@masaki-ahiru
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masaki-ahiru/67004ff6c9fef06b3d59 to your computer and use it in GitHub Desktop.
Save masaki-ahiru/67004ff6c9fef06b3d59 to your computer and use it in GitHub Desktop.
mackerel-agent インストール用の Ansible Playbook です。
mackerel_install.yaml の使い方
==============================
## 編集
自分の環境に併せて、hosts,remote_user,sudo を変更してください。
## 実行
自分のMackerelアカウントのAPIキーを以下のhogehogeに代入して、実行してください。
$ ansible-playbook mackerel_install.yaml --extra-vars "APIkey=hogehoge"
---
- hosts: example-hosts
remote_user: example-user
sudo: yes
tasks:
- name: setting yum script
shell: curl -fsSL https://mackerel.io/assets/files/scripts/setup-yum.sh | sh
when: ansible_os_family == 'RedHat'
- name: yum install mackerel-agent
yum: name=mackerel-agent state=present
when: ansible_os_family == 'RedHat'
- name: setting apt script
shell: curl -fsSL https://mackerel.io/assets/files/scripts/setup-apt.sh | sh
when: ansible_os_family == 'Debian'
- name: apt-get install mackerel-agent
apt: name=mackerel-agent state=present
when: ansible_os_family == 'Debian'
- name: setting API Key
shell: sed -i 's/# apikey = ""/apikey = "'{{ APIkey }}'"/g' /etc/mackerel-agent/mackerel-agent.conf
- name: restart mackerel-agent
service: name=mackerel-agent state=restarted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment