WordPress Ansible Role https://wordpress.com/
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Conrad 0f5a90ebe2
All checks were successful
Lint + Tag / format (push) Successful in 57s
Lint + Tag / tag (push) Successful in 56s
feat: moved to forgejo pipeline
2026-10-13 13:03:54 +07:00
.forgejo/workflows feat: moved to forgejo pipeline 2026-10-13 13:03:54 +07:00
defaults feat: basic wordpress deployment 2026-09-08 00:26:39 +02:00
files feat: basic wordpress deployment 2026-09-08 00:26:39 +02:00
handlers feat: basic wordpress deployment 2026-09-08 00:26:39 +02:00
meta feat: basic wordpress deployment 2026-09-08 00:26:39 +02:00
tasks feat: basic wordpress deployment 2026-09-08 00:26:39 +02:00
templates feat: basic wordpress deployment 2026-09-08 00:26:39 +02:00
.gitignore feat: basic wordpress deployment 2026-09-08 00:26:39 +02:00
CHANGELOG.md feat: moved to forgejo pipeline 2026-10-13 13:03:54 +07:00
LICENSE feat: basic wordpress deployment 2026-09-08 00:26:39 +02:00
README.md Prettified Code! 2026-09-07 22:27:45 +00:00

WordPress

Deploys WordPress via Docker Compose, backed by MySQL, with optional Traefik integration for HTTPS termination and reverse-proxy routing.

Requirements

  • Docker
  • community.docker Ansible 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_EXTRA sets $_SERVER['HTTPS'] = 'on' whenever it sees X-Forwarded-Proto: https, so WordPress generates correct https:// URLs when sitting behind Traefik.
  • Data ownership. wordpress_data_path/db is owned 999:999 (the MySQL image's user) and wordpress_data_path/wp is owned 33:33 (www-data, the WordPress image's user).
  • Health-gated startup. db has a healthcheck (mysqladmin ping), and wordpress won't start until it reports healthy, avoiding a race where WordPress boots before MySQL is ready to accept connections.
  • uploads.ini changes 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 the wordpress container whenever the rendered file changes.
  • Containers are not proxied by Traefik unless wordpress_domain is set — it must already have a traefik_web network and a matching certresolver (see the traefik role).