mclarkson / nagrestconf

Nagios REST Interface
12 stars 5 forks source link

Docker installation guide results wrong user configuration #80

Closed riknykn closed 6 years ago

riknykn commented 6 years ago

If you follow docker installation guideline (https://github.com/mclarkson/nagrestconf-docker), the resulting configuration where applying configuration in Nagrestconf causes error:

----------------------------------------------------------------------------------------------------
- APPLYING NAGIOS CONFIGURATION (csv2nag -y all)
----------------------------------------------------------------------------------------------------

sudo: no tty present and no askpass program specified

----------------------------------------------------------------------------------------------------
- NAGIOS CONFIGURATION CHECK (nagios -v /etc/nagios/nagios.cfg)
----------------------------------------------------------------------------------------------------

sudo: no tty present and no askpass program specified

CONFIG ERROR

----------------------------------------------------------------------------------------------------
- SCHEDULING NAGIOS RESTART
----------------------------------------------------------------------------------------------------

NAGCTL ERROR: Config error. Nagios restart request not sent.

Problem seems to be sudoers file, where nagrestconf_install expects have group nagios, but nagrestconf is executed by www-data, when run from docker container. Manually it is possible to fix sudoers, but one needs to edit also nagrestconf_install, because it overwrites line
%nagios ALL = NOPASSWD: $NAGIOSBIN -v *, /usr/bin/csv2nag -y all or %www-data ALL = NOPASSWD: $NAGIOSBIN -v *, /usr/bin/csv2nag -y all in each restart.

mclarkson commented 6 years ago

I just tried and it works fine for me using JasonRivers/Docker-Nagios. Please ensure you copy/paste exactly as shown, then later try with different options (if you need to do that). Note that I updated nagrestconf-docker just a few days ago to fix this very issue so maybe, before you try again, delete all your docker images and docker containers.

Just to be clear I did exactly the following using docker 1.31.1 (from Fedora 27 repos):

docker run -d --name nagios4 -p 8080:80 -v /opt/nagios jasonrivers/nagios:latest

wget https://raw.githubusercontent.com/mclarkson/nagrestconf-docker/master/jasonrivers_docker-nagios.env

docker run -d -p 8880:8080 --name nagrestconf -v /tmp \
  --volumes-from nagios4 --env-file jasonrivers_docker-nagios.env \
  mclarkson/nagrestconf

docker run -d --name nagrestconf-restarter \
    -e NAGIOSCMD=/opt/nagios/var/rw/nagios.cmd \
    --volumes-from nagrestconf mclarkson/nagrestconf-restarter

Then firefox to http://localhost:8880/nagrestconf and restore the nagcfgbak_example_v3.tgz file as shown on the web site.

After clicking Apply Changes I get no errors.

If it doesn't work for you please let me know your docker version. Thanks!

riknykn commented 6 years ago

Just tested with a fresh Ubuntu 16.04.3 and works perfectly. Problem in the earlier installation might be that there was existing nagios and www-data users. Case closed.