add wordpress role with lots of bells and whistles

This commit is contained in:
uumas
2022-11-25 18:58:20 +02:00
parent 9001420597
commit c74a56a2e2
7 changed files with 86 additions and 0 deletions

View File

@@ -7,3 +7,6 @@ To add a new role:
1. usually meta/main.yml with depend on container 1. usually meta/main.yml with depend on container
1. README.md 1. README.md
1. Add docs to docs/ 1. Add docs to docs/
The following roles have default versions which should probably be overridden:
- wordpress: `wordpress_tag`

21
docs/wordpress.md Normal file
View File

@@ -0,0 +1,21 @@
# Required variables
These variables are required. Example values included.
```
ports:
wordpress_http: 8080
docker_vhost_domains:
wordpress:
- wordpress.domain.tld
database_passwords:
wordpress: secret
```
# Optional variables
These variables have default values listed below
```
wordpress_tag: php8.1
```

View File

@@ -0,0 +1 @@
Installs wordpress in docker and configures cron

View File

@@ -0,0 +1,14 @@
---
wordpress_tag: php8.1
dockerfile: {}
docker_additional_services: []
docker_host_user: false
wordpress_symlinks: false
wordpress_docker_volumes:
- name: html
path: /var/www/html

View File

@@ -0,0 +1,35 @@
---
- name: Add memcached php extension to container
set_fact:
dockerfile: "{{ dockerfile | combine({'run': ['apt-get update && apt-get install -y libmemcached-dev zlib1g-dev && pecl install memcached-3.2.0 && docker-php-ext-enable memcached']}, list_merge='append') }}"
when: "'memcached' in docker_additional_services"
- name: Add pdo_mysql php extension to container
set_fact:
dockerfile: "{{ dockerfile | combine({'run': ['docker-php-ext-install -j$(nproc) pdo_mysql']}, list_merge='append') }}"
when: "'pdo_mysql' in wordpress_php_extensions"
- name: Include additional volume vars
include_vars: "{{ item }}_volume.yml"
loop: "{{ wordpress_additional_volumes | default([]) }}"
- name: Wordpress container setup
include_role:
name: container
vars:
docker_service: wordpress
docker_image: wordpress:{{ wordpress_tag }}
docker_image_http_port: 80
docker_database: mariadb
docker_volumes: "{{ wordpress_docker_volumes + wordpress_www_volume + wordpress_log_volume }}"
docker_volume_type: bind
docker_env:
WORDPRESS_DB_HOST: "{{ docker_service_name }}_db"
WORDPRESS_DB_NAME: "{{ docker_service_name }}"
WORDPRESS_DB_USER: "{{ docker_service_name }}"
WORDPRESS_DB_PASSWORD: "{{ database_passwords[docker_service_name] }}"
WORDPRESS_CONFIG_EXTRA: |
define('WP_SITEURL', 'https://{{ docker_vhost_domains[docker_service_name][0] }}');
define('WP_HOME', 'https://{{ docker_vhost_domains[docker_service_name][0] }}');

View File

@@ -0,0 +1,6 @@
---
wordpress_log_volume:
- name: logs
path: /var/log/apache2

View File

@@ -0,0 +1,6 @@
---
wordpress_www_volume:
- name: www
path: /var/www