From 00a79d11ed70e9c622058e240f6af5c80008203e Mon Sep 17 00:00:00 2001 From: Nareshkumar Rao Date: Sat, 25 Sep 2021 21:18:58 +0200 Subject: [PATCH] loops over sites --- roles/wordpress/tasks/main.yml | 31 +++++-------------------------- roles/wordpress/tasks/setup.yml | 27 +++++++++++++++++++++++++++ vars.yml | 4 +++- 3 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 roles/wordpress/tasks/setup.yml diff --git a/roles/wordpress/tasks/main.yml b/roles/wordpress/tasks/main.yml index f63141d..298a528 100644 --- a/roles/wordpress/tasks/main.yml +++ b/roles/wordpress/tasks/main.yml @@ -9,30 +9,9 @@ name: php-curl, php-imagick, php-json, php-mbstring, php-xml, php-zip, php-gd, ghostscript, imagemagick state: present -- name: Check Certificate Modify Dates - stat: - path: "{{ letsencrypt_certs_dir }}/{{ site_url }}.crt" - register: stat_results - -- name: Get LetsEncrypt Certificates - import_tasks: letsencrypt.yml - when: ((ansible_date_time.epoch|int - stat_results.stat.mtime) > (90 * 60 * 60 * 24)) - -- name: Copy Apache config - template: - src: apache-site.conf - dest: /etc/apache2/sites-available/{{ site_url }}.conf - owner: root - group: root - mode: u=rw,g=r,o=r - -- name: Enable Apache Modules - shell: a2enmod ssl rewrite - notify: - - Restart Apache - -- name: Enable Apache site - shell: a2ensite {{ site_url }} - notify: - - Restart Apache +- name: Loop over sites to setup + include_tasks: setup.yml + loop: "{{ site_urls }}" + loop_control: + loop_var: site_url diff --git a/roles/wordpress/tasks/setup.yml b/roles/wordpress/tasks/setup.yml new file mode 100644 index 0000000..4d1193e --- /dev/null +++ b/roles/wordpress/tasks/setup.yml @@ -0,0 +1,27 @@ +- name: Check Certificate Modify Dates + stat: + path: "{{ letsencrypt_certs_dir }}/{{ site_url }}.crt" + register: stat_results + +- name: Get LetsEncrypt Certificates + import_tasks: letsencrypt.yml + when: (stat_results.stat.mtime is defined and (ansible_date_time.epoch|int - stat_results.stat.mtime) > (90 * 60 * 60 * 24)) + +- name: Copy Apache config + template: + src: apache-site.conf + dest: /etc/apache2/sites-available/{{ site_url }}.conf + owner: root + group: root + mode: u=rw,g=r,o=r + +- name: Enable Apache Modules + shell: a2enmod ssl rewrite + notify: + - Restart Apache + +- name: Enable Apache site + shell: a2ensite {{ site_url }} + notify: + - Restart Apache + diff --git a/vars.yml b/vars.yml index afea4ca..134217c 100644 --- a/vars.yml +++ b/vars.yml @@ -1,5 +1,7 @@ --- -site_url: psm.msolidariti.org +# Website Configurations +site_urls: + - psm.msolidariti.org admin_email: naresh@msolidariti.org # LetsEncrypt Configuration