postgresql: updates to get things working with systemd
PATCH 1/1 postgresql: updates to get things working with systemd
Convert the sysvinit code to instead work with systemd. We are no longer able to make use of postinst scripts as we need to perform setup after the postgresql service is started, this will have 'knock-on' effects for other postinst, such as for keystone. Changing these postinst to "one time" services buys us greater control and easier readability than the postinst scripts, so overall this is a good change.
Signed-off-by Mark Asselstine <[email protected]>
--- .../classes/hosts.bbclass | 2 +- .../postgresql/postgresql/postgresql | 117 ++++++--------------- .../postgresql/postgresql/postgresql-init | 9 +- .../postgresql/postgresql/postgresql-init.service | 12 +++ .../postgresql/postgresql_9.%.bbappend | 65 +++++------- 5 files changed, 78 insertions(+), 127 deletions(-) create mode 100644 meta-openstack/recipes-support/postgresql/postgresql/postgresql-init.service
meta-openstack-controller-deploy/classes/hosts.bbclass +1 -1
@@ -5,4 +5,4 @@ CONTROLLER_IP ?= "192.168.7.2" CONTROLLER_HOST ?= "controller" MY_IP ?= "${CONTROLLER_IP}" MY_HOST ?= "${CONTROLLER_HOST}" -DB_DATADIR ?= "/etc/postgresql" +DB_DATADIR ?= "/etc/postgresql/data"
meta-openstack/recipes-support/postgresql/postgresql/postgresql +32 -85
125 lines not on this page · raw message
meta-openstack/recipes-support/postgresql/postgresql/postgresql-init +6 -3
@@ -18,11 +18,14 @@ if [ -e $DATA_DIR/PG_VERSION ]; then exit 0 fi +# Create the DB sudo -u postgres initdb -D $DATA_DIR + +# Allow readers/writers by IP echo "listen_addresses = '*'" >> $DATA_DIR/postgresql.conf echo "host all all ${CONTROLLER_IP}/32 trust" >> $DATA_DIR/pg_hba.conf echo "host all all ${COMPUTE_IP}/32 trust" >> $DATA_DIR/pg_hba.conf -/etc/init.d/postgresql start +systemctl restart postgresql count=0 done=0
@@ -30,9 +33,9 @@ while [ $count -le 10 ] && [ $done -eq 0 ]; do sudo -u postgres psql -c "CREATE ROLE ${DB_USER} WITH SUPERUSER LOGIN PASSWORD '${DB_PASSWORD}'" 2> /dev/null if [ $? -ne 0 ]; then echo "[INFO] postgres: failed to create account for ${DB_USER}, trying again" - /etc/init.d/postgresql stop + systemctl stop postresql sleep 3 - /etc/init.d/postgresql start + systemctl start postgresql sleep 3 else echo "[INFO] postgres: created account for ${DB_USER}, continuing .. "
meta-openstack/recipes-support/postgresql/postgresql/postgresql-init.service new file +12 -0
@@ -0,0 +1,12 @@ +[Unit] +Description=Postgresql setup for OpenStack +After=postgresql.service + +[Service] +Type=oneshot +ExecStart=%SYSCONFIGDIR%/postgresql/postgresql-init +ExecStartPost=/bin/systemctl --no-reload disable postgresql-init.service +RemainAfterExit=No + +[Install] +WantedBy=multi-user.target
meta-openstack/recipes-support/postgresql/postgresql_9.%.bbappend +27 -38
84 lines not on this page · raw message
Signature · 1 line
2.7.4