jloh / nagios-nrpe-server

Nagios NRPE Server Role for Ansible
https://blog.jloh.co/nagios-nrpe-ansible-role/
MIT License
29 stars 38 forks source link

Add Arch Linux support #5

Closed k0ste closed 9 years ago

k0ste commented 9 years ago

Also, add nagios_nrpe_server_dir, cause on deb/rpm is /etc/nagios, but on Arch is /etc/nrpe.

jloh commented 9 years ago

Awesome pull request! I've never delt with a Arch OS before, I'll have an read tomorrow and chuck it in the next release.

k0ste commented 9 years ago

May confuse what I was doing in nrpe.cfg I removed the reading catalogs (nrpe.d) - we do not create, they do nothing there, because nrpe will swear to it:

Apr 13 16:28:50 csvideo nrpe [19845]: Could not open config directory '/etc/nagios/nrpe.d' for reading.
Apr 13 16:28:50 csvideo nrpe [19845]: Continuing with errors ...

I would even removed all the comments, they are just in the way, and so everything is clear. IMHO.

jloh commented 9 years ago

Is the file /etc/nrpe/nrpe_local.cfg created on Arch? I really want a way for local configurations to be kept/included. If these files/directories aren't made/created, the play should.

k0ste commented 9 years ago

No.

pacman -Ql nrpe

nrpe /etc/
nrpe /etc/nrpe/
nrpe /etc/nrpe/nrpe.cfg
nrpe /etc/xinetd.d/
nrpe /etc/xinetd.d/nrpe
nrpe /usr/
nrpe /usr/bin/
nrpe /usr/bin/nrpe
nrpe /usr/lib/
nrpe /usr/lib/monitoring-plugins/
nrpe /usr/lib/monitoring-plugins/check_nrpe
nrpe /usr/lib/systemd/
nrpe /usr/lib/systemd/system/
nrpe /usr/lib/systemd/system/nrpe.service
nrpe /usr/lib/systemd/system/nrpe.socket
nrpe /usr/lib/systemd/system/nrpe@.service
nrpe /usr/lib/tmpfiles.d/
nrpe /usr/lib/tmpfiles.d/nrpe.conf
nrpe /usr/share/
nrpe /usr/share/doc/
nrpe /usr/share/doc/nrpe/
nrpe /usr/share/doc/nrpe/README
nrpe /usr/share/doc/nrpe/README.SSL
nrpe /usr/share/doc/nrpe/SECURITY
nrpe /usr/share/licenses/
nrpe /usr/share/licenses/nrpe/
nrpe /usr/share/licenses/nrpe/LEGAL
jloh commented 9 years ago

Okay, interesting. Long story short, I don't want to limit the functionality of RedHat/Debian based users because of how the Arch package works, that seems dumb to me.

Option 1. Add more plays to the Arch playbook to create the files/directories. Something like this should work:

# Create nrpe_local.conf since it isn't created in the Arch package
- name: create nrpe_local.conf [Arch]
  file: >
   path="{{ nagios_nrpe_server_dir }}/nrpe_local.conf" 
   state=touch

# Create nrpe.d dir since it isn't created in the Arch package
- name: create nrpe.d dir [Arch]
  file: >
   path="{{ nagios_nrpe_server_dir }}/nrpe.d/"
   state=directory 
   owner=root group=root mode=0600

And restore your changes to the nrpe.conf file.

Option two: Wrap the options at the bottom of the NRPE conf in if statements so they aren't included in Arch

{% if 'ansible_os_family' != 'Archlinux' %}
#
# local configuration:
# if you'd prefer, you can instead place directives here
include={{ nagios_nrpe_server_dir }}/nrpe_local.cfg
{% endif %}
include={{ nagios_nrpe_server_dir }}/nrpe_ansible.cfg

{% if 'ansible_os_family' != 'Archlinux' %}
# 
# you can place your config snipplets into nrpe.d/
# only snipplets ending in .cfg will get included
include_dir={{ nagios_nrpe_server_dir }}/nrpe.d/
{% endif %}

I'm not 100% sure my syntax are right on those so you'll have to check. I'm happy with either of the above options and I would prefer to use Option 1. Let me know what you think.

As for your comment about removing the comments in the file, if someone comes along and wants to read the file it is a lot easier if there is comments. Please leave them in. You should always comment your code, you wont be alive forever.

k0ste commented 9 years ago

I tell not about code, about config. How look clear config (which is already very simple, everything is obvious from the directives):

log_facility=daemon
pid_file=/var/run/nrpe/nrpe.pid
server_port=5666
nrpe_user=31
nrpe_group=31
allowed_hosts=127.0.0.1,192.168.0.0/16
dont_blame_nrpe=0
allow_bash_command_substitution=0
debug=1
command_timeout=60
connection_timeout=300
include=/etc/nrpe/nrpe_ansible.cfg

12 strings vs 209 :)

I think second option is best, cause it serves the environment, and does not subordinate it.

jloh commented 9 years ago

Awesome work. There are some small formatting things I'll fix up later once I have a style guide setup.

As a final request can you please rebase/squash your commits. http://stackoverflow.com/questions/14534397/squash-all-my-commits-into-one-for-github-pull-request

k0ste commented 9 years ago

Squashed.

jloh commented 9 years ago

Thanks again, this has now been implemented. Ansible Galaxy isn't showing the Arch support for some reason, hopefully that'll update/refresh soon.