WordPress Ansible Role
https://wordpress.com/
- Jinja 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| defaults | ||
| files | ||
| handlers | ||
| meta | ||
| tasks | ||
| templates | ||
| .gitignore | ||
| CHANGELOG.md | ||
| LICENSE | ||
| README.md | ||
WordPress
Deploys WordPress via Docker Compose, backed by MySQL, with optional Traefik integration for HTTPS termination and reverse-proxy routing.
Requirements
- Docker
community.dockerAnsible collection (>=5.2.0)
Variables
| Variable | Default | Description |
|---|---|---|
wordpress_instance |
wordpress |
Unique instance name. Used as Compose project name and container names. |
wordpress_data_path |
/data/wordpress |
Host path for persistent data (MySQL data and WordPress files). |
wordpress_docker_path |
/docker/wordpress |
Host path for the Compose file and uploads.ini. |
wordpress_db_version |
8.0 |
MySQL image tag. |
wordpress_wp_version |
6-php8.2-apache |
WordPress image tag. |
wordpress_domain |
~ |
Public domain. When set, enables Traefik routing labels and attaches to the traefik_web network. |
wordpress_traefik_certresolver |
default |
Traefik certificate resolver to use for wordpress_domain. |
wordpress_port |
~ |
When set, exposes WordPress on this host port (maps to container port 80). Omit when using wordpress_domain. |
wordpress_pg_user |
wp_user |
MySQL user (also the database owner). Despite the pg_ prefix, this configures MySQL, not PostgreSQL. |
wordpress_pg_name |
wordpress |
MySQL database name. |
wordpress_db_pass |
~ |
MySQL password for wordpress_pg_user. Required. |
wordpress_db_root_pass |
~ |
MySQL root password. Required. |
wordpress_uninstall |
false |
Stops and removes containers and the compose directory. |
wordpress_purge |
false |
Also removes the data directory (database and uploaded files). Requires wordpress_uninstall: true. Irreversible. |
Usage
Minimal setup:
wordpress_db_pass: "{{ vault_wordpress_db_pass }}"
wordpress_db_root_pass: "{{ vault_wordpress_db_root_pass }}"
wordpress_domain: "blog.example.com"
Without a reverse proxy (direct host port instead of wordpress_domain):
wordpress_port: 8080
Uninstall
To stop and remove all containers and the compose directory:
wordpress_uninstall: true
Add wordpress_purge: true to also delete the database and uploaded files.
Notes
- HTTPS behind a reverse proxy. The container's
WORDPRESS_CONFIG_EXTRAsets$_SERVER['HTTPS'] = 'on'whenever it seesX-Forwarded-Proto: https, so WordPress generates correcthttps://URLs when sitting behind Traefik. - Data ownership.
wordpress_data_path/dbis owned999:999(the MySQL image's user) andwordpress_data_path/wpis owned33:33(www-data, the WordPress image's user). - Health-gated startup.
dbhas a healthcheck (mysqladmin ping), andwordpresswon't start until it reports healthy, avoiding a race where WordPress boots before MySQL is ready to accept connections. uploads.inichanges restart the container. It's a bind-mounted file the compose service definition itself doesn't reference by content, so an edit alone doesn't trigger a recreate — a handler restarts thewordpresscontainer whenever the rendered file changes.- Containers are not proxied by Traefik unless
wordpress_domainis set — it must already have atraefik_webnetwork and a matchingcertresolver(see thetraefikrole).