homelab/roles/wordpress/tasks/main.yml

35 lines
1.3 KiB
YAML

- name: Start WordPress database container
community.general.docker_container:
name: "{{ wordpress_dbcontainer }}"
image: mariadb:{{ wordpress_dbversion }}
restart_policy: always
volumes: "{{ wordpress_dbroot }}:/var/lib/mysql"
env:
MYSQL_RANDOM_ROOT_PASSWORD: "true"
MYSQL_DATABASE: "{{ wordpress_dbname }}"
MYSQL_USER: "{{ wordpress_dbuser }}"
MYSQL_PASSWORD: "{{ wordpress_dbpass }}"
- name: Start WordPress container
community.general.docker_container:
name: "{{ wordpress_container }}"
image: wordpress:{{ wordpress_version }}
restart_policy: always
volumes:
- "{{ wordpress_docroot }}:/var/www/html"
labels:
traefik.http.routers.wordpress.rule: "{{ wordpress_rule }}"
traefik.http.routers.wordpress.entrypoints: websecure
traefik.http.routers.wordpress.tls.certresolver: letsencrypt
traefik.http.routers.wordpress.middlewares: securehttps@file
traefik.docker.network: traefik
traefik.enable: "true"
links:
- "{{ wordpress_dbcontainer }}"
env:
WORDPRESS_DB_NAME: "{{ wordpress_dbname }}"
WORDPRESS_DB_USER: "{{ wordpress_dbuser }}"
WORDPRESS_DB_PASSWORD: "{{ wordpress_dbpass }}"
WORDPRESS_DB_HOST: "{{ wordpress_dbcontainer }}"
WORDPRESS_CONFIG_EXTRA: "{{ wordpress_config_extra }}"