85 lines
2.3 KiB
YAML
85 lines
2.3 KiB
YAML
|
# Copyright (C) 2019 Free I.T. Athens
|
||
|
#
|
||
|
# This program is free software: you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU General Public License as published by
|
||
|
# the Free Software Foundation, version 3 of the License.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
|
||
|
|
||
|
# PyMySQL or MySQL-python is required for database tasks
|
||
|
- name: Install MySQL Support for Python
|
||
|
apt: name=python-pymysql state=present
|
||
|
|
||
|
- name: Create Database
|
||
|
mysql_db:
|
||
|
name: "{{ wp_db_name }}"
|
||
|
state: present
|
||
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||
|
|
||
|
- name: Create Database User
|
||
|
mysql_user:
|
||
|
name: "{{ wp_db_user }}"
|
||
|
password: "{{ wp_db_pass }}"
|
||
|
priv: "{{ wp_db_name }}.*:ALL,GRANT"
|
||
|
state: present
|
||
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||
|
|
||
|
- name: Create Public HTML Directory
|
||
|
file:
|
||
|
path: "{{ wp_dir }}/public_html"
|
||
|
state: directory
|
||
|
|
||
|
- name: Create Logs Directory
|
||
|
file:
|
||
|
path: "{{ wp_dir }}/logs"
|
||
|
state: directory
|
||
|
|
||
|
- name: Download WordPress
|
||
|
get_url:
|
||
|
url: https://wordpress.org/wordpress-{{ wp_version }}.tar.gz
|
||
|
dest: /tmp/wordpress-{{ wp_version }}.tar.gz
|
||
|
checksum: sha1:{{ wp_sha1_hash }}
|
||
|
|
||
|
- name: Extract WordPress
|
||
|
unarchive:
|
||
|
src: /tmp/wordpress-{{ wp_version }}.tar.gz
|
||
|
dest: "{{ wp_dir }}/public_html"
|
||
|
extra_opts: [--strip-components=1]
|
||
|
remote_src: yes
|
||
|
|
||
|
- name: Generate Keys and Salts
|
||
|
get_url:
|
||
|
url: https://api.wordpress.org/secret-key/1.1/salt/
|
||
|
dest: "{{ wp_dir }}/salts.txt"
|
||
|
|
||
|
- name: Grab Keys and Salts
|
||
|
slurp: src="{{ wp_dir }}/salts.txt"
|
||
|
register: salts
|
||
|
|
||
|
- name: Apply WordPress Configuration
|
||
|
template:
|
||
|
src: wp-config.php.j2
|
||
|
dest: "{{ wp_dir }}/public_html/wp-config.php"
|
||
|
owner: nobody
|
||
|
group: nogroup
|
||
|
|
||
|
- name: Apply Apache Configuration
|
||
|
template:
|
||
|
src: wordpress.conf.j2
|
||
|
dest: /etc/apache2/sites-available/{{ wp_domain }}.conf
|
||
|
notify: Reload Apache2
|
||
|
|
||
|
- name: Enable Apache Website
|
||
|
shell: a2ensite {{ wp_domain }}
|
||
|
args:
|
||
|
creates: /etc/apache2/sites-enabled/{{ wp_domain }}.conf
|
||
|
notify: Reload Apache2
|
||
|
|