im building a fully high velocity environment for forman containerized
the setup is
postgres-container
foreman-container
foreman-proxy-container
foreman gets the data for configure its db instance injected. so basically foreman sets itself up after the containers are startet with the given config.
My Problem is: i want to check now if db is already configured and if yes, i want to exit the installer initiation
How can i check from foreman if his db is configured?
i want to do something like
foreman-rake db:initiated-> yes || no
elytscha https://community.theforeman.org/u/elytscha
May 3
im building a fully high velocity environment for forman containerized
the setup is
postgres-container
foreman-container
foreman-proxy-container
foreman gets the data for configure its db instance injected. so basically
foreman sets itself up after the containers are startet with the given
config.
My Problem is: i want to check now if db is already configured and if yes,
i want to exit the installer initiation
How can i check from foreman if his db is configured?
i want to do something like
foreman-rake db:initiated-> yes || no
You can try rake db:migrate: status.
Which containers are you using?
1 Like
Hi, thank you for your solution! i was able to solve it like this
DB_STATUS="$(foreman-rake db:migrate:status 2>&1 | head -n 1)"
if [ "$DB_STATUS" == "Schema migrations table does not exist yet." ]; then
echo "will init db now"
foreman-rake db:migrate RAILS_ENV=production
foreman-rake db:seed RAILS_ENV=production
foreman-rake permissions:reset RAILS_ENV=production > /var/lib/foreman/.admin-default
echo '##################_USERDATA_########################'
cat /var/lib/foreman/.admin-default
echo '##################_USERDATA_########################'
else
echo "db is already configured, starting up"
fi
im just a little bit unhappy with the fact that if a new forman version issues an updated text for the mesage = “Schema migrations table does not exist yet.”, this will break
we build our docker container from scratch by ourself, because we don’t want to rely on public / private docker registrys and also we want to have the full control over our images:
so we have our own base images for ubuntu / centos / rhel / alpine which are builded from scratch
and then we build our applications images on top of this.
this let us do things like install curl in every our base images, so the images relying on our base images does have already curl preinstalled
you can check if you have some migrations in down status, this would mean a migrate is required.