Ansible : how to create roles and install prometheus, grafana and node-exporter
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…