Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Commit

Permalink
Add Wordpress files
Browse files Browse the repository at this point in the history
Add files for actually installing and configuring Wordpress.
What was there before was just the Nginx and PHP configuration.

Also:
- Add "egesto" dependency theme, which is required by our custom
  Wordpress theme.
- Add proxy cache clearing for Wordpress deployment
  • Loading branch information
Mark Breedlove committed Oct 8, 2014
1 parent ac423ed commit 4edca08
Show file tree
Hide file tree
Showing 14 changed files with 358 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Vagrantfile.dist
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# but don't modify the mount point.
# webapp.vm.synced_folder "../frontend", "/frontend_dev"
# webapp.vm.synced_folder "../platform", "/api_dev"
# webapp.vm.synced_folder "../wordpress-plugins", "/wordpress-plugins"
# webapp.vm.synced_folder "../frontend-wp-theme", "/wordpress-theme"
end

end
13 changes: 13 additions & 0 deletions ansible/roles/wordpress/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

do_wordpress: false
wp_theme_use_local_source: false

wp_auth_key: "bLGFW(pi3@m&[HtB4-Utj2+%bwntE kRwex=I#+_G>-mkJVv[X#XYVv9Sg7OV|+j"
wp_secure_auth_key: "iB/:bGNU|7-|4!@u~69:lPWqD)om*g?G=%?nJ,W+:zbet{,Wzm-_aQN^,/DeALm|"
wp_logged_in_key: "BGr[{r9bj_x&WNmz/tBUwHhS-(b$+|R)@q<wv<[Pe,p)L>H]:8kux2dY^wTavO^S"
wp_nonce_key: "&b!~D9|&-V|3q~yVn{<#IFft$)8rKeJ>RoNQ]ig&w!fQ9WDeAx%=Ci` 8pjW6Y`|"
wp_auth_salt: ")=d{XACbc/^+q<,r`L`q]R$1rA)!D{XgG^kmTAI#f3h`-yF>&U#/]);sN;EP&@tQ"
wp_secure_auth_salt: "|6lyuZV=2s~LL]w91$*xtcOm(ZeaL,E^Q$-L{G: IgMp-T6| $aij}+],x7+4:~f"
wp_logged_in_salt: "Z?.WWr]I;Bu;^!=P ]BK?<x[%lNL*47MWa4=+)4SP7aV21;$<J!g{0m*Q;=3s&q8"
wp_nonce_salt: "-DV|s.W8/BL^ZP>tz.d2b<KZ9}PxQg.lB13i+)MAvr[+c3+bqbl.OKQA&SZNe*+*"
33 changes: 33 additions & 0 deletions ansible/roles/wordpress/files/build_wordpress_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Runs as 'dpla' user

rsync=/usr/bin/rsync

# Copy local plugins directory into build directory
$rsync -ruptl --checksum --delete --delay-updates \
--exclude '.git'
/wordpress-plugins/ /home/dpla/wordpress/wp-content/plugins

# Copy themes directory into build directory
$rsync -ruptl --checksum --delete --delay-updates \
--exclude '.git'
/wordpress-theme/ \
/home/dpla/wordpress/wp-content/themes/berkman_custom_dpla

# Check our our theme's dependency, "egesto". It does not seem
# worth it to have this pulled in from a local directory, so it's
# pulled from a private repository.
eval `ssh-agent`
ssh-add $HOME/git_private_key
if [ -d "$HOME/frontend-wp-egesto" ]; then
cd $HOME/frontend-wp-egesto
git pull || exit 1
else
cd $HOME
git clone [email protected]:dpla/frontend-wp-egesto.git frontend-wp-egesto \
|| exit 1
fi
$rsync -ruptoglv --delete --checksum \
--exclude '.git' \
$HOME/frontend-wp-egesto/ $HOME/wordpress/wp-content/themes/egesto
54 changes: 54 additions & 0 deletions ansible/roles/wordpress/files/build_wordpress_remote.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

# Runs as 'dpla' user

plugins_branch=${1:-master}
rsync=/usr/bin/rsync

eval `ssh-agent`
ssh-add $HOME/git_private_key

