Browse Source

loops over sites

master
Nareshkumar Rao 3 years ago
parent
commit
00a79d11ed
  1. 31
      roles/wordpress/tasks/main.yml
  2. 27
      roles/wordpress/tasks/setup.yml
  3. 4
      vars.yml

31
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 name: php-curl, php-imagick, php-json, php-mbstring, php-xml, php-zip, php-gd, ghostscript, imagemagick
state: present 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

27
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

4
vars.yml

@ -1,5 +1,7 @@
--- ---
site_url: psm.msolidariti.org
# Website Configurations
site_urls:
- psm.msolidariti.org
admin_email: naresh@msolidariti.org admin_email: naresh@msolidariti.org
# LetsEncrypt Configuration # LetsEncrypt Configuration

Loading…
Cancel
Save