Skip to content

Commit 2539ab1

Browse files
committed
update installation instructions
1 parent d01f0eb commit 2539ab1

File tree

2 files changed

+131
-66
lines changed

2 files changed

+131
-66
lines changed

INSTALL.md

+130-65
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ The default installation uses sqlite3 for the django database. To configure
44
mysql or postgresql instead, see the database configuration section.
55

66

7-
## Supported Install Options
8-
- [Ubuntu 22.04](#ubuntu-2204-jammy)
7+
## Supported Server Installation Options
8+
- [Ubuntu 24.04](#ubuntu-2404-noble)
99
- [Debian 12](#debian-12-bookworm)
10-
- [CentOS 9](#centos-9)
10+
- [Rocky 10](#rocky-10)
1111
- [virtualenv + pip](#virtualenv--pip)
1212
- [Source](#source)
1313

1414

15-
### Ubuntu 22.04 (jammy)
15+
### Ubuntu 24.04 (noble)
1616

1717
```shell
1818
curl -sS https://repo.openbytes.ie/openbytes.gpg > /usr/share/keyrings/openbytes.gpg
19-
echo "deb [signed-by=/usr/share/keyrings/openbytes.gpg] https://repo.openbytes.ie/patchman/ubuntu jammy main" > /etc/apt/sources.list.d/patchman.list
19+
echo "deb [signed-by=/usr/share/keyrings/openbytes.gpg] https://repo.openbytes.ie/patchman/ubuntu noble main" > /etc/apt/sources.list.d/patchman.list
2020
apt update
2121
apt -y install python3-patchman patchman-client
2222
patchman-manage createsuperuser
@@ -27,21 +27,23 @@ patchman-manage createsuperuser
2727
```shell
2828
curl -sS https://repo.openbytes.ie/openbytes.gpg > /usr/share/keyrings/openbytes.gpg
2929
echo "deb [signed-by=/usr/share/keyrings/openbytes.gpg] https://repo.openbytes.ie/patchman/debian bookworm main" > /etc/apt/sources.list.d/patchman.list
30+
echo "deb http://deb.debian.org/debian bookworm-backports main" > /etc/apt/sources.list.d/backports.list
3031
apt update
32+
apt -y install -t bookworm-backports python3-django
3133
apt -y install python3-patchman patchman-client
3234
patchman-manage createsuperuser
3335
```
3436

35-
### CentOS 9
37+
### Rocky 10
3638

37-
This also applies to Rocky/Alma/RHEL
39+
This also applies to Alma, RHEL, etc.
3840

3941
```shell
4042
curl -sS https://repo.openbytes.ie/openbytes.gpg > /etc/pki/rpm-gpg/RPM-GPG-KEY-openbytes
4143
cat <<EOF >> /etc/yum.repos.d/openbytes.repo
4244
[openbytes]
4345
name=openbytes
44-
baseurl=https://repo.openbytes.ie/patchman/el9
46+
baseurl=https://repo.openbytes.ie/patchman/el10
4547
enabled=1
4648
gpgcheck=1
4749
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-openbytes
@@ -60,7 +62,7 @@ TBD - not working yet
6062

6163
```shell
6264
apt -y install gcc libxml2-dev libxslt1-dev virtualenv python3-dev zlib1g-dev # (debian/ubuntu)
63-
dnf -y install gcc libxml2-devel libxslt-devel python3-virtualenv # (centos/rocky/alma)
65+
dnf -y install gcc libxml2-devel libxslt-devel python3-virtualenv # (rocky/alma/redhat)
6466
mkdir /srv/patchman
6567
cd /srv/patchman
6668
python3 -m venv .venv
@@ -74,7 +76,7 @@ gunicorn patchman.wsgi -b 0.0.0.0:80
7476

7577
### Source
7678

77-
#### Ubuntu 22.04 (jammy)
79+
#### Ubuntu 24.04 (noble)
7880

7981
1. Install dependencies
8082

@@ -107,9 +109,9 @@ cp /srv/patchman/etc/patchman/local_settings.py /etc/patchman/
107109

108110
# Configuration
109111

110-
## Patchman Settings
112+
## Patchman Server Settings
111113

112-
Modify `/etc/patchman/local_settings.py` to configure patchman.
114+
Modify `/etc/patchman/local_settings.py` to configure the patchman server.
113115

114116
If installing from source or using virtualenv, the following settings should
115117
be configured:
@@ -119,28 +121,32 @@ be configured:
119121
* STATIC_ROOT - should point to `/srv/patchman/run/static` if installing from
120122
source
121123

122-
## Patchman-client Settings
124+
The default settings for errata downloading may include operating systems that
125+
are not relevant to a given deployment. If this is the case, modify the
126+
`ERRATA_OS_UPDATES` setting in `/etc/patchman/local_settings.py`. Further
127+
distribution-specific settings are also available to only download errata
128+
for specific versions/codenames.
123129

124-
The client comes with a default configuration. This configuration will attempt to upload the reports to a server at *patchman.example.com*. This configuration needs to be updated to connect to your own patchman installation.
130+
## Patchman Client Settings
125131

126-
In `/etc/patchman/patchman-client.conf`, look for the following line(s):
132+
The client comes with a default configuration that will attempt to upload the
133+
reports to a server at *patchman.example.com*. This configuration needs to be
134+
updated to connect to the correct patchman server.
135+
136+
Change the following lines in `/etc/patchman/patchman-client.conf`:
127137

128138
```
129139
# Patchman server
130-
server=https://patchman.example.com
140+
server=https://patchman.example.com
131141
132142
# Options to curl
133143
curl_options="--insecure --connect-timeout 60 --max-time 300"
134144
135-
...
136145
```
137-
* *server* needs to point the URL where your patchman server
138-
is running
139-
* *--insecure* in the curl_options tells the client to ignore certificates, if you set them up correctly and are using patchman with "https:/...", you could remove this flag to increase security
140-
141-
142-
143-
146+
* *server* needs to point the URL where the local patchman server is running
147+
* *--insecure* in the curl options tells the client to ignore certificates.
148+
If the patchman server is set up correctly with certificates this flag can
149+
be removed to increase security.
144150

145151
## Configure Database
146152

@@ -151,10 +157,13 @@ production deployments. MySQL or PostgreSQL are better choices.
151157

152158
To configure the sqlite database backend:
153159

154-
1. Create the database directory specified in the settings file:
160+
1. Create the database directory specified in the settings file, touch the
161+
database file and set the journal mode to WAL:
155162

156163
```shell
157164
mkdir -p /var/lib/patchman/db
165+
touch /var/lib/patchman/db/patchman.db
166+
sqlite3 /var/lib/patchman/db/patchman.db 'PRAGMA journal_mode=WAL;'
158167
```
159168

160169
2. Modify `/etc/patchman/local_settings.py` as follows:
@@ -163,7 +172,7 @@ mkdir -p /var/lib/patchman/db
163172
DATABASES = {
164173
'default': {
165174
'ENGINE': 'django.db.backends.sqlite3',
166-
'NAME': '/var/lib/patchman/db/patchman.db'
175+
'NAME': '/var/lib/patchman/db/patchman.db',
167176
}
168177
}
169178
```
@@ -199,16 +208,16 @@ Query OK, 0 rows affected (0.00 sec)
199208

200209
```
201210
DATABASES = {
202-
'default': {
203-
'ENGINE': 'django.db.backends.mysql',
204-
'NAME': 'patchman',
205-
'USER': 'patchman',
206-
'PASSWORD': 'changeme',
207-
'HOST': '',
208-
'PORT': '',
209-
'STORAGE_ENGINE': 'INNODB',
210-
'CHARSET' : 'utf8'
211-
}
211+
'default': {
212+
'ENGINE': 'django.db.backends.mysql',
213+
'NAME': 'patchman',
214+
'USER': 'patchman',
215+
'PASSWORD': 'changeme',
216+
'HOST': '',
217+
'PORT': '',
218+
'STORAGE_ENGINE': 'INNODB',
219+
'CHARSET': 'utf8',
220+
}
212221
}
213222
```
214223

@@ -250,15 +259,15 @@ GRANT
250259

251260
```
252261
DATABASES = {
253-
'default': {
254-
'ENGINE': 'django.db.backends.postgresql_psycopg2',
255-
'NAME': 'patchman',
256-
'USER': 'patchman',
257-
'PASSWORD': 'changeme',
258-
'HOST': '127.0.0.1',
259-
'PORT': '',
260-
'CHARSET' : 'utf8'
261-
}
262+
'default': {
263+
'ENGINE': 'django.db.backends.postgresql_psycopg2',
264+
'NAME': 'patchman',
265+
'USER': 'patchman',
266+
'PASSWORD': 'changeme',
267+
'HOST': '127.0.0.1',
268+
'PORT': '',
269+
'CHARSET': 'utf8',
270+
}
262271
}
263272
```
264273

@@ -273,8 +282,7 @@ After configuring a database backend, the django database should be synced:
273282
collect static files:
274283

275284
```shell
276-
patchman-manage makemigrations
277-
patchman-manage migrate --run-syncdb --fake-initial
285+
patchman-manage migrate --run-syncdb
278286
patchman-manage createsuperuser
279287
patchman-manage collectstatic
280288
```
@@ -285,6 +293,27 @@ N.B. To run patchman-manage when installing from source, run `./manage.py`
285293
2. Restart the web server after syncing the database.
286294

287295

296+
### Migrate from sqlite to another database backend
297+
298+
The prebuilt package installations use sqlite as the default database backend,
299+
but this is not recommended in production. To migrate from sqlite to another
300+
database backend, use the following procedure:
301+
302+
1. Dump the sqlite database to a json file
303+
304+
```shell
305+
patchman-manage dumpdata --exclude packages.Packagestring -e contenttypes -e auth.Permission --natural-foreign --natural-primary --indent 4 > patchman-db.json
306+
```
307+
308+
2. Create the new database and add the new database settings to `/etc/patchman/local_settings.py`
309+
310+
3. Sync the new database and load the existing data:
311+
312+
```
313+
patchman-manage migrate --run-syncdb
314+
patchman-manage loaddata patchman-db.json
315+
```
316+
288317
## Configure Web Server
289318

290319
### Apache
@@ -301,7 +330,7 @@ a2enconf patchman
301330

302331
```shell
303332
vi /etc/apache2/conf-available/patchman.conf
304-
service apache2 reload
333+
systemctl reload apache2
305334
```
306335

307336
3. If installing from source, allow apache access to the settings and to the sqlite db:
@@ -321,9 +350,10 @@ The django interface should be available at http://127.0.0.1/patchman/
321350

322351
#### Daily cronjob on patchman server
323352

324-
A daily cronjob on the patchman server should be run to process reports,
325-
perform database maintenance, check for upstream updates, and find updates for
326-
clients.
353+
A daily cronjob on the patchman server can be run to process reports, perform
354+
database maintenance, check for upstream updates, and find updates for clients.
355+
Alternatively, run celery as outlined below for finer granularity over the
356+
timing of these tasks and for increased concurrency.
327357

328358
```
329359
patchman -a
@@ -337,16 +367,17 @@ patchman-client
337367

338368
### Celery
339369

340-
Install Celery for realtime processing of reports from clients:
370+
Install Celery for realtime processing of reports from clients and for periodic
371+
maintenance tasks. The celery configuation file is in `/etc/patchman/celery.conf`
341372

342373
#### Ubuntu / Debian
343374

344375
```shell
345376
apt -y install python3-celery redis python3-redis python-celery-common
346-
C_FORCE_ROOT=1 celery -b redis://127.0.0.1:6379/0 -A patchman worker -l INFO -E
377+
/usr/bin/celery --broker redis://127.0.0.1:6379/0 --app patchman worker --loglevel info --beat --scheduler django_celery_beat.schedulers:DatabaseScheduler --task-events --pool threads
347378
```
348379

349-
#### CentOS / Rocky / Alma
380+
#### Rocky / Alma / RHEL
350381

351382
Currently waiting on https://bugzilla.redhat.com/show_bug.cgi?id=2032543
352383

@@ -355,35 +386,69 @@ dnf -y install python3-celery redis python3-redis
355386
systemctl restart redis
356387
semanage port -a -t http_port_t -p tcp 6379
357388
setsebool -P httpd_can_network_connect 1
358-
C_FORCE_ROOT=1 celery -b redis://127.0.0.1:6379/0 -A patchman worker -l INFO -E
389+
/usr/bin/celery --broker redis://127.0.0.1:6379/0 --app patchman worker --loglevel info --beat --scheduler django_celery_beat.schedulers:DatabaseScheduler --task-events --pool threads
390+
```
391+
392+
#### Persistence
393+
394+
There is a systemd unit file for celery to make the service persistent over reboot:
395+
396+
`etc/systemd/system/patchman-celery.service`
397+
398+
If installing from prebuilt packages, this should be enabled by default.
399+
400+
401+
### Caching
402+
403+
Memcached or Redis can optionally be run to reduce the load on the server.
404+
Note that caching may result in the web interface showing results that are
405+
out of date with the database, so this is disabled by default.
406+
407+
408+
#### Redis
409+
410+
Install Redis:
411+
412+
```shell
413+
apt -y install redis python3-redis # (debian/ubuntu)
414+
dnf -y install redis python3-redis # (rocky/alma/redhat)
415+
systemctl restart redis/redis-server
359416
```
360417

361-
Add the last command to an initscript (e.g. /etc/rc.local) to make celery
362-
persistent over reboot.
418+
and add the following to `/etc/patchman/local_settings.py`
363419

364-
Enable celery by adding `USE_ASYNC_PROCESSING = True` to `/etc/patchman/local_settings.py`
420+
```
421+
CACHES = {
422+
'default': {
423+
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
424+
'LOCATION': 'redis://127.0.0.1:6379',
425+
'TIMEOUT': 30,
426+
}
427+
}
428+
```
365429

366-
### Memcached
430+
#### Memcacached
367431

368-
Memcached can optionally be run to reduce the load on the server.
432+
Install Memcached
369433

370434
```shell
371435
apt -y install memcached python3-pymemcache # (debian/ubuntu)
372-
dnf -y install memcached python3-pymemcache # (centos/rocky/alma)
436+
dnf -y install memcached python3-pymemcache # (rocky/alma/redhat)
373437
systemctl restart memcached
374438
```
375439

376440
and add the following to `/etc/patchman/local_settings.py`
377441

378442
```
379443
CACHES = {
380-
'default': {
381-
'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
382-
'LOCATION': '127.0.0.1:11211',
444+
'default': {
445+
'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
446+
'LOCATION': '127.0.0.1:11211',
447+
'TIMEOUT': 30,
383448
'OPTIONS': {
384449
'ignore_exc': True,
385450
},
386-
}
451+
}
387452
}
388453
```
389454

etc/patchman/local_settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
DATABASES = {
1010
'default': {
11-
# 'ENGINE': 'django.db.backends.sqlite3', # noqa disabled until django 5.1 is in use, see https://blog.pecar.me/django-sqlite-dblock
11+
# 'ENGINE': 'django.db.backends.sqlite3', # noqa - disabled until django 5.1 is in use, see https://blog.pecar.me/django-sqlite-dblock
1212
'ENGINE': 'patchman.sqlite3',
1313
'NAME': '/var/lib/patchman/db/patchman.db',
1414
'OPTIONS': {

0 commit comments

Comments
 (0)