Commit initial

This commit is contained in:
Navas 2022-07-20 12:02:01 +02:00
commit 59fddd7fa9
5 changed files with 101 additions and 0 deletions

38
README.md Normal file
View file

@ -0,0 +1,38 @@
# Role : docker_wordpress
## Services fournis
Installation d'une instance wordpress sur un serveur docker_host
## Variables
Fournir les variables suivantes. Par exemple :
```yaml
docker_wordpress_fqdn: monsite.libretic.fr
docker_wordpress_data_dir: /data1
docker_wordpress_service_id: monsite
docker_wordpress_image_version: 6.0.0-apache
docker_wordpress_db_name: wp
docker_wordpress_db_user: wp
docker_wordpress_db_password: mdp_bdd
```
| Option | Valeur par défaut | Description |
|--------------------------------|-------------------|-------------------------------------------------------------------------------------------|
| docker_wordpress_fqdn | | Nom de domaine, ou liste de noms de domaines, pour lequel le service wordpress répond |
| docker_wordpress_data_dir | | L'emplacement dans lequel se trouvent les volumes de donnees docker pour le service |
| docker_wordpress_service_id | | Le nom de service souhaité : conditionne le nommage des volumes et le routage par traefik |
| docker_wordpress_image_version | | Version de wordpress et de l'image docker |
| docker_wordpress_db_name | | Nom de la base de données |
| docker_wordpress_db_user | | Nom du user proprietaire de la base de donnees |
| docker_wordpress_db_password | | Mot de passe du user proprietaire de la base de donnees |
## Poursuite de l'installation dans wordpress
Après le premier lancement :
- créer le compte administrateur interne de wordpress depuis la page d'administration

0
defaults/main.yml Normal file
View file

5
handlers/main.yml Normal file
View file

@ -0,0 +1,5 @@
- name: docker-compose-up
shell: |
docker-compose up -d
args:
chdir: /opt/{{ docker_wordpress_service_id }}/

14
tasks/main.yml Normal file
View file

@ -0,0 +1,14 @@
- name: docker directory
file:
path: /opt/{{ docker_wordpress_service_id }}/
state: directory
- name: prepare docker-compose.yml
template:
src: "{{ item }}"
dest: /opt/{{ docker_wordpress_service_id }}/
with_items:
- docker-compose.yml
notify: docker-compose-up

View file

@ -0,0 +1,44 @@
# {{ ansible_managed }}
version: '3.1'
services:
wordpress:
image: wordpress:{{ docker_wordpress_image_version }}
restart: always
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: "{{ docker_wordpress_db_user }}"
WORDPRESS_DB_PASSWORD: "{{ docker_wordpress_db_password }}"
WORDPRESS_DB_NAME: "{{ docker_wordpress_db_name }}"
volumes:
- /data1/{{ docker_wordpress_service_id }}/wp_html:/var/www/html
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.routers.{{ docker_wordpress_service_id }}.entrypoints=web"
- "traefik.http.routers.{{ docker_wordpress_service_id }}.rule=Host(`{{ docker_wordpress_fqdn }}`)"
- "traefik.http.services.{{ docker_wordpress_service_id }}.loadbalancer.server.port=80"
networks:
- wordpress
- traefik
db:
image: mariadb:10.8.2-rc-focal
restart: always
volumes:
- {{ docker_wordpress_data_dir }}/data1/{{ docker_wordpress_service_id }}/mysql:/var/lib/mysql
environment:
# genere un mdp root et l'affiche au demarrage sur stdout
MARIADB_RANDOM_ROOT_PASSWORD: "yes"
MARIADB_DATABASE: "{{ docker_wordpress_db_name }}"
MARIADB_USER: "{{ docker_wordpress_db_user }}"
MARIADB_PASSWORD: "{{ docker_wordpress_db_password }}"
networks:
- wordpress
networks:
traefik:
external: true
wordpress:
internal: true