Compare commits

...

53 Commits

Author SHA1 Message Date
uumas
e51052c34b v0.8.4 2023-04-21 08:21:37 +03:00
uumas
2893a99036 container: build docker image in separate directory 2023-04-21 08:13:01 +03:00
uumas
9ca48d376a container: fix db volume 2023-04-21 08:12:31 +03:00
uumas
079b008111 container: support bind mounted db data directory and mysql config 2023-04-21 07:44:23 +03:00
uumas
20e38332e6 container: reorganize volume directory creation 2023-04-21 05:09:14 +03:00
uumas
f845962ed9 container: use mount instead of volume for db 2023-04-21 04:08:15 +03:00
uumas
165a04fa51 wordpress: add customizable php.ini 2023-04-21 03:24:24 +03:00
uumas
309bd41836 wordpress: move wordpress_docker_volumes to vars as it should generally not be overridden 2023-04-21 03:24:10 +03:00
uumas
64491514a9 v0.8.3 2023-04-18 19:38:57 +03:00
uumas
7504ba96d0 add uisp role 2023-04-18 19:38:43 +03:00
uumas
851504030a container: add proxy target protocol and network mode vars to argspec 2023-04-18 19:37:57 +03:00
uumas
6fb2e23151 container: set TZ variable 2023-04-18 19:37:29 +03:00
uumas
7369fe30db v0.8.2 2023-03-24 21:07:05 +02:00
uumas
db49a87e29 jitsi: Set default reverse_proxy_type 2023-03-24 20:43:41 +02:00
uumas
d53f3b0d7d v0.8.1 2023-03-24 20:05:58 +02:00
uumas
df0005d2f4 Make wordpress role pass container argument spec validation when docker_service_suffix is defined 2023-03-24 20:03:40 +02:00
uumas
472ad4286f Add role readmes 2023-03-24 18:41:26 +02:00
uumas
9103bafb8d v0.8.0 2023-03-24 18:31:44 +02:00
uumas
aa7216d6e2 Add Prometheus role 2023-03-21 01:33:57 +02:00
uumas
c569974ba7 Fix argument specs typo 2023-03-21 01:13:31 +02:00
uumas
d5f2bb84c6 Add Grafana role 2023-03-21 01:13:09 +02:00
uumas
265270eed3 Add DokuWiki role 2023-03-21 00:51:34 +02:00
uumas
93e76562f4 Generalize alpine argument_specs 2023-03-21 00:44:36 +02:00
uumas
0541367cb3 Update container argument_specs, add alpine role as a template 2023-03-21 00:32:01 +02:00
uumas
9d7d11c384 v0.7.2 2023-03-15 03:32:07 +02:00
uumas
70bc3ce15b container: fix ansible check mode when image not present on host 2023-03-15 03:31:24 +02:00
uumas
2b43003564 gitea: fix mailer, add require signin view option 2023-03-15 00:16:57 +02:00
uumas
513392180a wordpress: fix dockerfile default 2023-03-15 00:08:54 +02:00
uumas
a1c23a5f1f jitsi: support muc_census 2023-03-15 00:08:20 +02:00
uumas
202046f442 container: fix traefik support 2023-03-15 00:05:41 +02:00
uumas
13f81e0c3e container: work in check mode 2023-03-15 00:05:24 +02:00
uumas
8a3d588a66 release 0.7.0 2023-02-07 18:29:40 +02:00
uumas
5991385def container: fix legacy docker_volumes compatibility, add missing arguments to argument specs 2023-02-07 18:00:06 +02:00
uumas
5a20226105 set volume types correctly 2023-02-07 16:14:52 +02:00
uumas
df996e5ef7 container: fix specifying docker_networks 2023-02-03 06:50:42 +02:00
uumas
5204ee38c2 container: fix template mounts 2023-02-03 06:50:22 +02:00
uumas
88e32f216a move container docs to arguments specs 2023-02-03 05:26:53 +02:00
uumas
3db21c6a05 container: add argument specs 2023-02-03 05:24:00 +02:00
uumas
9551382693 container: cleanups, fixes 2023-02-03 05:22:57 +02:00
uumas
f45f7d25e0 container: rework bind mount directory permissions, move from volume syntax to mount syntax, add single file template volumes 2023-02-03 05:15:39 +02:00
uumas
3c670d5832 container: run proxy tasks only when proxy will be installed, proxy cleanup 2023-02-03 05:06:58 +02:00
uumas
5a9c982f69 container: always pull image in a separate task before container creation 2023-02-03 05:04:30 +02:00
uumas
4c6363cab0 container: reset variables in role init, define more defaults outside tasks 2023-02-03 05:01:42 +02:00
uumas
a58c5bd47b move vars from defaults to vars 2023-02-03 04:54:38 +02:00
uumas
d77111e2fd split container tasks to multiple files for readability 2023-02-03 04:35:11 +02:00
uumas
d92d72f18f add restart docker handler 2023-02-03 03:16:22 +02:00
uumas
3150bf5c2c Update galaxy.yml, make ansible-lint happier 2022-11-25 20:00:47 +02:00
uumas
c74a56a2e2 add wordpress role with lots of bells and whistles 2022-11-25 18:58:20 +02:00
uumas
9001420597 container: support custom built images, mariadb, bind mounts, custom user 2022-11-25 18:54:56 +02:00
uumas
ab357620f7 update jitsi 2022-10-14 00:28:01 +03:00
uumas
568c40740e add container docs 2022-05-15 00:44:29 +03:00
uumas
166cc09277 jitsi support turn 2022-05-14 00:42:18 +03:00
uumas
11991867c6 unifi docs 2022-05-12 00:52:16 +03:00
59 changed files with 1115 additions and 97 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`

1
docs/container.md Normal file
View File

@@ -0,0 +1 @@
Please see `roles/container/meta/arguments_specs.yml` for all possible variables

View File

@@ -7,3 +7,11 @@ ports:
jitsi_domain: 'jitsi.domain.tld' jitsi_domain: 'jitsi.domain.tld'
``` ```
These vars are optional:
```
# for TURN, no turn server is used if not defined
turn_domain: turn.domain.tld
turn_secret: secret
```

14
docs/unifi.md Normal file
View File

@@ -0,0 +1,14 @@
Unifi is installed with host network mode.
# Required variables
These variables are required. Example values included. Some general variables might also be required for this role.
```
ports:
unifi:
https: 8443
docker_vhost_domains:
unifi:
- unifi.domain.tld
```

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

@@ -2,11 +2,12 @@
namespace: uumas namespace: uumas
name: docker name: docker
version: 0.5.3 description: Roles for installing services in docker containers
version: 0.8.4
readme: README.md readme: README.md
repository: https://git.uumas.fi/uumas/ansible-docker repository: https://git.uumas.fi/uumas/ansible-docker
license_file: LICENSE license_file: LICENSE
dependencies: dependencies:
uumas.general: '>=0.5.0' uumas.general: '>=0.5.5'
authors: authors:
- uumas - uumas

1
roles/alpine/README.md Normal file
View File

@@ -0,0 +1 @@
Sets up an alpine docker container. To be used as a template for other roles.

View File

@@ -0,0 +1,39 @@
---
argument_specs:
main:
short_description: Alpine container
description: "Sets up an alpine docker container. This role can be used as a template for other roles using the container role."
options:
# All options after this will be passed directly to the container role
docker_service_suffix:
description: "Passed to container role"
required: false
docker_host_user:
description: "Passed to container role"
required: false
database_passwords:
description: "Passed to container role"
required: false
docker_additional_services:
description: "Passed to container role"
required: false
docker_volume_type:
description: "Passed to container role"
required: false
reverse_proxy_type:
description: "Passed to container role"
required: false
ports:
description: "Passed to container role"
required: false
docker_vhost_domains:
description: "Passed to container role"
required: false
docker_entrypoint:
description: "Passed to container role"
required: false

View File

@@ -0,0 +1,15 @@
---
- name: Alpine container
import_role:
name: container
vars:
docker_service: alpine
docker_image: alpine
docker_image_http_port: 8080
docker_database: postgres
docker_mounts:
- name: data
path: /data
docker_env:
TZ: "{{ timezone }}"

View File

@@ -1,5 +1,7 @@
--- ---
reverse_proxy_type: caddy docker_host_user: false
docker_additional_env: {} docker_volume_type: named
docker_published_ports: [] docker_mariadb_config: {}
timezone: Etc/UTC

View File

@@ -0,0 +1,149 @@
---
argument_specs:
main:
short_description: Docker container
description: "Sets up a docker container. Supports defining networks, building a custom image, setting up memcached, databases and a reverse proxy, creating a user on the host to run the container as, named volumes, bind mounts (either auto-created or existing)."
options:
docker_service:
description: "The name of the docker service (example: gitea)"
type: str
required: true
docker_service_suffix:
description: "A suffix used to allow running multiple instances of the same service on a host. If docker_service is gitea and docker_service_suffix production, the container will be gitea_production"
type: str
required: false
docker_image:
description: "Docker image to use for the container. If dockerfile is defined, it will be used as base for locally built image (example: gitea/gitea:latest)"
type: str
required: true
docker_host_user:
description: "If true, creates a user on the host for this service. The container will run as this user's uid/gid. Bind mount volumes will be owned by this user."
type: bool
required: false
default: true
docker_database:
description: "Database type to set up. It will be run in a docker container accessible to the service at host <service name (with _suffix if suffix is defined)>_db on default port."
type: str
required: false
choices:
- postgres
- mariadb
- mongo
- none
default: none
database_passwords:
description: "database_passwords[docker_service] is a string with the password used for communication between the service and database. Required if docker_database is postgres or mariadb"
type: dict
required: false
docker_mariadb_config:
description: |
A dict specifying config for mariadb. For example
mysqld:
innodb_buffer_pool_size: '4G'
aria_pagecache_buffer_size': '4G'
would set
[mysqld]
innodb_buffer_pool_size = 4G
aria_pagecache_buffer_size = 4G
type: dict
required: false
default: {}
docker_additional_services:
description: "List of additional services to configure (in separate containers). These will be accessible with hostname <docker_service_name>[_suffix]_<additional_service>"
type: list
required: false
elements: str
choices:
- memcached
default: []
docker_volume_type:
description: "Defines whether to use named volumes or bind mounts for mounts with name"
type: str
required: false
choices:
- named
- bind
default: named
docker_volumes:
description: "DEPRECATED List of docker volumes to mount inside the container. Use docker_mounts instead. DEPRECATED"
type: list
required: false
default: []
elements: str
docker_mounts:
description: "List of bind mounts or volumes to be mounted inside the container. Each element is a dict with path and exactly one of name, src or template"
type: list
required: false
default: []
elements: dict
options:
path:
description: "The path inside the container to mount at"
type: str
required: true
name:
description: "If docker_volume_type is named, the name of the named volume to be mounted at path. If docker_volume_type is bind, the name of the folder to create under /opt/<service>[/suffix]/mounts/ and mount at path."
type: str
required: false
src:
description: "Host path to bind mount inside the container."
type: str
required: false
template:
description: "Name of template without .j2 extension. Will be templated at /opt/<service>[/suffix]/mounts/<template> and mounted inside the container."
type: str
required: false
reverse_proxy_type:
description: "Defines which kind of reverse proxy to configure for the container. Traefik support is experimental."
type: str
required: false
choices:
- caddy
- traefik
- none
default: caddy
docker_image_http_port:
description: "The port for http listener inside the container. Will be mapped to the host port defined in ports. Required if reverse_proxy_type is not none."
type: int
required: false
docker_proxy_target_protocol:
description: "Protocol to use for proxy connection"
type: str
required: false
choices:
- http
- https
default: http
ports:
description: "ports[docker_service]['http'] or ports[docker_service]['https'] defines the port on which the container will listen on for reverse proxy connections. Required if reverse_proxy_type is caddy."
type: dict
docker_vhost_domains:
description: "docker_vhost_domains[docker_service] is a list which defines which domains should be proxied to the container. Required if reverse_proxy_type is not none"
type: dict
docker_published_ports:
description: "A list of published ports in docker format (<host listen address>:<host port>:<container port>)"
type: list
required: false
default: []
docker_env:
description: "A dict of environment variables for the container"
type: dict
required: false
default: {}
docker_entrypoint:
description: "Docker entrypoint as list of command and arguments"
type: list
required: false
elements: str
docker_network_mode:
description: "Docker container network mode"
type: str
required: false
timezone:
description: "Timezone set in the TZ env var"
type: str
required: false
default: Etc/UTC

View File

@@ -1,10 +1,4 @@
--- ---
dependencies: dependencies:
- docker - role: docker
- role: uumas.general.reverse_proxy
vhost_id: "{{ docker_service }}"
vhost_domains: "{{ docker_vhost_domains[docker_service] }}"
proxy_target_protocol: "{{ docker_proxy_target_protocol | default('http') }}"
proxy_target_port: "{{ ports[docker_service][proxy_target_protocol] }}"
when: reverse_proxy_type != 'none' and reverse_proxy_type != 'traefik'

View File

@@ -0,0 +1,79 @@
---
- name: Set postgres container vars
set_fact:
db_container_image: 'postgres:14-alpine'
db_container_env:
POSTGRES_USER: "{{ docker_service_name }}"
POSTGRES_PASSWORD: "{{ database_passwords[docker_service_name] }}"
db_container_data: /var/lib/postgresql/data
when: docker_database == 'postgres'
- name: Set mariadb container vars
set_fact:
db_container_image: mariadb:10
db_container_env:
MARIADB_USER: "{{ docker_service_name }}"
MARIADB_DATABASE: "{{ docker_service_name }}"
MARIADB_PASSWORD: "{{ database_passwords[docker_service_name] }}"
MARIADB_RANDOM_ROOT_PASSWORD: "{{ database_passwords[docker_service_name + '_root'] is not defined | string }}"
MARIADB_ROOT_PASSOWRD: "{{ database_passwords[docker_service_name + '_root'] | default(omit) }}"
db_container_data: /var/lib/mysql
db_image_port: 3306
when: docker_database == 'mariadb'
- name: Set mongo container vars
set_fact:
db_container_image: 'mongo:latest'
db_container_data: /data/db
when: docker_database == 'mongo'
- name: Reset db container mount definition var
set_fact:
db_container_mount_definition: []
- name: Set up database container data bind mount
when: docker_volume_type == 'bind'
block:
- name: Create db data bind mount directory for {{ docker_service_name }}
file:
path: "{{ docker_mounts_dir }}/db"
state: directory
- name: Set db_container_mount_definition for db data bind mount
set_fact:
db_container_mount_definition: "{{ db_container_mount_definition + [{'source': docker_mounts_dir + '/db', 'target': db_container_data, 'type': 'bind'}] }}"
- name: Set up database container config bind mount
when: db_config_mounts_needed
block:
- name: Put mariadb config in place
template:
src: mariadb.cnf.j2
dest: "{{ docker_mounts_dir }}/mariadb.cnf"
- name: Set db_container_mount_definition for db config bind mount
set_fact:
db_container_mount_definition: "{{ db_container_mount_definition + [{'source': docker_mounts_dir + '/mariadb.cnf', 'target': '/etc/mysql/conf.d/custom.cnf', 'type': 'bind', 'read_only': true}] }}"
- name: Set db_container_mount_definition for db data named volume
set_fact:
db_container_mount_definition: "{{ db_container_mount_definition + [{'source': docker_service_name + '_db', 'target': db_container_data, 'type': 'volume'}] }}"
when: docker_volume_type == 'named'
- name: Set db published ports var
set_fact:
db_published_ports: ["127.0.0.1:{{ ports[docker_service_name].db }}:{{ db_image_port }}"]
when: ports[docker_service_name].db is defined
- name: Database container for {{ docker_service_name + ' (' + docker_database + ')' }}
docker_container:
name: "{{ docker_service_name }}_db"
image: "{{ db_container_image }}"
pull: true
env: "{{ db_container_env | default(omit) }}"
published_ports: "{{ db_published_ports | default(omit) }}"
restart_policy: always
mounts: "{{ db_container_mount_definition }}"
networks: "{{ container_networks | default(omit) }}"
log_driver: local

View File

@@ -0,0 +1,14 @@
---
- name: "Create user for {{ docker_service_name }}"
user:
name: "{{ docker_service_name }}"
home: "/opt/{{ docker_service }}/{{ docker_service_suffix | default('') }}"
create_home: false
system: true
shell: /bin/bash
register: user
- name: Set docker container user
set_fact:
docker_user: "{{ user.uid }}:{{ user.group }}"

View File

@@ -0,0 +1,65 @@
---
- name: Image build
when: dockerfile_needed
block:
- name: Set docker_build_directory variable
set_fact:
docker_build_directory: /opt/{{ docker_service }}/build
- name: Create container build directory
file:
path: "{{ docker_build_directory }}"
state: directory
- name: Put dockerfile in place
template:
src: Dockerfile.j2
dest: "{{ docker_build_directory }}/Dockerfile"
mode: 0644
- name: Build docker image for {{ docker_service }}
docker_image:
name: "local_{{ docker_service }}"
source: build
force_source: true
build:
pull: true
path: "{{ docker_build_directory }}"
register: built_image
- name: Pull container image for {{ docker_service }}
docker_image:
name: "{{ docker_image }}"
source: pull
force_source: true
register: pulled_image
when: dockerfile is not defined or dockerfile | length == 0
- name: Set container_image variable
set_fact:
container_image: "{{ item.image }}"
when: item.skipped is not defined or not item.skipped
loop:
- "{{ built_image }}"
- "{{ pulled_image }}"
- name: Check mode image info
when: ansible_check_mode
block:
- name: Get docker image info for check mode
docker_image_info:
name: "{{ ('local_' + docker_service) if dockerfile is defined and dockerfile | length > 0 else docker_image }}"
register: existing_image
- name: Set check mode container_image variable
set_fact:
container_image: "{{ existing_image.images[0] }}"
when: existing_image.images | length > 0
- name: Set image user variable
set_fact:
image_user: "{{ container_image.Config.User }}"
when:
- not ansible_check_mode
- container_image.Config.User | length > 0

View File

@@ -0,0 +1,56 @@
---
- name: Reset variables
set_fact:
docker_volume_definition: []
container_published_ports: []
docker_volumes_new: []
final_docker_volumes: "{{ docker_volumes }}"
container_image: ''
- name: Set assistive variables
set_fact:
template_mounts_needed: "{{ docker_mounts | selectattr('template', 'defined') | list | length > 0 }}"
volumes_needed: "{{ docker_mounts | selectattr('name', 'defined') | list | length > 0 or docker_database != 'none' }}"
dockerfile_needed: "{{ dockerfile is defined and dockerfile | length > 0 }}"
db_config_mounts_needed: "{{ docker_mariadb_config | length > 0 }}"
- name: Set more assistive variables
set_fact:
bind_volumes_needed: "{{ volumes_needed and docker_volume_type == 'bind' }}"
named_volumes_needed: "{{ volumes_needed and docker_volume_type == 'named' }}"
- name: Set even more assistive variables
set_fact:
create_opt_directory: "{{ dockerfile_needed or docker_host_user or bind_volumes_needed or template_mounts_needed or db_config_mounts_needed }}"
create_mounts_directory: "{{ bind_volumes_needed or template_mounts_needed or db_config_mounts_needed }}"
- name: Set docker service full name
set_fact:
docker_service_name: "{{ docker_service }}_{{ docker_service_suffix }}"
when: docker_service_suffix is defined
- name: Warn about docker_volumes legacy format
debug:
msg: "docker_volumes is deprecated. This support may be removed after december 2022. Use docker_mounts instead!"
when: docker_volumes | length > 0
- name: Convert docker_volumes from legacy format
when: docker_volumes | length > 0 and docker_volumes[0] is not mapping
block:
- name: Add legacy docker volumes to docker_volumes_new using the new format
set_fact:
docker_volumes_new: "{{ docker_volumes_new | default([]) + [{'name': item.split(':')[0] | regex_replace('^' + docker_service_name + '_', ''), 'path': item.split(':')[1]}] }}"
when: "'/' not in item.split(':')[0]"
loop: "{{ docker_volumes }}"
- name: Add legacy docker src bind mounts to docker_volumes_new using the new format
set_fact:
docker_volumes_new: "{{ docker_volumes_new | default([]) + [{'src': item.split(':')[0], 'path': item.split(':')[1]}] }}"
when: "'/' in item.split(':')[0]"
loop: "{{ docker_volumes }}"
- name: Set final_docker_volumes variable
set_fact:
final_docker_volumes: "{{ docker_volumes_new }}"
- name: Convert final_docker_volumes to docker_mounts
set_fact:
docker_mounts: "{{ final_docker_volumes }}"
when: docker_mounts | length == 0 and final_docker_volumes | length > 0

View File

@@ -1,65 +1,114 @@
--- ---
- name: "{{ docker_service }} docker network" - name: Container role initialization
docker_network: import_tasks: init.yml
name: "{{ docker_service }}"
when: docker_network_mode is not defined or docker_network_mode != 'host'
- name: Set published ports variable - name: Docker network
set_fact: when: docker_network_mode is not defined or docker_network_mode != 'host' or docker_networks | length > 0
container_published_ports: ["127.0.0.1:{{ ports[docker_service][proxy_target_protocol] }}:{{ docker_image_http_port }}"] block:
when: reverse_proxy_type != 'traefik' and (docker_network_mode is not defined or docker_network_mode != 'host') - name: Set networks variable to {{ docker_service_name }}
- name: Set networks variable
set_fact: set_fact:
container_networks: container_networks:
- name: "{{ docker_service }}" - name: "{{ docker_service_name }}"
when: docker_network_mode is not defined or docker_network_mode != 'host' when: docker_networks | length == 0
- name: Set networks variable to {{ docker_networks }}
- name: Include traefik vars
include_vars: traefik.yml
when: reverse_proxy_type == 'traefik'
- name: Set postgres container env
set_fact: set_fact:
db_container_image: 'postgres:14-alpine' container_networks: "{{ docker_networks }}"
db_container_env: when: docker_networks | length > 0
POSTGRES_USER: "{{ docker_service }}" - name: Create docker networks
POSTGRES_PASSWORD: "{{ database_passwords[docker_service] }}" docker_network:
db_container_data: /var/lib/postgresql/data name: "{{ item.name }}"
when: docker_database is defined and docker_database == 'postgres' loop: "{{ container_networks }}"
- name: Set mongo container env
set_fact:
db_container_image: 'mongo:latest'
db_container_data: /data/db
when: docker_database is defined and docker_database == 'mongo'
- name: "{{ docker_database }} database container for {{ docker_service }}" - name: Reverse proxy for container
docker_container: include_tasks: proxy.yml
name: "{{ docker_service }}_db" when: reverse_proxy_type != 'none'
image: "{{ db_container_image }}"
pull: yes
container_default_behavior: no_defaults
env: "{{ db_container_env | default(omit) }}"
restart_policy: always
volumes:
- "{{ docker_service }}_db:{{ db_container_data }}"
networks: "{{ container_networks | default(omit) }}"
when: docker_database is defined
- name: "Container for {{ docker_service }}" - name: Additional services
when: docker_additional_services is defined
block:
- name: "Memcached container for {{ docker_service_name }}"
docker_container: docker_container:
name: "{{ docker_service }}" name: "{{ docker_service_name }}_memcached"
image: "{{ docker_image }}" image: memcached:alpine
pull: true pull: true
container_default_behavior: no_defaults restart_policy: always
volumes: "{{ docker_volumes | default(omit) }}" networks: "{{ container_networks | default(omit) }}"
published_ports: "{{ container_published_ports | default([]) + docker_published_ports | default(omit) }}" log_driver: local
when: "'memcached' in docker_additional_services"
- name: Create directory /opt/{{ docker_service }}
file:
path: "/opt/{{ docker_service }}"
state: directory
mode: 0755
when: create_opt_directory
- name: Container image
import_tasks: image.yml
- name: Container user
include_tasks: host_user.yml
when: docker_host_user
- name: Create suffix directory
when: create_opt_directory and docker_service_suffix is defined
block:
- name: Create directory /opt/{{ docker_service + '/' + docker_service_suffix }}
file:
path: "/opt/{{ docker_service }}/{{ docker_service_suffix }}"
state: directory
owner: "{{ user.uid | default(omit) }}"
group: "{{ user.group | default(omit) }}"
mode: 0755
- name: Set container_workdir variable
set_fact:
container_workdir: /opt/{{ docker_service }}/{{ docker_service_suffix }}
- name: Set container_workdir variable
set_fact:
container_workdir: /opt/{{ docker_service }}
when: docker_service_suffix is not defined
- name: Create mounts directory
when: create_mounts_directory
block:
- name: Set docker_mounts_dir
set_fact:
docker_mounts_dir: "{{ container_workdir }}/mounts"
- name: Create directory {{ docker_mounts_dir }}
file:
path: "{{ docker_mounts_dir }}"
state: directory
owner: "{{ user.uid | default(omit) }}"
group: "{{ user.group | default(omit) }}"
mode: 0700
- name: Database container
include_tasks: database.yml
when: docker_database != 'none'
- name: Container volumes
import_tasks: volumes.yml
- name: "Container for {{ docker_service_name }}"
docker_container:
name: "{{ docker_service_name }}"
image: "{{ container_image.Id if container_image != '' else docker_image }}"
user: "{{ docker_user if docker_host_user else omit }}"
mounts: "{{ docker_volume_definition }}"
published_ports: "{{ container_published_ports + docker_published_ports }}"
labels: "{{ traefik_labels | default(omit) }}" labels: "{{ traefik_labels | default(omit) }}"
env: "{{ docker_env | combine(docker_additional_env) }}" env: "{{ docker_env | combine(docker_additional_env) | combine({'TZ': timezone}) }}"
entrypoint: "{{ docker_entrypoint | default(omit) }}" entrypoint: "{{ docker_entrypoint | default(omit) }}"
restart_policy: always restart_policy: always
network_mode: "{{ docker_network_mode | default(omit) }}" network_mode: "{{ docker_network_mode | default(omit) }}"
networks: "{{ container_networks | default(omit) }}" networks: "{{ container_networks | default(omit) }}"
log_driver: local
register: container_out register: container_out
- name: Reset docker_mounts if converted from docker_volumes
set_fact:
docker_mounts: []
when: final_docker_volumes | length > 0

View File

@@ -0,0 +1,22 @@
---
- name: Reverse proxy
include_role:
name: uumas.general.reverse_proxy
vars:
vhost_id: "{{ docker_service_name }}"
proxy_target_protocol: "{{ docker_proxy_target_protocol }}"
vhost_domains: "{{ docker_vhost_domains[docker_service_name] }}"
proxy_target_port: "{{ ports[docker_service_name][proxy_target_protocol] }}"
when: reverse_proxy_type != 'traefik'
- name: Set published ports variable to http port
set_fact:
container_published_ports: ["127.0.0.1:{{ ports[docker_service_name][docker_proxy_target_protocol] }}:{{ docker_image_http_port }}"]
when:
- docker_network_mode is not defined or docker_network_mode != 'host'
- reverse_proxy_type != 'traefik'
- name: Include traefik vars
include_vars: traefik.yml
when: reverse_proxy_type == 'traefik'

View File

@@ -0,0 +1,47 @@
---
- name: Create directories and put files in them
when: create_mounts_directory
block:
- name: Define mount directory owner
set_fact:
mount_owner: "{{ user.uid if docker_host_user else image_user | default('') }}"
mount_group: "{{ user.group if docker_host_user else '' }}"
- name: "Create docker bind mount directories for {{ docker_service_name }}"
file:
path: "{{ docker_mounts_dir }}/{{ item.name }}"
state: directory
owner: "{{ mount_owner if (item.set_owner is not defined or item.set_owner) and mount_owner | length > 0 else omit }}"
group: "{{ mount_group if (item.set_group is not defined or item.set_group) and mount_group | length > 0 else omit }}"
when: item.name is defined
loop: "{{ docker_mounts }}"
- name: Set docker_volume_definition for named binds
set_fact:
docker_volume_definition: "{{ docker_volume_definition + [{'source': docker_mounts_dir + '/' + item.name, 'target': item.path, 'type': 'bind'}] }}"
when: item.name is defined
loop: "{{ docker_mounts }}"
- name: Template docker template mounts for {{ docker_service_name }}
template:
src: "{{ item.template }}.j2"
dest: "{{ docker_mounts_dir }}/{{ item.template }}"
when: item.template is defined
loop: "{{ docker_mounts }}"
- name: Set docker_volume_definition for template mounts
set_fact:
docker_volume_definition: "{{ docker_volume_definition + [{'source': docker_mounts_dir + '/' + item.template, 'target': item.path, 'type': 'bind', 'read_only': true}] }}"
when: item.template is defined
loop: "{{ docker_mounts }}"
- name: Set docker_volume_definition for named volumes
set_fact:
docker_volume_definition: "{{ docker_volume_definition + [{'source': docker_service_name + '_' + item.name, 'target': item.path, 'type': 'volume'}] }}"
when: docker_volume_type == 'named' and item.name is defined
loop: "{{ docker_mounts }}"
- name: Set docker_volume_definition for src binds
set_fact:
docker_volume_definition: "{{ docker_volume_definition + [{'source': item.src, 'target': item.path, 'type': 'bind'}] }}"
when: item.src is defined
loop: "{{ docker_mounts }}"

View File

@@ -0,0 +1,9 @@
# {{ ansible_managed }}
FROM {{ docker_image }}
{% if dockerfile.run is iterable %}
{% for cmd in dockerfile.run %}
RUN {{ cmd }}
{% endfor %}
{% endif %}

View File

@@ -0,0 +1,8 @@
# {{ ansible_managed }}
{% for section in docker_mariadb_config | dict2items %}
[{{ section.key }}]
{% for item in section.value | dict2items %}
{{ item.key }} = {{ item.value }}
{% endfor %}
{% endfor %}

View File

@@ -0,0 +1,15 @@
---
docker_service_name: "{{ docker_service }}"
reverse_proxy_type: caddy
docker_proxy_target_protocol: http
docker_additional_env: {}
docker_database: none
docker_volumes: [] # DEPRECATED
docker_mounts: []
docker_networks: []
docker_env: {}
docker_published_ports: []

View File

@@ -2,5 +2,5 @@
traefik_labels: traefik_labels:
traefik.enable: 'true' traefik.enable: 'true'
"traefik.http.routers.{{ docker_service }}.rule": "Host(`{{ vhost_domains[docker_service] | join('`) || Host(`') }}`)" "traefik.http.routers.{{ docker_service_name }}.rule": "Host(`{{ vhost_domains[docker_service_name] | join('`) || Host(`') }}`)"
"traefik.http.routers.{{ docker_service }}.tls.certresolver": 'le' "traefik.http.routers.{{ docker_service_name }}.tls.certresolver": 'le'

View File

@@ -0,0 +1,6 @@
---
- name: restart docker
systemd:
name: docker.service
state: restarted

1
roles/dokuwiki/README.md Normal file
View File

@@ -0,0 +1 @@
Sets up a dokuwiki docker container.

View File

@@ -0,0 +1,4 @@
---
dokuwiki_wiki_name: DokuWiki
dokuwiki_admin_email: "{{ admin_email }}"

View File

@@ -0,0 +1,45 @@
---
argument_specs:
main:
short_description: DokuWiki container
description: "Sets up a DokuWiki docker container."
options:
dokuwiki_wiki_name:
description: Name of the DokuWiki site
type: str
reuired: false
default: DokuWiki
dokuwiki_admin_password:
description: Password of dokuwiki admin user
type: str
required: true
dokuwiki_admin_email:
description: Email address of dokuwiki admin user
type: str
required: false
default: "{{ admin_email }}"
# All options after this will be passed directly to the container role
docker_service_suffix:
description: "Passed to container role"
required: false
docker_host_user:
description: "Passed to container role"
required: false
docker_volume_type:
description: "Passed to container role"
required: false
reverse_proxy_type:
description: "Passed to container role"
required: false
ports:
description: "Passed to container role"
required: false
docker_vhost_domains:
description: "Passed to container role"
required: false
docker_entrypoint:
description: "Passed to container role"
required: false

View File

@@ -0,0 +1,18 @@
---
- name: Dokuwiki container
import_role:
name: container
vars:
docker_service: dokuwiki
docker_image: bitnami/dokuwiki
docker_image_http_port: 8080
docker_mounts:
- name: data
path: /bitnami/dokuwiki
docker_env:
DOKUWIKI_USERNAME: admin
DOKUWIKI_FULL_NAME: Admin
DOKUWIKI_PASSWORD: "{{ dokuwiki_admin_password }}"
DOKUWIKI_EMAIL: "{{ dokuwiki_admin_email }}"
DOKUWIKI_WIKI_NAME: "{{ dokuwiki_wiki_name }}"

View File

@@ -1,7 +1,7 @@
--- ---
dependencies: dependencies:
- docker - role: docker
- role: uumas.general.reverse_proxy - role: uumas.general.reverse_proxy
vhost_id: element vhost_id: element
vhost_domains: "{{ element_domains }}" vhost_domains: "{{ element_domains }}"

View File

@@ -33,4 +33,3 @@
content: "{{ element_config }}" content: "{{ element_config }}"
dest: "{{ element_config_volume.Source }}/config.json" dest: "{{ element_config_volume.Source }}/config.json"
mode: '644' mode: '644'

View File

@@ -25,5 +25,6 @@ dependencies:
GITEA__mailer__HOST: "{{ smtp_server }}:587" GITEA__mailer__HOST: "{{ smtp_server }}:587"
GITEA__mailer__FROM: "{{ smtp_from }}" GITEA__mailer__FROM: "{{ smtp_from }}"
GITEA__mailer__MAILER_TYPE: smtp GITEA__mailer__MAILER_TYPE: smtp
GITERA__mailer__USER: "{{ smtp_user | default(omit) }}" GITEA__mailer__USER: "{{ smtp_user | default(omit) }}"
GITERA__mailer__PASSWD: "{{ smtp_pw | default(omit) }}" GITEA__mailer__PASSWD: "{{ smtp_pw | default(omit) }}"
GITEA__service__REQUIRE_SIGNIN_VIEW: "{{ gitea_require_signin_view | default(omit) }}"

View File

@@ -4,16 +4,16 @@
group: group:
name: git name: git
gid: 2132 gid: 2132
system: yes system: true
- name: Create git user on host for gitea ssh - name: Create git user on host for gitea ssh
user: user:
name: git name: git
uid: 2132 uid: 2132
group: git group: git
system: yes system: true
home: /var/lib/gitea home: /var/lib/gitea
generate_ssh_key: yes generate_ssh_key: true
register: git_user register: git_user
- name: Add git user's own ssh key to its authorized keys - name: Add git user's own ssh key to its authorized keys

1
roles/grafana/README.md Normal file
View File

@@ -0,0 +1 @@
Sets up a grafana docker container.

View File

@@ -0,0 +1,38 @@
---
argument_specs:
main:
short_description: Alpine container
description: "Sets up an alpine docker container. This role can be used as a template for other roles using the container role."
options:
database_passwords:
description: "Passed to container role"
required: true
type: dict
docker_vhost_domains:
description: "Passed to container role"
required: true
type: dict
# All options after this will be passed directly to the container role
docker_host_user:
description: "Passed to container role"
required: false
docker_additional_services:
description: "Passed to container role"
required: false
docker_volume_type:
description: "Passed to container role"
required: false
reverse_proxy_type:
description: "Passed to container role"
required: false
ports:
description: "Passed to container role"
required: false
docker_entrypoint:
description: "Passed to container role"
required: false

View File

@@ -0,0 +1,21 @@
---
- name: Grafana container
import_role:
name: container
vars:
docker_service: grafana
docker_image: grafana/grafana
docker_image_http_port: 3000
docker_volumes:
- name: data
path: /var/lib/grafana
docker_database: postgres
docker_env:
GF_DATABASE_TYPE: postgres
GF_DATABASE_HOST: grafana_db:5432
GF_DATABASE_NAME: grafana
GF_DATABASE_USER: grafana
GF_DATABASE_PASSWORD: "{{ database_passwords.grafana }}"
GF_SERVER_DOMAIN: "{{ docker_vhost_domains.grafana[0] }}"
GF_SERVER_ROOT_URL: "https://{{ docker_vhost_domains.grafana[0] }}"

View File

@@ -15,4 +15,3 @@ dependencies:
CMD_ALLOW_ANONYMOUS: "false" CMD_ALLOW_ANONYMOUS: "false"
CMD_ALLOW_ANONYMOUS_EDITS: "true" CMD_ALLOW_ANONYMOUS_EDITS: "true"
CMD_ALLOW_FREEURL: "true" CMD_ALLOW_FREEURL: "true"

View File

@@ -0,0 +1,4 @@
---
jitsi_docker_tag: stable
reverse_proxy_type: caddy

View File

@@ -1,7 +1,7 @@
--- ---
dependencies: dependencies:
- docker - role: docker
- role: uumas.general.reverse_proxy - role: uumas.general.reverse_proxy
vhost_id: jitsi vhost_id: jitsi
vhost_domains: vhost_domains:

View File

@@ -9,6 +9,14 @@
jitsi_web_published_ports: ["127.0.0.1:{{ ports.jitsi_http }}:80"] jitsi_web_published_ports: ["127.0.0.1:{{ ports.jitsi_http }}:80"]
when: reverse_proxy_type != 'traefik' when: reverse_proxy_type != 'traefik'
- name: Reset jitsi meet prosody published ports variable
set_fact:
jitsi_prosody_published_ports: []
- name: Set jitsi meet prosody published ports variable
set_fact:
jitsi_prosody_published_ports: ["127.0.0.1:{{ ports.jitsi_prosody_http }}:5280"]
when: ports.jitsi_prosody_http is defined
- name: Include traefik vars - name: Include traefik vars
include_vars: traefik.yml include_vars: traefik.yml
when: reverse_proxy_type == 'traefik' when: reverse_proxy_type == 'traefik'
@@ -16,7 +24,7 @@
- name: Jitsi meet web - name: Jitsi meet web
docker_container: docker_container:
name: 'jitsi_meet_web' name: 'jitsi_meet_web'
image: 'jitsi/web:latest' image: "jitsi/web:{{ jitsi_docker_tag }}"
pull: true pull: true
container_default_behavior: no_defaults container_default_behavior: no_defaults
published_ports: "{{ jitsi_web_published_ports | default(omit) }}" published_ports: "{{ jitsi_web_published_ports | default(omit) }}"
@@ -41,25 +49,13 @@
- meet.jitsi - meet.jitsi
register: jitsi_meet_web_out register: jitsi_meet_web_out
- set_fact:
jitsi_meet_web_config_volume: "{{ jitsi_meet_web_out.container.Mounts | selectattr('Destination', 'equalto', '/config') | join }}"
- name: Disable recording and livestreaming
lineinfile:
path: "{{ jitsi_meet_web_config_volume.Source }}/config.js"
regexp: "^ (\/\/ )?{{ item }}: .*,$"
line: " {{ item }}: false,"
state: present
loop:
- fileRecordingsEnabled
- liveStreamingEnabled
- name: Jitsi meet prosody - name: Jitsi meet prosody
docker_container: docker_container:
name: 'jitsi_meet_prosody' name: 'jitsi_meet_prosody'
image: 'jitsi/prosody:latest' image: "jitsi/prosody:{{ jitsi_docker_tag }}"
pull: true pull: true
container_default_behavior: no_defaults container_default_behavior: no_defaults
published_ports: "{{ jitsi_prosody_published_ports }}"
env: env:
PUBLIC_URL: "https://{{ jitsi_domain }}" PUBLIC_URL: "https://{{ jitsi_domain }}"
TZ: "{{ timezone }}" TZ: "{{ timezone }}"
@@ -69,10 +65,16 @@
JICOFO_AUTH_PASSWORD: "{{ jitsi_pw.jicofo_auth }}" JICOFO_AUTH_PASSWORD: "{{ jitsi_pw.jicofo_auth }}"
JVB_AUTH_USER: jvb JVB_AUTH_USER: jvb
JVB_AUTH_PASSWORD: "{{ jitsi_pw.jvb_auth }}" JVB_AUTH_PASSWORD: "{{ jitsi_pw.jvb_auth }}"
TURN_CREDENTIALS: "{{ turn_secret | default(omit) }}"
TURN_HOST: "{{ turn_domain | default(omit) }}"
TURN_PORT: "{{ '443' if turn_domain is defined else omit }}"
TURNS_HOST: "{{ turn_domain | default(omit) }}"
TURNS_PORT: "{{ '443' if turn_domain is defined else omit }}"
XMPP_DOMAIN: meet.jitsi XMPP_DOMAIN: meet.jitsi
XMPP_AUTH_DOMAIN: auth.meet.jitsi XMPP_AUTH_DOMAIN: auth.meet.jitsi
XMPP_INTERNAL_MUC_DOMAIN: internal-muc.meet.jitsi XMPP_INTERNAL_MUC_DOMAIN: internal-muc.meet.jitsi
XMPP_MUC_DOMAIN: muc.meet.jitsi XMPP_MUC_DOMAIN: muc.meet.jitsi
XMPP_MODULES: 'muc_census'
restart_policy: always restart_policy: always
exposed_ports: exposed_ports:
- '5222' - '5222'
@@ -85,7 +87,7 @@
- name: Jitsi meet jicofo - name: Jitsi meet jicofo
docker_container: docker_container:
name: 'jitsi_meet_jicofo' name: 'jitsi_meet_jicofo'
image: 'jitsi/jicofo:latest' image: "jitsi/jicofo:{{ jitsi_docker_tag }}"
pull: true pull: true
container_default_behavior: no_defaults container_default_behavior: no_defaults
env: env:
@@ -108,7 +110,7 @@
- name: Jitsi meet video bridge - name: Jitsi meet video bridge
docker_container: docker_container:
name: 'jitsi_meet_jvb' name: 'jitsi_meet_jvb'
image: 'jitsi/jvb:latest' image: "jitsi/jvb:{{ jitsi_docker_tag }}"
pull: true pull: true
container_default_behavior: no_defaults container_default_behavior: no_defaults
published_ports: published_ports:
@@ -132,4 +134,3 @@
- name: meet.jitsi - name: meet.jitsi
aliases: aliases:
- meet.jitsi - meet.jitsi

View File

@@ -20,4 +20,3 @@ dependencies:
KC_DB_URL: jdbc:postgresql://keycloak_db/keycloak KC_DB_URL: jdbc:postgresql://keycloak_db/keycloak
KC_DB_USERNAME: keycloak KC_DB_USERNAME: keycloak
KC_DB_PASSWORD: "{{ database_passwords.keycloak }}" KC_DB_PASSWORD: "{{ database_passwords.keycloak }}"

View File

@@ -0,0 +1 @@
Sets up a prometheus docker container.

View File

@@ -0,0 +1,6 @@
---
prometheus_scrape_interval: 5s
prometheus_evaluation_interval: 15s
prometheus_install_grafana: false
prometheus_hcloud_relabel_configs: []

View File

@@ -0,0 +1,73 @@
---
argument_specs:
main:
short_description: Prometheus docker container
options:
prometheus_scrape_interval:
description: Interval how often prometheus will scrape the monitoring targets
type: str
required: false
default: 5s
prometheus_evaluation_interval:
description: Interval how often prometheus will evaluate the scraped metrics against defined conditions
type: str
required: false
default: 15s
prometheus_hcloud_token:
description: Access token for hetzner cloud service discovery. It will be enabled if this variable is defined
type: str
required: false
prometheus_hcloud_relabel_configs:
description: Relabel configs for hcloud
type: list
required: false
default: []
elements: dict
options:
source_labels:
type: list
required: true
elements: str
target_label:
type: str
required: true
replacement:
type: str
required: false
prometheus_install_grafana:
description: If true, installs grafana in the same docker network as prometheus and configures it with prometheus as data source
type: bool
required: false
default: false
# All options after this will be passed directly to the container role
docker_service_suffix:
description: "Passed to container role"
required: false
docker_host_user:
description: "Passed to container role"
required: false
database_passwords:
description: "Passed to container role"
required: false
docker_additional_services:
description: "Passed to container role"
required: false
docker_volume_type:
description: "Passed to container role"
required: false
reverse_proxy_type:
description: "Passed to container role"
required: false
ports:
description: "Passed to container role"
required: false
docker_vhost_domains:
description: "Passed to container role"
required: false
docker_entrypoint:
description: "Passed to container role"
required: false

View File

@@ -0,0 +1,22 @@
---
- name: Prometheus container
import_role:
name: container
vars:
docker_service: prometheus
docker_image: prom/prometheus
reverse_proxy_type: none
docker_volumes:
- name: data
path: /prometheus
- template: prometheus.yml
path: /etc/prometheus/prometheus.yml
- name: Grafana container for prometheus
include_role:
name: grafana
vars:
docker_networks:
- name: prometheus
when: prometheus_install_grafana

View File

@@ -0,0 +1,34 @@
---
# my global config
global:
scrape_interval: {{ prometheus_scrape_interval }}
evaluation_interval: {{ prometheus_evaluation_interval }}
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
{% if prometheus_hcloud_token is defined %}
- job_name: hcloud
hetzner_sd_configs:
- role: hcloud
authorization:
credentials: {{ prometheus_hcloud_token }}
relabel_configs: {{ prometheus_hcloud_relabel_configs }}
{% endif %}

1
roles/uisp/README.md Normal file
View File

@@ -0,0 +1 @@
Sets up an UISP docker container.

View File

@@ -0,0 +1,35 @@
---
argument_specs:
main:
short_description: UISP container
description: "Sets up an UISP docker container."
options:
ports:
description: "ports.netflow is used directly. Others passed to container role"
required: true
# All options after this will be passed directly to the container role
docker_service_suffix:
description: "Passed to container role"
required: false
docker_host_user:
description: "Passed to container role"
required: false
docker_additional_services:
description: "Passed to container role"
required: false
docker_volume_type:
description: "Passed to container role"
required: false
reverse_proxy_type:
description: "Passed to container role"
required: false
docker_vhost_domains:
description: "Passed to container role"
required: false
docker_entrypoint:
description: "Passed to container role"
required: false

18
roles/uisp/tasks/main.yml Normal file
View File

@@ -0,0 +1,18 @@
---
- name: UISP container
import_role:
name: container
vars:
docker_service: uisp
docker_proxy_target_protocol: https
docker_image: nico640/docker-unms
docker_image_http_port: 8443
docker_mounts:
- name: config
path: /config
docker_published_ports:
- "0.0.0.0:{{ ports.uisp.netflow }}:2055"
docker_env:
HTTPS_PORT: "8443"
PUBLIC_HTTPS_PORT: "443"

View File

@@ -11,4 +11,3 @@ dependencies:
docker_env: docker_env:
UNIFI_HTTPS_PORT: "{{ ports.unifi.https }}" UNIFI_HTTPS_PORT: "{{ ports.unifi.https }}"
PORTAL_HTTP_PORT: "8808" PORTAL_HTTP_PORT: "8808"

View File

@@ -12,4 +12,3 @@ dependencies:
MONGO_URL: mongodb://wekan_db:27017/wekan MONGO_URL: mongodb://wekan_db:27017/wekan
ROOT_URL: "https://{{ docker_vhost_domains.wekan[0] }}" ROOT_URL: "https://{{ docker_vhost_domains.wekan[0] }}"
WRITABLE_PATH: /data WRITABLE_PATH: /data

View File

@@ -10,3 +10,4 @@
state: directory state: directory
owner: 999 owner: 999
group: 999 group: 999
mode: 0755

View File

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

View File

@@ -0,0 +1,12 @@
---
wordpress_tag: php8.1
docker_additional_services: []
docker_host_user: false
wordpress_symlinks: false
wordpress_php_memory_limit: 256M
wordpress_php_post_max_size: 128M
wordpress_php_upload_max_filesize: 32M

View File

@@ -0,0 +1,45 @@
---
- name: Reset dockerfile variable
set_fact:
dockerfile: {}
- name: Set docker service full name (required because docker_env uses it)
set_fact:
docker_service_name: "wordpress_{{ docker_service_suffix }}"
when: docker_service_suffix is defined
- 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,5 @@
; {{ ansible_managed }}
memory_limit = {{ wordpress_php_memory_limit }}
post_max_size = {{ wordpress_php_post_max_size }}
upload_max_filesize = {{ wordpress_php_upload_max_filesize }}

View File

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

View File

@@ -0,0 +1,7 @@
---
wordpress_docker_volumes:
- name: html
path: /var/www/html
- template: php.ini
path: /usr/local/etc/php/conf.d/custom.ini

View File

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