Member-only story

Ansible : how to create roles and install prometheus, grafana and node-exporter

Xavier Pestel (Xavki)
4 min readJun 21, 2021

How to learn ansible ? Many people begin with this infrastructure as code and many companies adopt it.

Ansible is a great tool because you can do many things with it… and it’s very easy to begin with it. When you try it, you adopt it.

As a practical exercise I’ suggest you to install a monitoring stack like prometheus, grafana and node-exporter. Because that allow you to practice different and standard modules with a little or a large scale.

To begin define an inventory

Before to code your ansible roles, I prefer to begin with the inventory file. In this file, we describe our inrfastructure.

In our case, with use a simple yaml format like it 00_inventory.yaml :

all:
children:
monitor:
hosts:
172.17.0.2
others:
hosts:
172.17.0.5:
172.17.0.4:
172.17.0.3:

Easy ? we have only two groups :

  • monitor : for our monitoring stack (prometheus and grafana)
  • others : for all other servers
  • and of course the all group which merge…

Xavier Pestel (Xavki)
Xavier Pestel (Xavki)

Written by Xavier Pestel (Xavki)

Microservices architecture and opensource. I’m maintainer of xavki https://youtube.com/c/xavki-linux about opensource. My blog : https://xavki.blog/

Responses (2)

Write a response

node_exorter.service.j2

exporter

--

Really good article !
I am a DevOps beginner and it's really cool !
Some mistakes:
1) Of course we need to create node_exPorter.service.j2 file in teMplates directory :
2) "Then we can set some defaults variables in the default directory "
In my humble…

--