Nagios NRPE Server Ansible Role


NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines. This allows you to monitor remote machine metrics (disk usage, CPU load, etc.). Deploying NRPE is easy through your favourite package manager (apt-get install nagios-nrpe-server or yum install nrpe), configuring your Nagios server’s IP, adding your checks on NRPE’s end and letting Nagios know its there.

But if you’re deploying this often (Or not), why not automate it? I created an Ansible role which installs and configures NRPE from scratch on both Debian and CentOS based servers. All you need to do now is configure it in Nagios and you’re rolling.

Latest version:

How it works

It uses Ansible for deployment and configuration (If you aren’t familiar with Ansible, I highly recommend you watch their video introduction here). The first play installs NRPE and any dependences (NRPE doesn’t come with any plugins on RedHat, wtf?), the second play then configures nrpe.cfg from a Jinja2 template (Ansible’s standard template language of choice). The third play installs nrpe_ansible.cfg where you can place all your custom checks (Again from a Jinja2 template) and finally the final play ensures its running and configured to start at boot.

The Role

As you can see above, its mostly through Jinja2 templates and OS variables. I’ve tested it on CentOS 6, Debian 7 and Ubuntu 14.x. On all systems it worked without a hitch.

Configuration Options

The role allows a few configuration options (see below) although most are either OS Specific and are likely not going to be changed.

  • nagios_nrpe_server_bind_address:
  • nagios_nrpe_server_port: 5666
  • nagios_nrpe_server_allowed_hosts:

And some OS Specific Variables


  • nagios_nrpe_server_pid: /var/run/nrpe/
  • nagios_nrpe_server_user: nrpe
  • nagios_nrpe_server_group: nrpe
  • nagios_nrpe_server_repo_redhat: epel
  • nagios_nrpe_server_service: nrpe


  • nagios_nrpe_server_pid: /var/run/nagios/
  • nagios_nrpe_server_user: nagios
  • nagios_nrpe_server_group: nagios
  • nagios_nrpe_server_service: nagios-nrpe-server
  • nagios_nrpe_server_plugins_dir: /usr/lib/nagios/plugins

You can of course override the OS Specific variables I set above through either a hostgroup var or on a per host variable, if your plugins live in a different directory other then /usr/lib/nagios/plugins for example.

Wrap Up

Thats my role, its lightweight and gets the job done. If you’ve got any questions or feel its missing a feature, feel free to ask it below or open an issue on GitHub. Like the role? Don't forget to rate it on Ansible Galaxy!

Tagged: Monitoring, Nagios, Ansible

Share this post