The default installation uses sqlite3 for the django database. To configure mysql or postgresql instead, see the database configuration section.
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0412F522
echo "deb https://repo.openbytes.ie/ubuntu bionic main" > /etc/apt/sources.list.d/patchman.list
apt update
apt -y install python-patchman patchman-client
patchman-manage createsuperuser
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0412F522
echo "deb https://repo.openbytes.ie/debian buster main" > /etc/apt/sources.list.d/patchman.list
apt update
apt -y install python-patchman patchman-client
patchman-manage createsuperuser
cat <<EOF >> /etc/yum.repos.d/openbytes.repo
[openbytes]
name=openbytes
baseurl=https://repo.openbytes.ie/yum
enabled=1
gpgcheck=0
EOF
yum install -y epel-release
yum makecache
yum install -y patchman patchman-client
systemctl restart httpd
patchman-manage createsuperuser
TBD - not working yet
apt -y install gcc libxml2-dev libxslt1-dev virtualenv python-dev zlib1g-dev # (debian/ubuntu)
yum -y install gcc libxml2-devel libxslt-devel python-virtualenv # (centos/rhel)
mkdir /srv/patchman
cd /srv/patchman
virtualenv .
. bin/activate
pip install --upgrade pip
pip install patchman gunicorn whitenoise==3.3.1
patchman-manage migrate
patchman-manage createsuperuser
gunicorn patchman.wsgi -b 0.0.0.0:80
- Install dependencies
apt -y install python-django-tagging python-django python-requests \
python-django-extensions python-argparse python-defusedxml python-rpm python-debian \
python-pygooglechart python-cracklib python-progressbar libapache2-mod-wsgi \
python-djangorestframework apache2 python-colorama python-humanize liblzma-dev \
python-magic python-lxml
- Install django-bootstrap3
pip install django-bootstrap3==11.1.0
- Clone git repo to e.g. /srv/patchman
cd /srv
git clone https://github.com/furlongm/patchman
- Copy server settings example file to /etc/patchman
mkdir /etc/patchman
cp /srv/patchman/etc/patchman/local_settings.py /etc/patchman/
Modify /etc/patchman/local_settings.py
to configure patchman.
If installing from source or using virtualenv, the following settings should be configured:
- ADMINS - set up an admin email address
- SECRET_KEY - create a random secret key
- STATICFILES_DIRS - should point to /srv/patchman/patchman/static if installing from source
The default database backend is sqlite. However, this is not recommended for production deployments. MySQL or PostgreSQL are better choices.
To configure the sqlite database backend:
- Create the database directory specified in the settings file:
mkdir -p /var/lib/patchman/db
- Modify
/etc/patchman/local_settings.py
as follows:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '/var/lib/patchman/db/patchman.db'
}
}
- Proceed to syncing database.
To configure the mysql database backend:
- Ensure mysql-server and the python mysql bindings are installed:
apt -y install default-mysql-server python-mysqldb python-pymysql
- Create database and users:
$ mysql
mysql> CREATE DATABASE patchman CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON patchman.* TO patchman@localhost IDENTIFIED BY 'changeme';
Query OK, 0 rows affected (0.00 sec)
- Modify
/etc/patchman/local_settings.py
as follows:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'patchman',
'USER': 'patchman',
'PASSWORD': 'changeme',
'HOST': '',
'PORT': '',
'STORAGE_ENGINE': 'INNODB',
'CHARSET' : 'utf8'
}
}
- Proceed to syncing database.
To configure the postgresql database backend:
- Ensure the postgresql server and the python postgres bindings are installed:
apt -y install postgresql python-psycopg2
- Create database and users:
$ sudo su - postgres
$ psql
postgres=# CREATE DATABASE patchman;
CREATE DATABASE
postgres=# CREATE USER patchman WITH PASSWORD 'changeme';
CREATE ROLE
postgres=# ALTER ROLE patchman SET client_encoding TO 'utf8';
ALTER ROLE
postgres=# ALTER ROLE patchman SET default_transaction_isolation TO 'read committed';
ALTER ROLE
postgres=# ALTER ROLE patchman SET timezone TO 'UTC';
ALTER ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE patchman to patchman;
GRANT
- Modify
/etc/patchman/local_settings.py
as follows:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'patchman',
'USER': 'patchman',
'PASSWORD': 'changeme',
'HOST': '127.0.0.1',
'PORT': '',
'CHARSET' : 'utf8'
}
}
- Proceed to syncing database.
After configuring a database backend, the django database should be synced:
- Initialise the database, perform migrations, create the admin user and collect static files:
patchman-manage makemigrations
patchman-manage migrate --run-syncdb
patchman-manage createsuperuser
patchman-manage collectstatic
N.B. To run patchman-manage when installing from source, run ./manage.py
- Restart the web server after syncing the database.
- If installing from source, enable mod-wsgi and copy the apache conf file:
a2enmod wsgi
cp /srv/patchman/etc/patchman/apache.conf.example /etc/apache2/conf-available/patchman.conf
a2enconf patchman
- Edit the networks allowed to report to apache and reload apache.
vi /etc/apache2/conf-available/patchman.conf
service apache2 reload
- If installing from source, allow apache access to the settings and to the sqlite db:
chown -R :www-data /etc/patchman
chmod -R g+r /etc/patchman
chown -R :www-data /var/lib/patchman
chmod -R g+w /var/lib/patchman/db
The django interface should be available at http://127.0.0.1/patchman/
A daily cronjob on the patchman server should be run to process reports, perform database maintenance, check for upstream updates, and find updates for clients.
patchman -a
patchman-client
Install Celery for realtime processing of reports from clients:
apt -y install python-celery python-celery-common rabbitmq-server
C_FORCE_ROOT=1 celery worker --loglevel=info -E -A patchman
yum -y install python-celery rabbitmq-server
systemctl restart rabbitmq-server
semanage port -a -t http_port_t -p tcp 5672
C_FORCE_ROOT=1 celery worker --loglevel=info -E -A patchman
Add the last command to an initscript (e.g. /etc/rc.local) to make celery persistent over reboot.
Memcached can optionally be run to reduce the load on the server.
apt -y install memcached python-memcache # (debian/ubuntu)
yum -y install memcached python-memcached # (centos/rhel)
systemctl restart memcached
and add the following to /etc/patchman/local_settings.py
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
To test the installation, run the client locally on the patchman server:
patchman-client -s http://127.0.0.1/patchman/