From 64d2994388334aa0033bb5656ffc10737b4fbf3b Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 9 Aug 2022 12:00:05 +0200 Subject: [PATCH] Update to 2022-08-09 12:00 --- roles/docker_wordpress/defaults/main.yml | 44 ++++++++++------------ roles/docker_wordpress/tasks/main.yml | 30 +++++++++------ roles/docker_wordpress/templates/docker-compose.j2 | 31 +++++++++++++++ .../templates/docker-compose.yml.j2 | 31 --------------- roles/mysql_server/vars/AlmaLinux-8.yml | 6 +++ 5 files changed, 75 insertions(+), 67 deletions(-) create mode 100644 roles/docker_wordpress/templates/docker-compose.j2 delete mode 100644 roles/docker_wordpress/templates/docker-compose.yml.j2 create mode 100644 roles/mysql_server/vars/AlmaLinux-8.yml diff --git a/roles/docker_wordpress/defaults/main.yml b/roles/docker_wordpress/defaults/main.yml index d192f8b..b10778c 100644 --- a/roles/docker_wordpress/defaults/main.yml +++ b/roles/docker_wordpress/defaults/main.yml @@ -1,28 +1,24 @@ --- -# Default name of WP containers and unique ID for this instance -wp_docker_name: wp_wordpress - -# Root dir of Docker -wp_docker_root_dir: /opt/docker - -# Default Wordpress image used from Docker HUB -wp_docker_wp_image: wordpress-fpm:latest - -# Default PHPMyAdmin image used from Docker HUB -wp_docker_pma_image: phpmyadmin:latest - -# Containers will automaticly restart Website at boot -wp_docker_restart: unless-stopped - -# Default port of Wordpress containers -wp_docker_wp_port: 8080 - -# Default port of PHPMyAdmin containers -wp_docker_pma_port: 8180 +# Default Docker configuration +wpdocker_name: wordpress +wpdocker_email: technique@iptek.fr +wpdocker_root_dir: /opt/docker +wpdocker_restart: unless-stopped + +# Default Wordpress configuration +wpdocker_wp_image: wordpress-fpm:latest +wpdocker_wp_port: 8080 +wpdocker_url: wp.iptek.fr +wpdocker_admin: iptek +wpdocker_pass: "S3cr3t." # Default DB config -wp_docker_db_host: localhost -wp_docker_db_user: wp_wordpress -wp_docker_db_pass: wp_wordpress -wp_docker_db_name: wp_wordpress +wpdocker_db_host: localhost +wpdocker_db_user: wordpress +wpdocker_db_pass: "S3cr3t." +wpdocker_db_name: wordpress + +# Default PHPMyAdmin configuration +wpdocker_pma_image: phpmyadmin:latest +wpdocker_pma_port: 8180 diff --git a/roles/docker_wordpress/tasks/main.yml b/roles/docker_wordpress/tasks/main.yml index 9ee8427..578d52c 100644 --- a/roles/docker_wordpress/tasks/main.yml +++ b/roles/docker_wordpress/tasks/main.yml @@ -1,29 +1,35 @@ --- + - name: Create main folder for configuration files + file: + path: "{{ wpdocker_root_dir }}/conf" + state: directory + owner: bin + group: wheel + mode: '0644' + - name: Create folders for each containers - with_items: "{{ wp_docker }}" + with_items: "{{ wpdocker }}" file: - path: "{{ wp_docker_root_dir }}/{{ item.wp_docker_name }}" + path: "{{ wpdocker_root_dir }}/conf/{{ item.wpdocker_name }}" state: directory owner: bin group: wheel mode: '0644' + - name: Deploy docker-compose YML file - with_items: "{{ wp_docker }}" + with_items: "{{ wpdocker }}" template: - src: docker-compose.yml.j2 - dest: "{{ wp_docker_root_dir }}/{{ item.wp_docker_name }}/docker-compose.yml" + src: docker-compose.j2 + dest: "{{ wpdocker_root_dir }}/conf/{{ item.wpdocker_name }}/docker-compose.yml" owner: bin group: wheel mode: '0644' - # - name: Launch PhpMyAdmin containers - # with_items: "{{ wp_docker }}" - # command: "docker-compose up -d -f {{ wp_docker_root_dir }}/pma_{{ item.wp_docker_name }}/docker-compose.yml" - - # - name: Launch Wordpress containers - # with_items: "{{ wp_docker }}" - # command: "docker-compose up -d -f {{ wp_docker_root_dir }}/{{ item.wp_docker_name }}/docker-compose.yml" + - name: Launch containers + with_items: "{{ wpdocker }}" + command: "echo 'docker-compose -f {{ wpdocker_root_dir }}/conf/{{ item.wpdocker_name }}/docker-compose.yml up -d'" + # command: "docker-compose -f {{ wpdocker_root_dir }}/conf/{{ item.wpdocker_name }}/docker-compose.yml" up -d # - name: Send an welcome email message # TODO diff --git a/roles/docker_wordpress/templates/docker-compose.j2 b/roles/docker_wordpress/templates/docker-compose.j2 new file mode 100644 index 0000000..c322a60 --- /dev/null +++ b/roles/docker_wordpress/templates/docker-compose.j2 @@ -0,0 +1,31 @@ +version: '3.1' +services: + wordpress-fpm: + image: "{{ item.wpdocker_wp_image }}" + restart: "{{ item.wpdocker_restart }}" + container_name: "wp_{{ item.wpdocker_name }}" + ports: + - "{{ item.wpdocker_wp_port}}" + environment: + WORDPRESS_DB_HOST: "{{ item.wpdocker_db_host }}" + WORDPRESS_DB_USER: "{{ item.wpdocker_db_user }}" + WORDPRESS_DB_PASSWORD: "{{ item.wpdocker_db_pass }}" + WORDPRESS_DB_NAME: "{{ item.wpdocker_db_name }}" + volumes: + - /opt/wp/{{ item.wpdocker_name }}/html:/var/www/html +# - TODO : conf PHP +# - TODO : Backups +# - TODO : cron +# - TODO : email + phpmyadmin: + image: "{{ item.wpdocker_pma_image }}" + restart: "{{ item.wpdocker_restart }}" + container_name: "pma_{{ item.wpdocker_name }}" + ports: + - "{{ item.wpdocker_pma_port}}" + environment: + PMA_ARBITRARY: 0 + PMA_HOST: "{{ item.wpdocker_db_host }}" + PMA_ABSOLUTE_URI: "db.{{ item.wpdocker_url }}" +# volumes: +# - TODO : conf PMA diff --git a/roles/docker_wordpress/templates/docker-compose.yml.j2 b/roles/docker_wordpress/templates/docker-compose.yml.j2 deleted file mode 100644 index c95595b..0000000 --- a/roles/docker_wordpress/templates/docker-compose.yml.j2 +++ /dev/null @@ -1,31 +0,0 @@ -version: '3.1' - -services: - wordpress-fpm: - image: "{{ item.wp_docker_wp_image }}" - restart: "{{ item.wp_docker_restart }}" - container_name: "{{ item.wp_docker_name }}" - ports: "{{ item.wp_docker_wp_port}}" - environment: - WORDPRESS_DB_HOST: "{{ item.wp_docker_db_host }}" - WORDPRESS_DB_USER: "{{ item.wp_docker_db_user }}" - WORDPRESS_DB_PASSWORD: "{{ item.wp_docker_db_pass }}" - WORDPRESS_DB_NAME: "{{ item.wp_docker_db_name }}" - volumes: - - /opt/wp/"{{ item.wp_docker_name }}"/html:/var/www/html -# - conf PHP -# - Backups -# - cron -# - email - - phpmyadmin: - image: "{{ item.wp_docker_pma_image }}" - restart: "{{ item.wp_docker_restart }}" - container_name: pma_"{{ item.wp_docker_name }}" - ports: "{{ item.wp_docker_pma_port}}" - environment: - - PMA_ARBITRARY=0 - - PMA_HOST: "{{ item.wp_docker_db_host }}" - - PMA_ABSOLUTE_URI: db."{{ item.wp_docker_url }}" - volumes: -# - diff --git a/roles/mysql_server/vars/AlmaLinux-8.yml b/roles/mysql_server/vars/AlmaLinux-8.yml new file mode 100644 index 0000000..c07acd7 --- /dev/null +++ b/roles/mysql_server/vars/AlmaLinux-8.yml @@ -0,0 +1,6 @@ +--- + +mysql_server_packages: + - "{{ (mysql_engine == 'mysql') | ternary('mysql-server','mariadb-server') }}" + - "{{ (mysql_engine == 'mysql') | ternary('mysql','mariadb') }}" + - python3-mysql