2019-01-02 05:04:01 +00:00
|
|
|
# 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
|
2020-01-21 03:27:13 +00:00
|
|
|
apt:
|
|
|
|
name: python-pymysql
|
|
|
|
state: present
|
2019-01-02 05:04:01 +00:00
|
|
|
|
|
|
|
- name: Create Database
|
2020-01-21 03:27:13 +00:00
|
|
|
mysql_db:
|
2019-01-02 05:04:01 +00:00
|
|
|
name: "{{ wp_db_name }}"
|
|
|
|
state: present
|
|
|
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
|
|
|
|
|
|
|
- name: Create Database User
|
2020-01-21 03:27:13 +00:00
|
|
|
mysql_user:
|
2019-01-02 05:04:01 +00:00
|
|
|
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]
|
2019-03-14 02:22:50 +00:00
|
|
|
owner: "www-data"
|
|
|
|
group: "www-data"
|
2019-01-02 05:04:01 +00:00
|
|
|
remote_src: yes
|
|
|
|
|
2020-01-23 04:31:54 +00:00
|
|
|
- name: Stat WordPress Salts
|
|
|
|
stat:
|
|
|
|
path: "{{ wp_dir }}/salts.txt"
|
|
|
|
register: salts
|
|
|
|
|
2019-01-02 05:04:01 +00:00
|
|
|
- name: Generate Keys and Salts
|
2020-01-21 03:27:13 +00:00
|
|
|
get_url:
|
2019-01-02 05:04:01 +00:00
|
|
|
url: https://api.wordpress.org/secret-key/1.1/salt/
|
|
|
|
dest: "{{ wp_dir }}/salts.txt"
|
2020-01-23 04:31:54 +00:00
|
|
|
when: not salts.stat.exists
|
2019-01-02 05:04:01 +00:00
|
|
|
|
|
|
|
- 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"
|
2019-03-14 02:22:50 +00:00
|
|
|
owner: "www-data"
|
|
|
|
group: "www-data"
|
2019-01-02 05:04:01 +00:00
|
|
|
|
|
|
|
- name: Apply Apache Configuration
|
|
|
|
template:
|
|
|
|
src: wordpress.conf.j2
|
|
|
|
dest: /etc/apache2/sites-available/{{ wp_domain }}.conf
|
|
|
|
notify: Reload Apache2
|
|
|
|
|
2019-03-14 02:22:50 +00:00
|
|
|
- name: Enable Apache Module rewrite
|
|
|
|
apache2_module:
|
|
|
|
state: present
|
|
|
|
name: rewrite
|
|
|
|
notify: Reload Apache2
|
|
|
|
|
2019-01-02 05:04:01 +00:00
|
|
|
- name: Enable Apache Website
|
|
|
|
shell: a2ensite {{ wp_domain }}
|
|
|
|
args:
|
|
|
|
creates: /etc/apache2/sites-enabled/{{ wp_domain }}.conf
|
|
|
|
notify: Reload Apache2
|
|
|
|
|