From 68a2bd4421cff0141f16e159b99e4adc2e806350 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 6 Dec 2023 14:40:18 +0100 Subject: [PATCH] refactored wordpress role --- playbook.yml | 16 +++++------- .../tasks/create-wordpress-nginx.yml | 10 +++++++ roles/docker-wordpress/tasks/main.yml | 26 ++++++++++--------- tasks/recieve-certbot-certificate.yml | 2 ++ 4 files changed, 32 insertions(+), 22 deletions(-) create mode 100644 roles/docker-wordpress/tasks/create-wordpress-nginx.yml create mode 100644 tasks/recieve-certbot-certificate.yml diff --git a/playbook.yml b/playbook.yml index ec9c608f..faa8770d 100644 --- a/playbook.yml +++ b/playbook.yml @@ -74,16 +74,12 @@ - name: setup wordpress hosts hosts: wordpress become: true - tasks: - - name: Include docker-wordpress role for each domain - include_role: - name: docker-wordpress - vars: - domain: "{{ item }}" - http_port: 8003 - loop: "{{ wordpress_domains }}" - loop_control: - loop_var: item + roles: + - role: docker-wordpress + vars: + domain: "{{ item }}" + http_port: 8003 + - name: setup mediawiki hosts hosts: mediawiki become: true diff --git a/roles/docker-wordpress/tasks/create-wordpress-nginx.yml b/roles/docker-wordpress/tasks/create-wordpress-nginx.yml new file mode 100644 index 00000000..06689927 --- /dev/null +++ b/roles/docker-wordpress/tasks/create-wordpress-nginx.yml @@ -0,0 +1,10 @@ +- name: Activate NGINX matomo tracking for {{domain}} + include_role: + name: nginx-matomo-tracking + when: nginx_matomo_tracking_active + +- name: configure wordpress nginx configurations + vars: + client_max_body_size: "{{wordpress_max_upload_size}}" + template: src=roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 dest=/etc/nginx/conf.d/{{ domain }}.conf + notify: restart nginx \ No newline at end of file diff --git a/roles/docker-wordpress/tasks/main.yml b/roles/docker-wordpress/tasks/main.yml index e0390e81..a8ad46f6 100644 --- a/roles/docker-wordpress/tasks/main.yml +++ b/roles/docker-wordpress/tasks/main.yml @@ -1,17 +1,19 @@ --- -- name: recieve wordpress certificates for {{domain}} - command: certbot certonly --agree-tos --email {{administrator_email}} --non-interactive --webroot -w /var/lib/letsencrypt/ -d {{domain}} - -- name: Activate NGINX matomo tracking for {{domain}} - include_role: - name: nginx-matomo-tracking - when: nginx_matomo_tracking_active - -- name: configure wordpress nginx configurations +- name: "include task receive certbot certificate" + include_tasks: recieve-certbot-certificate.yml vars: - client_max_body_size: "{{wordpress_max_upload_size}}" - template: src=roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 dest=/etc/nginx/conf.d/{{ domain }}.conf - notify: restart nginx + domain: "{{ item }}" + loop: "{{ wordpress_domains }}" + loop_control: + loop_var: item + +- name: "include task create wordpress nginx" + include_tasks: create-wordpress-nginx.yml + vars: + domain: "{{ item }}" + loop: "{{ wordpress_domains }}" + loop_control: + loop_var: item - name: "create {{docker_compose_instance_directory}}" file: diff --git a/tasks/recieve-certbot-certificate.yml b/tasks/recieve-certbot-certificate.yml new file mode 100644 index 00000000..77f063ee --- /dev/null +++ b/tasks/recieve-certbot-certificate.yml @@ -0,0 +1,2 @@ +- name: recieve certbot certificate for {{domain}} + command: certbot certonly --agree-tos --email {{administrator_email}} --non-interactive --webroot -w /var/lib/letsencrypt/ -d {{domain}} \ No newline at end of file