Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
# 3.9 and 3.11 run the older fail2ban releases verify_ops_configs checks;
# the last one listed is the default `python`.
python-version: |
3.9
3.11
3.12

- name: Install project (with dev deps)
run: python -m pip install --upgrade pip && pip install -e ".[dev]"
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ All notable changes to this project are documented here. The format is based on

### Fixed

- **fail2ban web and Odoo bans never applied on Ubuntu 22.04 and Debian 11.** fail2ban 0.11.2 split the
`Nginx Full` profile name, and ufw refused it. They now use the tool's own `ufw-odoo-web` action (ports 80
and 443), checked on fail2ban 0.11.2, 1.0.2 and 1.1.0.
- **The fail2ban base setup was rolled back on Debian 12.** The `backend` set for every jail sent `sshd` to an
`auth.log` that does not exist; `sshd` now reads the journal there.
- **Let's Encrypt and "leave certificates untouched"** pointed the vhost at files that may not exist, and a
certbot-managed vhost was swapped back to self-signed. Both now name the files that are there. A missing
certificate or a cancelled file pick writes no HTTPS vhost.
- **Update configuration** now checks the new values before writing anything. With a new password for a remote
role it no longer restarts the service before that role has the password.
- **Safer configuration changes.**
- Staged writes of fail2ban, logrotate and nginx configuration can no longer leave half a configuration after
a failed write or an interruption.
- Enabling UFW allows SSH first, and deleting the SSH rule asks first.
- Durations, networks and the logrotate size are validated, and "Test the Odoo regex" no longer writes the
filter.

- **Installs that failed on supported hosts.**
- **Python.** Odoo 15 on Debian 12 (Python 3.11) and Odoo 14 on a host Python 3.10 hit the `gevent==21.8.0` pin,
which has no wheel there and no longer builds; they now get uv's interpreter.
Expand Down
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ check and hand-over commands, and has Odoo itself try to send a mail from the co

`tools/verify_ops_configs.py` downloads the distribution's nginx package (`apt-get download`, extracted, never
installed) and fail2ban's source release, then runs `nginx -t`, `fail2ban-regex` and `fail2ban-client -t` on the
generated vhosts, filter and jails, including their rollbacks. Run it after changing those planners.
generated vhosts, filter and jails, including their rollbacks. It runs fail2ban 1.1.0, 1.0.2 and 0.11.2 (the
older two on a Python 3.11/3.10 and 3.9/3.8 found on PATH or through uv, converted with lib2to3 as the
distributions do), and has each ban a stub ufw. It also runs the staged writes' failure modes and logrotate's
rollback. Run it after changing those planners.

CI (`.github/workflows/ci.yml`) runs ruff, pytest, a byte-compile, `openspec validate`, and the eunomai
`docs-check` / `provenance-check` gates on every push and PR to `main`.
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ For HTTPS you pick a certificate strategy:

