Skip to content

Instantly share code, notes, and snippets.

@wate
Last active February 18, 2020 14:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wate/6a2038999309d4e19bddb35ae9e9bca5 to your computer and use it in GitHub Desktop.
Save wate/6a2038999309d4e19bddb35ae9e9bca5 to your computer and use it in GitHub Desktop.
CentOS 7にGrafanaをインストールします
# ネタ元:https://wiki.infra-workshop.tech/%E5%8B%89%E5%BC%B7%E4%BC%9A%E3%83%AD%E3%82%B0/2018/07/03/Zabbix%26Grafana%E3%81%A7%E7%9B%A3%E8%A6%96%E3%82%92%E5%8F%AF%E8%A6%96%E5%8C%96%E3%81%97%E3%81%A6%E3%81%BF%E3%81%9F
- name: install grafana(CentOS 7 Only)
hosts: all
become: yes
vars:
grafana_plugins:
- alexanderzobnin-zabbix-app
tasks:
- name: add yum repository
yum_repository:
name: grafana
description: grafana
baseurl: https://packagecloud.io/grafana/stable/el/7/$basearch
gpgkey: "https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana"
enabled: false
gpgcheck: true
file: grafana
- name: install grafana
yum:
name: "{{ item }}"
enablerepo: grafana
with_items:
- initscripts
- fontconfig
- grafana
- name: set router_logging setting
lineinfile:
path: /etc/grafana/grafana.ini
regexp: ^;?router_logging = .+
line: router_logging = true
- name: start and enable grafana
systemd:
name: grafana-server
state: started
enabled: true
- name: allow grafana port
firewalld:
port: 3000/tcp
permanent: true
state: enabled
register: result
- name: reload firewalld
systemd:
name: firewalld
state: reloaded
when: result is changed
- name: install grafana plugins
command: grafana-cli plugins install {{ item }}
args:
creates: /var/lib/grafana/plugins/{{ item }}
with_items: "{{ grafana_plugins }}"
register: result
- name: restart grafana
systemd:
name: grafana-server
state: restarted
when: result is changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment