Upgrading Powerdns-admin

Sat, Jan 8, 2022 2-minute read

Suddenly my powerdns admin installation stopped working, probably because of system upgrades - so I decided to fix it by upgrading to latest version of powerdns-admin. This is a guide for myself.

First some dependencies needs to be installed

sudo apt-get update
sudo apt-get install pip
sudo apt install python3.8-venv

Then we take a backup of the existing installation, so we have it for reference and to retain the old configuration in an easy way.

cd /opt/web

#make sure you can clone new version
sudo chmod a+xrw .

mv powerdns-admin ./powerdns-admin-backup

Then we clone the latest version from github

git clone https://github.com/PowerDNS-Admin/PowerDNS-Admin.git ./powerdns-admin

And now starts the nitty gritty installation

cd /opt/web/powerdns-admin

First we create a python virtual environment so we do not fuck up existing pything installation.

python3 -mvenv ./flask

Then we activate the virtual environment, which tells pythong/pip that all changes needs to happen inside this virtual environment.

source ./flask/bin/activate

Now we install the required python packages.

python3 -m pip install --upgrade pip
python3 -m pip install wheel
python3 -m pip install -r requirements.txt

Copy the old configuration file to the new powerdns-admin installation directory.

cp /opt/web/powerdns-admin-backup/config.py /opt/web/powerdns-admin/config.py
cp /opt/web/powerdns-admin-backup/config.py /opt/web/powerdns-admin/powerdnsadmin/default_config.py

When that is done we have to migrate the database if required.

export FLASK_APP=powerdnsadmin/__init__.py
flask db upgrade

Then comes creating of all the yarn assets and building of flask files.

yarn install --pure-lockfile
flask assets build

Then we have to make sure that the systemctl powerdns-admin service file is correct.

sudo nano /etc/systemd/system/powerdns-admin.service

If line ExecStart looks like this one:

ExecStart=/opt/web/powerdns-admin/flask/bin/gunicorn –workers 2 –bind unix:/opt/web/powerdns-admin/powerdns-admin.sock app:app

Then it needs to be changed to be like this:

ExecStart=/opt/web/powerdns-admin/flask/bin/gunicorn –workers 2 –bind unix:/opt/web/powerdns-admin/powerdns-admin.sock ‘powerdnsadmin:create_app()’

When that has been done, we need to tell systemctl to reload all files.

sudo systemctl daemon-reload

Then nginx needs to have its configuration files verified.

sudo nano /etc/nginx/conf.d/powerdns-admin.conf

In this file we need to make sure that the root directory points to the correct directory. Older versions of powerdns-admin used and /app directory - this is not the case now.

So look for a line that looks like: root /opt/web/powerdns-admin/app;

And change it to: root /opt/web/powerdns-admin/powerdnsadmin;

When all configuration changes has been done, then we just have to restart powerdns-admin and nginx.

sudo systemctl restart powerdns-admin
sudo systemctl restart nginx

And hopefully everything works again.