1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00
iiab/roles/wordpress/tasks/install.yml

150 lines
5 KiB
YAML
Raw Normal View History

2017-11-15 16:03:08 +00:00
# IF YOU NEED TO REINSTALL FROM /opt/iiab/downloads/wordpress.tar.gz
# TO /library/wordpress DURING YOUR NEXT RUN OF "./runtags wordpress" OR
# "./iiab-install" THEN YOU FIRST NEED TO:
#
# - "mv /library/wordpress /library/wordpress.old" (MUST)
# - back up then drop the database (RECOMMENDED)
#
# REASON: "keep_newer: yes" below tries to preserves WordPress's self-upgrades
# & security enhancements within /library/wordpress, that can occur without
# warning when WordPress is online, since WordPress ~4.8 especially.
#
# Such "emergency" reinstalls from /opt/iiab/downloads/wordpress.tar.gz to
# /library/wordpress should also work offline.
- name: Download the latest WordPress software
get_url:
url: "{{ wordpress_download_base_url }}/{{ wordpress_src }}"
dest: "{{ downloads_dir }}"
# force: yes
# backup: yes
2017-09-21 00:13:18 +00:00
register: wp_download_output
when: internet_available
2017-05-27 18:09:50 +00:00
2017-11-15 16:03:08 +00:00
- name: Create link /opt/iiab/downloads/wordpress.tar.gz pointing to {{ wp_download_output.dest }}
file:
src: "{{ wp_download_output.dest }}"
dest: "{{ downloads_dir }}/wordpress.tar.gz"
state: link
when: wp_download_output.dest is defined
- name: Check if /opt/iiab/downloads/wordpress.tar.gz link exists
stat:
path: "{{ downloads_dir }}/wordpress.tar.gz"
register: wp_link
2017-11-15 16:47:41 +00:00
- name: FAIL (force Ansible to exit) IF /opt/iiab/downloads/wordpress.tar.gz doesn't exist
2017-11-15 16:03:08 +00:00
fail:
msg: "{{ downloads_dir }}/wordpress.tar.gz is REQUIRED in order to install WordPress."
when: not wp_link.stat.exists
- name: "Unpack /opt/iiab/downloads/wordpress.tar.gz to permanent location /library/wordpress - owner: root, group: {{ apache_user }}, mode: 0664, keep_newer: yes"
2017-11-15 16:03:08 +00:00
unarchive:
src: "{{ downloads_dir }}/wordpress.tar.gz"
dest: "{{ wp_install_path }}"
2017-11-15 16:47:41 +00:00
owner: root
group: "{{ apache_user }}"
mode: 0664
2017-11-15 16:03:08 +00:00
keep_newer: yes
2017-05-27 18:09:50 +00:00
2017-11-15 16:03:08 +00:00
# - name: Rename /library/wordpress* to /library/wordpress
# shell: if [ ! -d {{ wp_abs_path }} ]; then mv {{ wp_abs_path }}* {{ wp_abs_path }}; fi
2017-05-27 18:09:50 +00:00
2017-11-15 16:47:41 +00:00
#- name: Make Apache owner and group, 1st pass permissions set to 0664
# file: path={{ wp_abs_path }}
# recurse=yes
# owner=root
# group={{ apache_user }}
# mode=0664
# state=directory
2017-05-27 18:09:50 +00:00
- name: Make /library/wordpress directories 775 so Apache can traverse and write (most files remain 0664)
command: "/usr/bin/find {{ wp_abs_path }} -type d -exec chmod 775 {} +"
2017-05-27 18:09:50 +00:00
- name: Copy wp salt values
copy: src=wp-keys.php.BAK
dest={{ wp_abs_path }}/wp-keys.php.BAK
owner=root
group={{ apache_user }}
2017-05-27 18:09:50 +00:00
mode=0640
# Fetch random salts for WordPress config into wp-keys.php file by generating script and running
- name: Create wp salt script
template: src=get-iiab-wp-salts.j2
dest=/tmp/get-iiab-wp-salts
2017-05-27 18:09:50 +00:00
owner=root
group=root
mode=0700
- name: Run wp salt script to create /library/wordpress/wp-keys.php
command: /tmp/get-iiab-wp-salts
2017-05-27 18:09:50 +00:00
- name: Cleanup - remove wp salt script
file: path=/tmp/get-iiab-wp-salts
2017-05-27 18:09:50 +00:00
state=absent
2017-11-08 06:14:09 +00:00
- name: MySQL database needs to be running if we are trying to create a new db
2017-05-27 18:09:50 +00:00
service: state=started
name='{{ mysql_service }}'
2017-11-08 06:14:09 +00:00
- name: Create MySQL wordpress database
2017-05-27 18:09:50 +00:00
mysql_db: name={{ wp_db_name }}
state=present
2017-11-08 06:14:09 +00:00
- name: Create MySQL wordpress database user
2017-05-27 18:09:50 +00:00
mysql_user: name={{ wp_db_user }}
password={{ wp_db_user_password }}
priv={{ wp_db_name }}.*:ALL,GRANT
state=present
- name: Copy WordPress config file
template: src=wp-config.php.j2
dest={{ wp_abs_path }}/wp-config.php
owner=root
group={{ apache_user }}
2017-05-31 01:48:48 +00:00
mode=0660
2017-05-27 18:09:50 +00:00
- name: Copy WordPress httpd conf file
template: src=wordpress.conf.j2
dest=/etc/{{ apache_config_dir }}/wordpress.conf
2017-11-08 06:14:09 +00:00
- name: Enable httpd conf file if we are disabled (debuntu)
2017-05-27 18:09:50 +00:00
file: path=/etc/apache2/sites-enabled/wordpress.conf
src=/etc/apache2/sites-available/wordpress.conf
state=link
2017-05-27 23:10:45 +00:00
when: wordpress_enabled and is_debuntu
2017-05-27 18:09:50 +00:00
2017-11-08 06:14:09 +00:00
- name: Remove httpd conf file if we are disabled (OS's other than debuntu)
2017-05-27 18:09:50 +00:00
file: path=/etc/apache2/sites-enabled/wordpress.conf
state=absent
2017-05-27 23:10:45 +00:00
when: not wordpress_enabled and is_debuntu
2017-05-27 18:09:50 +00:00
2017-11-08 06:14:09 +00:00
- name: Restart Apache, so it picks up the new aliases
2017-05-27 18:09:50 +00:00
service: name={{ apache_service }} state=restarted
2017-11-27 01:05:57 +00:00
- name: Add 'wordpress' to list of services at /etc/iiab/iiab.ini
2017-05-27 18:09:50 +00:00
ini_file: dest='{{ service_filelist }}'
section=wordpress
option='{{ item.option }}'
value='{{ item.value }}'
with_items:
- option: name
value: wordpress
- option: description
value: '"WordPress is a blog and web site management application."'
- option: wordpress_src
value: "{{ wordpress_src }}"
- option: wp_abs_path
value: "{{ wp_abs_path }}"
- option: wp_db_name
value: "{{ wp_db_name }}"
- option: wp_db_user
value: "{{ wp_db_user }}"
- option: wp_url
value: "{{ wp_url }}"
- option: wp_full_url
value: "{{ wp_full_url }}"
- option: wordpress_enabled
value: "{{ wordpress_enabled }}"