# Check out wordpress plugins and transfer into build directory.
cd $HOME
if [ -d "$HOME/wordpress-plugins" ]; then
cd $HOME/wordpress-plugins
git checkout $plugins_branch || exit 1
git pull || exit 1
else
git clone [email protected]:dpla/wordpress-plugins.git wordpress-plugins \
|| exit 1
cd $HOME/wordpress-plugins
git checkout $branch || exit 1
fi
$rsync -ruptoglv --delete --checksum \
--exclude '.git' \
$HOME/wordpress-plugins/ $HOME/wordpress/wp-content/plugins

# Check out our theme's dependency theme, "egesto", and transfer
# it into the build directory.
cd $HOME
if [ -d "$HOME/frontend-wp-egesto" ]; then
cd $HOME/frontend-wp-egesto
git pull || exit 1
else
git clone [email protected]:dpla/frontend-wp-egesto.git frontend-wp-egesto \
|| exit 1
fi
$rsync -ruptoglv --delete --checksum \
--exclude '.git' \
$HOME/frontend-wp-egesto/ $HOME/wordpress/wp-content/themes/egesto

# Check out theme and transfer into build directory.
# So far, this only has one branch, master.
cd $HOME
if [ -d "$HOME/wordpress-theme" ]; then
cd $HOME/wordpress-theme
git pull || exit 1
else
git clone [email protected]:dpla/frontend-wp-theme.git wordpress-theme \
|| exit 1
fi
$rsync -ruptoglv --delete --checksum \
--exclude '.git' \
$HOME/wordpress-theme/ $HOME/wordpress/wp-content/themes/berkman_custom_dpla

14 changes: 14 additions & 0 deletions ansible/roles/wordpress/files/sync_new_wordpress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Runs as 'dpla' user

rsync=/usr/bin/rsync

# Sync newly-downloaded Wordpress with build directory

$rsync -ruptl --checksum --delete \
--exclude '.git' \
--exclude 'wp-content/plugins' \
--exclude 'wp-content/themes/berkman_custom_dpla' \
--exclude 'wp-config.php' \
/tmp/wordpress/ /home/dpla/wordpress
7 changes: 7 additions & 0 deletions ansible/roles/wordpress/files/sync_to_siteroot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash


rsync=/usr/bin/rsync

$rsync -ruptolg --checksum --delete --delay-updates \
/home/dpla/wordpress/ /srv/www/wordpress
5 changes: 5 additions & 0 deletions ansible/roles/wordpress/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@

- name: restart php5-fpm
service: name=php5-fpm state=restarted

- name: clear site proxy cache
command: find /var/cache/nginx -type f -delete
delegate_to: "{{ item }}"
with_items: groups.site_proxies
129 changes: 127 additions & 2 deletions ansible/roles/wordpress/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,126 @@
---


# The wordpress_install tasks have to be done the first time around.
# The wordpress_deployment tasks are what you'll usually run if you don't have
# to change the Wordpress version and you've already installed it.

- include_vars: "../vars/{{ level }}.yml"
when: level is defined
tags:
- wordpress
- wordpress_install
- wordpress_deployment


- name: Download Wordpress
get_url: >
url="http://wordpress.org/wordpress-{{ wordpress_version }}.tar.gz"
dest=/tmp/wordpress-{{ wordpress_version}}.tar.gz
mode=0644
when: do_wordpress
tags:
- wordpress
- wordpress_install


- name: Unpack Wordpress
command: >
tar -C /tmp -zxf /tmp/wordpress-{{ wordpress_version }}.tar.gz
when: do_wordpress
tags:
- wordpress
- wordpress_install

- name: Synchronize new Wordpress with build directory
script: sync_new_wordpress.sh
sudo_user: dpla
when: do_wordpress
tags:
- wordpress
- wordpress_install

- name: Remove temporary Wordpress directory
file: path=/tmp/wordpress state=absent
when: do_wordpress
tags:
- wordpress
- wordpress_install

- name: Prep for build with private repo (git)
when: do_wordpress and not wp_theme_use_local_source
copy: >
src={{ github_private_key_path | default("~/.ssh/id_rsa") }}
dest=/home/dpla/git_private_key
owner=dpla group=dpla mode=0600
tags:
- wordpress
- wordpress_install
- wordpress_deployment



- name: Build Wordpress (local)
when: do_wordpress and wp_theme_use_local_source
sudo_user: dpla
script: build_wordpress_local.sh
tags:
- wordpress
- wordpress_install
- wordpress_deployment

- name: Build Wordpress (remote)
when: do_wordpress and not wp_theme_use_local_source
sudo_user: dpla
script: build_wordpress_remote.sh master
tags:
- wordpress
- wordpress_install
- wordpress_deployment


