From 4edca085b729d7e274ee44c50f3be8bea79ff48f Mon Sep 17 00:00:00 2001 From: Mark Breedlove Date: Tue, 7 Oct 2014 22:49:09 -0400 Subject: [PATCH] Add Wordpress files 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 --- Vagrantfile.dist | 2 + ansible/roles/wordpress/defaults/main.yml | 13 ++ .../wordpress/files/build_wordpress_local.sh | 33 +++++ .../wordpress/files/build_wordpress_remote.sh | 54 ++++++++ .../wordpress/files/sync_new_wordpress.sh | 14 ++ .../roles/wordpress/files/sync_to_siteroot.sh | 7 + ansible/roles/wordpress/handlers/main.yml | 5 + ansible/roles/wordpress/tasks/main.yml | 129 +++++++++++++++++- .../wordpress/templates/wp-config.php.j2 | 89 ++++++++++++ ansible/roles/wordpress/vars/.gitignore | 3 + .../roles/wordpress/vars/development.yml.dist | 6 + ansible/roles/wordpress/vars/main.yml | 3 + ansible/vars/development.yml.dist | 2 +- ansible/vars/staging.yml.dist | 2 +- 14 files changed, 358 insertions(+), 4 deletions(-) create mode 100644 ansible/roles/wordpress/defaults/main.yml create mode 100644 ansible/roles/wordpress/files/build_wordpress_local.sh create mode 100644 ansible/roles/wordpress/files/build_wordpress_remote.sh create mode 100644 ansible/roles/wordpress/files/sync_new_wordpress.sh create mode 100644 ansible/roles/wordpress/files/sync_to_siteroot.sh create mode 100644 ansible/roles/wordpress/templates/wp-config.php.j2 create mode 100644 ansible/roles/wordpress/vars/.gitignore create mode 100644 ansible/roles/wordpress/vars/development.yml.dist create mode 100644 ansible/roles/wordpress/vars/main.yml diff --git a/Vagrantfile.dist b/Vagrantfile.dist index 27d5b10..17f0e66 100644 --- a/Vagrantfile.dist +++ b/Vagrantfile.dist @@ -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 diff --git a/ansible/roles/wordpress/defaults/main.yml b/ansible/roles/wordpress/defaults/main.yml new file mode 100644 index 0000000..8fe43a6 --- /dev/null +++ b/ansible/roles/wordpress/defaults/main.yml @@ -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)@qH]: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?tz.d2b + 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 @@ -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 @@ -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 diff --git a/ansible/roles/wordpress/templates/wp-config.php.j2 b/ansible/roles/wordpress/templates/wp-config.php.j2 new file mode 100644 index 0000000..d5ea60d --- /dev/null +++ b/ansible/roles/wordpress/templates/wp-config.php.j2 @@ -0,0 +1,89 @@ +