jjethwa / icinga2

GNU General Public License v3.0
223 stars 189 forks source link

Can't run with external database #145

Closed morsik closed 6 years ago

morsik commented 6 years ago

Hi, I'm trying to start jordan/icinga2 with external database since the beggining so I use:

# docker run -it \
  --mount "type=bind,source=/srv/icingaweb2-sessions,target=/var/lib/php/sessions" \
  -e 'DEFAULT_MYSQL_HOST=mysql' \
  -e 'DEFAULT_MYSQL_USER=icinga' \
  -e 'DEFAULT_MYSQL_PASS=pass' \
  -e 'ICINGA2_IDO_MYSQL_DATA=icinga_ido' \
  -e 'ICINGAWEB2_MYSQL_DATA=icinga_icingaweb2' \
  -e 'ICINGAWEB2_DIRECTOR_MYSQL_DATA=icinga_director' \
  jordan/icinga2

But it fails with no any interesting error:

Generating locales (this might take a while)...
Generation complete.

Site 000-default already enabled
Site icingaweb2-ssl already disabled
Site icingaweb2-ssl-redirect already disabled
/opt/helpers: line 60: MYSQL_ROOT_PASSWORD: unbound variable
run-parts: /opt/setup/50-icinga2 exited with return code 1

I looked into /opt/setup/50-icinga2 which tried to import database so I imported it manually, but actually - I have no idea what's wrong here, and error is meaningless.

bebehei commented 6 years ago

/opt/helpers: line 60: MYSQL_ROOT_PASSWORD: unbound variable

Quickfix: add -e MYSQL_ROOT_PASSWORD="" to your docker run call.


Other question: Have you intiialized the DBs manually? If not, please give the root password via -e MYSQL_ROOT_PASSWORD="<your password>". Then the container will care about mysql schemas.

morsik commented 6 years ago

I don't want to provide root password for this cause I'm using my shared database - not instance dedicated for Icinga. There should be some other way to import database that doesn't needs mysql root account.

I tried to import IDO2 DB, but error is meaningless and doesn't tell where it crash and what's wrong exactly.

Also, warning about MYSQL_ROOT_PASSWORD is just simple error in code that assumes that this variable contains something - I really don't think this is related to crash.

bebehei commented 6 years ago

The MYSQL_ROOT_PASSWORD was checked for emptyness. While we set -u in the bashscripts, if the variable isn't defined it exits.

This is a stupid cornercase, I didn't cover during testing of #112. This is now fixed in d8623f2


To your issue: Please pull the image again from dockerhub after the build gets finished.

Then recreate your container and the stupid error should have gone.

bebehei commented 6 years ago

If you've still got (different) problems, please report back.