| Strategy | Behavior |
|----------|----------|
| **Leave certificates untouched** | Adds no certificate commands. |
| **Leave certificates untouched** | Adds no certificate commands; the vhost names the certificate the current vhost names (certbot's included), else the tool's own. HTTPS is not configured when those files are missing. |
| **Self-signed** | Reuses an existing key/fullchain or generates a 2048-bit self-signed cert for the domain. |
| **Let's Encrypt (managed externally)** | Adds no certificate commands — you manage LE outside the tool. |
| **Let's Encrypt (managed externally)** | Adds no certificate commands; the vhost names `/etc/letsencrypt/live/<domain>/fullchain.pem` and `privkey.pem`, which must exist — obtain the certificate first. |
| **Copy your own certificates** | Copies your CRT/KEY (+ optional intermediate) beside the live files, builds the fullchain, and **checks that the key matches the certificate** before they replace the current ones (kept as `.previous`); a wrong file never reaches Nginx. |

## The instance name must be free
Expand Down
5 changes: 4 additions & 1 deletion docs/operations/instance-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ Rewrites the instance's `odoo.conf` and systemd unit with new values, and option
- **Nothing is reinstalled** — no apt, clone or pip run — so the venv's pinned setuptools stays as it is.
- The Odoo version is read from the instance's checkout and the domain from its vhost.
- Passwords are kept unless you choose to set new ones; a new DB password is also set on the local role.
- A running service is **restarted**, so the change is live when the plan ends. Autostart is left as it was.
- A new DB password is set on the local role first; then the login is checked with the new values, and only
then are the files written — a typo leaves the running configuration as it was.
- A running service is **restarted**, so the change is live when the plan ends. Autostart is left as it was. With
a new password for a **remote** role the service is not restarted: set the password there, then restart it.

To go back, copy the files from the `config_preupdate/<timestamp>` directory and restart the service.

Expand Down
4 changes: 2 additions & 2 deletions docs/operations/log-rotation.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ policy for an instance's Odoo log (`/var/log/odoo/<instance>.log`).

The policy uses **`copytruncate`**, so Odoo keeps writing to the same file and does **not** need a restart.
`/var/log/odoo` belongs to root and each instance owns only its own log, so root rotates it with no `su`
directive. The plan installs `logrotate` if missing and validates the file with `logrotate -d` before
finishing.
directive. The plan installs `logrotate` if missing and keeps the policy only if `logrotate -d` accepts it; the
previous one is put back otherwise. The size threshold takes a number with `k`, `M` or `G`.

Log rotation is also offered **at install time** (recommended, default yes), so a fresh instance starts with a
rotation policy in place.
Expand Down
13 changes: 9 additions & 4 deletions docs/security/firewall.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ Applies a secure baseline:

- **Allow a port** — `ufw allow <port>/<tcp|udp>`.
- **Delete a rule (by number)** — lists the numbered rules and deletes one only if that number still shows the
same rule when the plan runs: fail2ban adds its bans at the top of the list, which shifts the numbers.
- **Enable / Disable UFW**.
same rule when the plan runs: fail2ban adds its bans at the top of the list, which shifts the numbers. A rule
that lets SSH in (its port, or the `OpenSSH` profile) is deleted only after you confirm the risk.
- **Enable / Disable UFW** — enabling allows the ports SSH listens on first; when none is detected, you confirm
before it goes up.

The PostgreSQL rule takes one address (the app server's), never a network or `any`.

## Relationship with Fail2ban

[Fail2ban](security-fail2ban.md) is configured with `banaction = ufw`, so its bans only take effect when UFW
is installed and active — this menu is how you make that true.
[Fail2ban](security-fail2ban.md) bans through UFW (`ufw` for SSH and recidive, the tool's `ufw-odoo-web` for
the web ports), so its bans only take effect when UFW is installed and active — this menu is how you make that
true.

## Related

Expand Down
14 changes: 11 additions & 3 deletions docs/security/security-fail2ban.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ reloaded, and the plan waits for the socket.
```mermaid
flowchart LR
ssh["sshd · recidive"] --> all(["all ports<br/>of that address"])
web["nginx-http-auth · nginx-botsearch<br/>odoo-auth (per instance)"] --> webports(["web ports only<br/>ufw profile Nginx Full"])
web["nginx-http-auth · nginx-botsearch<br/>odoo-auth (per instance)"] --> webports(["ports 80 and 443 only<br/>action ufw-odoo-web"])
ignore[("ignore list<br/>loopback + your admin networks")] -.-> never["never banned"]
classDef step fill:#dbeafe,stroke:#2563eb,color:#1e3a8a
classDef guard fill:#dcfce7,stroke:#16a34a,color:#14532d
Expand All @@ -42,8 +42,16 @@ flowchart LR
class ignore data
```

A failed Odoo or web login therefore never blocks SSH. The `Nginx Full` profile comes with the nginx package;
without it, fail2ban's ufw action blocks every port.
A failed Odoo or web login therefore never blocks SSH. The web bans use the tool's own `ufw-odoo-web` action
(`/etc/fail2ban/action.d/ufw-odoo-web.conf`), which rejects the address on ports 80 and 443. fail2ban's own
`ufw[application="Nginx Full"]` is not used. On fail2ban 0.11.2 (Ubuntu 22.04, Debian 11) it passes the profile
name unquoted, so ufw refuses every ban. On 1.0 and later it bans every port when the profile is missing.

The base jails set `backend` per jail, never for all of them. Where `/var/log/auth.log` does not exist (Debian 12,
or a host without rsyslog), `sshd` reads the journal, and the plan installs `python3-systemd` for it. Durations
use fail2ban's units (`10m`, `1h`, `1d`). The ignore list takes addresses or networks and starts with the address
your SSH session comes from. Every write is staged, and a refused configuration, a failed write or an
interruption puts the previous files back.

> **UFW prerequisite:** the ban action is `ufw`, so bans only take effect while **UFW is installed and
> active**. This menu does not install UFW: set it up from **Firewall (UFW)**, which allows SSH before enabling
Expand Down
12 changes: 12 additions & 0 deletions instance_manager/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,4 +990,16 @@ def tf(template: str, *args: object, **kwargs: object) -> str:
'Database manager disabled (list_db = False). Create the first database as the instance user: sudo -u <instance> <home>/venv/bin/python <home>/odoo/odoo-bin -c <odoo.conf> -d <db> -i base --stop-after-init, or re-enable the manager for a while.': 'Gestor de bases de datos desactivado (list_db = False). Crea la primera base de datos como el usuario de la instancia: sudo -u <instancia> <home>/venv/bin/python <home>/odoo/odoo-bin -c <odoo.conf> -d <bd> -i base --stop-after-init, o reactiva el gestor un momento.',
'verify-full checks the server against a CA: place it at {}/.postgresql/root.crt, readable by the instance user, before the install runs.': 'verify-full comprueba el servidor contra una CA: colócala en {}/.postgresql/root.crt, legible por el usuario de la instancia, antes de ejecutar la instalación.',
'The gevent port must differ from the HTTP port.': 'El puerto gevent debe ser distinto del puerto HTTP.',
'Use a duration such as 10m, 1h, 1d or 1w.': 'Usa una duración como 10m, 1h, 1d o 1w.',
'Not an IP address or network: {}': 'No es una dirección ni una red IP: {}',
'Install the journal reader fail2ban needs (python3-systemd)': 'Instalar el lector del journal que necesita fail2ban (python3-systemd)',
'This rule lets SSH in: deleting it can lock you out of the server. Delete it anyway?': 'Esta regla deja entrar por SSH: borrarla puede dejarte fuera del servidor. ¿Borrarla igualmente?',
'Could not detect the SSH port: enabling UFW may lock you out. Enable anyway?': 'No se pudo detectar el puerto SSH: activar UFW puede dejarte fuera. ¿Activarlo igualmente?',
'Write {} and keep it only if logrotate accepts it': 'Escribir {} y conservarlo solo si logrotate lo acepta',
'Use a size such as 500k, 50M or 1G.': 'Usa un tamaño como 500k, 50M o 1G.',
"Test the fail2ban regex (the tool's odoo-auth filter, not installed)": 'Probar la regex de fail2ban (el filtro odoo-auth de la herramienta, sin instalar)',
'Certificate file not found: {}. {}': 'Certificado no encontrado: {}. {}',
'Choose a mode that provides a certificate.': 'Elige un modo que aporte un certificado.',
'Obtain it first (for example: certbot certonly --webroot or --standalone for the domain).': 'Obténlo antes (por ejemplo: certbot certonly --webroot o --standalone para el dominio).',
'The DB is remote: the service is not restarted. Set the same password on its role there, then restart the service.': 'La BD es remota: no se reinicia el servicio. Pon la misma contraseña a su rol allí y luego reinicia el servicio.',
}
6 changes: 6 additions & 0 deletions instance_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ class InstanceConfig:
app_server_ip: str = "127.0.0.1"
odoo_admin_passwd: str = ""

# The certificate and key an HTTPS vhost names when they are not the tool's own
# (Let's Encrypt, or the ones an existing vhost already names). Empty: the files
# under nginx_ssl_dir.
tls_cert: str = ""
tls_key: str = ""

# Production-posture settings (rendered into odoo.conf).
list_db: bool = False
dbfilter: str = ""
Expand Down
Loading
Loading