- name: Ensure existence of site root
file: path=/srv/www/wordpress state=directory owner=dpla group=dpla mode=0755
tags:
- wordpress
- wordpress_install
- wordpress_deployment

- name: Sync installation to site root
script: sync_to_siteroot.sh
sudo_user: dpla
when: do_wordpress
notify:
- clear site proxy cache
tags:
- wordpress
- wordpress_install
- wordpress_deployment

- name: Ensure state of uploads directory
file: >
path=/srv/www/wordpress/wp-content/uploads state=directory
owner=www-data group=www-data mode=0755
when: do_wordpress
tags:
- wordpress
- wordpress_install
- wordpress_deployment

- name: Ensure state of Wordpress configuration file
template: >
src=wp-config.php.j2 dest=/srv/www/wordpress/wp-config.php
owner=dpla group=www-data mode=0640
when: do_wordpress
notify:
- restart php5-fpm
- clear site proxy cache
tags:
- wordpress
- wordpress_install
- wordpress_deployment


- name: Update php-fpm pool for Wordpress
template: >
src=etc_php5_fpm_pool.d_wp.conf.j2
Expand All @@ -16,7 +137,9 @@
src=etc_nginx_sites_available_wordpress.j2
dest="/etc/nginx/sites-available/wordpress"
owner=root group=root mode=0644
notify: restart nginx
notify:
- restart nginx
- clear site proxy cache
tags:
- wordpress
- nginx
Expand All @@ -27,7 +150,9 @@
src="/etc/nginx/sites-available/wordpress"
dest="/etc/nginx/sites-enabled/wordpress"
state=link owner=root group=root
notify: restart nginx
notify:
- restart nginx
- clear site proxy cache
tags:
- wordpress
- nginx
Expand Down
89 changes: 89 additions & 0 deletions ansible/roles/wordpress/templates/wp-config.php.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

define('WP_HOME', 'http://{{ frontend_hostname }}/info');
define('WP_SITEURL', 'http://{{ frontend_hostname }}/info');

/** The name of the database for WordPress */
define('DB_NAME', 'dpla_wp');

/** MySQL database username */
define('DB_USER', 'dpla_wordpress');

/** MySQL database password */
{% for u in mysql_users if u.name == "dpla_wordpress" %}
define('DB_PASSWORD', '{{ u.password }}');
{% endfor %}

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

define('COOKIEPATH', '/info/');
define('SITECOOKIEPATH', '/info/');

/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
define('AUTH_KEY', '{{ wp_auth_key }}');
define('SECURE_AUTH_KEY', '{{ wp_secure_auth_key }}');
define('LOGGED_IN_KEY', '{{ wp_logged_in_key }}');
define('NONCE_KEY', '{{ wp_nonce_key }}');
define('AUTH_SALT', '{{ wp_auth_salt }}');
define('SECURE_AUTH_SALT', '{{ wp_secure_auth_salt }}');
define('LOGGED_IN_SALT', '{{ wp_logged_in_salt }}');
define('NONCE_SALT', '{{ wp_nonce_salt }}');

/**#@-*/

/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';

/**
* WordPress Localized Language, defaults to English.
*
* Change this to localize WordPress. A corresponding MO file for the chosen
* language must be installed to wp-content/languages. For example, install
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
* language support.
*/
define('WPLANG', '');

/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
{% set debug_value = 'true' if webapp_debug == true else 'false' %}
define('WP_DEBUG', {{ debug_value }});
define('WP_DEBUG_LOG', {{ debug_value }});
define('WP_DEBUG_DISPLAY', {{ debug_value }});

define('DPLA_API_KEY', '{{ api_key }}');
define('DPLA_FRONTEND_URL', 'http://{{ frontend_hostname }}/');
define('DPLA_API_URL', 'http://{{ api_hostname }}/v2');


/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
3 changes: 3 additions & 0 deletions ansible/roles/wordpress/vars/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
staging.yml
production.yml
development.yml
6 changes: 6 additions & 0 deletions ansible/roles/wordpress/vars/development.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

# Uncomment this to have Wordpress installed
# This will not be useful unless you have access to the private Git
# repositories.
# do_wordpress: true
3 changes: 3 additions & 0 deletions ansible/roles/wordpress/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

wordpress_version: 3.9.1
Loading

0 comments on commit 4edca08

Please sign in to comment.