automation/deployer/roles/build/tasks/wordpress.yml

100 lines
2.5 KiB
YAML
Raw Normal View History

---
- name: "Set site_data_path to {{ www_path }}/{{ site.slug }}_wp-content"
set_fact: site_data_path="{{ www_path }}/{{ site.slug }}_wp-content"
2020-05-05 09:08:24 +00:00
tags: always
###############################
# Create wp-content if needed #
###############################
2020-05-01 13:40:16 +00:00
- name: Is it a new install?
stat:
2020-05-05 09:08:24 +00:00
path: "{{ site_data_path }}/index.php"
2020-05-01 13:40:16 +00:00
register: wpcontent
2020-05-07 10:47:05 +00:00
tags: bootstrap
2020-05-01 13:40:16 +00:00
- name: Populate wp-content folder
block:
2020-05-05 09:08:24 +00:00
- name: "Clear folder {{ site_data_path }}"
2020-05-01 13:40:16 +00:00
file:
2020-05-05 09:08:24 +00:00
path: "{{ site_data_path }}"
2020-05-01 13:40:16 +00:00
state: absent
- name: "Download Wordpress v{{ wordpress.version }} archive"
get_url:
url: "https://wordpress.org/wordpress-{{ wordpress.version }}.tar.gz"
dest: "/tmp/wordpress.tgz"
checksum: "{{ wordpress.checksum }}"
- name: "Extract Wordpress v{{ wordpress.version }} archive"
unarchive:
src: "/tmp/wordpress.tgz"
dest: /tmp
remote_src: yes
- name: "Copy wp-content folder to destination"
copy:
src: /tmp/wordpress/wp-content/
2020-05-05 09:08:24 +00:00
dest: "{{ site_data_path }}"
2020-05-01 13:40:16 +00:00
remote_src: yes
# group: www-data
# mode: '0660'
# directory_mode: '0770'
- name: Set proper access rights to wp-content tree
file:
2020-05-05 09:08:24 +00:00
path: "{{ site_data_path }}"
2020-05-01 13:40:16 +00:00
state: directory
recurse: yes
group: www-data
mode: "u=rwX,g=rwX,o="
- name: "Remove downloaded content"
file:
path: "{{ toremove }}"
state: absent
loop:
- /tmp/wordpress.tgz
- /tmp/wordpress
loop_control:
loop_var: toremove
when: wpcontent.stat.exists is not defined or wpcontent.stat.exists == False
tags: bootstrap
2020-05-01 13:40:16 +00:00
2020-05-01 13:40:16 +00:00
####################
# Render templates #
####################
- name: "Render templates"
import_tasks: render.yml
tags: render
2020-04-01 07:41:12 +00:00
2020-05-01 13:40:16 +00:00
#######################
# MySQL configuration #
#######################
- name: "Setup MySQL"
import_tasks: mysql.yml
2020-04-29 15:15:49 +00:00
tags: mysql
2020-05-05 09:08:24 +00:00
#################
# Setup backups #
#################
- name: "Setup backups"
import_tasks: backup.yml
tags: backup
###################
# SSL certificate #
###################
# - name: Create Let's Encrypt certificate
# This seems hard, see:
# https://docs.ansible.com/ansible/latest/modules/acme_certificate_module.html#acme-certificate-module
# https://www.digitalocean.com/community/tutorials/how-to-acquire-a-let-s-encrypt-certificate-using-ansible-on-ubuntu-18-04
# Maybe using shell directly? e.g.
# certbot certonly --webroot -w /var/www/letsencrypt -d <url>