2020-03-31 16:32:13 +00:00
|
|
|
- name: "Create folder {{ sites_path }}/{{ item.slug }}"
|
|
|
|
file:
|
|
|
|
path: "{{ sites_path }}/{{ item.slug }}"
|
|
|
|
state: directory
|
|
|
|
mode: '750'
|
|
|
|
|
|
|
|
- name: Render sexy Dockerfile
|
|
|
|
template:
|
2020-04-27 10:23:53 +00:00
|
|
|
src: wordpress/Dockerfile.j2
|
2020-03-31 16:32:13 +00:00
|
|
|
dest: "{{ sites_path }}/{{ item.slug }}/Dockerfile"
|
|
|
|
|
|
|
|
- name: Render marvelous docker-compose.yml
|
|
|
|
template:
|
2020-04-27 10:23:53 +00:00
|
|
|
src: wordpress/docker-compose.yml.j2
|
2020-04-01 07:41:12 +00:00
|
|
|
dest: "{{ sites_path }}/{{ item.slug }}/docker-compose.yml"
|
|
|
|
|
|
|
|
- name: Render swell nginx site config
|
|
|
|
template:
|
2020-04-27 10:23:53 +00:00
|
|
|
src: wordpress/nginx.j2
|
2020-04-01 07:41:12 +00:00
|
|
|
dest: "/etc/nginx/sites-available/{{ item.url }}"
|
2020-04-01 07:42:30 +00:00
|
|
|
become: yes
|
|
|
|
|
|
|
|
# - 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.
|
2020-04-09 15:29:12 +00:00
|
|
|
# certbot certonly --webroot -w /var/www/letsencrypt -d <url>
|
2020-04-01 07:42:30 +00:00
|
|
|
|
2020-04-09 15:29:12 +00:00
|
|
|
# MySQL equivalent:
|
|
|
|
# create user <user>@<ip> identified by <pass>;
|
|
|
|
# grant all on <db>.* to <user>@<ip>;
|
|
|
|
- name: "Add database user {{ item.mysql_username }}@{{ item.subnet_site_ip }} and grant all privileges on {{ item.mysql_database }}"
|
|
|
|
mysql_user:
|
|
|
|
# Credentials to log in MySQL
|
|
|
|
login_host: localhost
|
|
|
|
login_user: root
|
|
|
|
login_password: "{{ mysql_root_password }}"
|
|
|
|
# Credentials of the new db user
|
|
|
|
host: "{{ item.subnet_site_ip }}"
|
|
|
|
name: "{{ item.mysql_username }}"
|
|
|
|
password: "{{ item.mysql_password }}"
|
|
|
|
# Grants
|
2020-04-27 07:45:07 +00:00
|
|
|
priv: "{{ item.mysql_database }}.*:all"
|
2020-04-09 15:29:12 +00:00
|
|
|
state: present
|