# vim:ft=ansible:
#
---
- hosts: all
become: yes
tasks:
- name: install wp-cli
shell: curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
args:
creates: /usr/local/bin/wp
- name: config wp-cli
shell: php wp-cli.phar --info --allow-root
args:
creates: /usr/local/bin/wp
- name: make wp-cli writable
shell: chmod +x wp-cli.phar
args:
creates: /usr/local/bin/wp
- name: move wp-cli to local bin
shell: sudo mv wp-cli.phar /usr/local/bin/wp
args:
creates: /usr/local/bin/wp
- name: setup wordpress vhost config
copy:
src=myapp.conf
dest=/etc/apache2/sites-available/myapp.conf
owner=root
mode=0644
force=no
- name: set ServerName for wordpress vhost
replace:
dest=/etc/apache2/sites-available/myapp.conf
regexp="{HOSTNAME}"
replace="www.{{hostname}}"
backup=no
- name: set webroot for apache vhost
replace:
dest=/etc/apache2/sites-available/myapp.conf
regexp="{WEBROOT}"
replace="/var/www/myapp/www"
backup=no
- name: enable the myapp virtual host
shell: sudo a2ensite wordpress
- name: create 'myapp' database if it doesn't exist
shell: mysql -uroot -e "CREATE DATABASE IF NOT EXISTS myapp"
- name: setup wp-config.php
shell: sudo wp core config --path=/var/www/myapp/www --dbname=myapp --dbuser=root --allow-root
args:
creates: /var/www/myapp/www/wp-config.php
- name: add WP_ENV and APP_URL to wp-config
lineinfile:
dest=/var/www/myapp/www/wp-config.php
regexp='^WP_ENV'
line='\n\ndefine("WP_ENV", "development");\ndefine("APP_URL","{{hostname}}");'
insertafter='<\?php'
state=absent
notify: restart apache
- name: install wp build
shell: sudo wp core install --path=/var/www/myapp/www --url="http://www.myapp.dev" --title="Invent Value" --admin_user="admin" --admin_password="myapp" --admin_email="admin@myapp.dev" --allow-root
- name: enable and activate myapp theme
shell: sudo wp theme activate myapp --path=/var/www/myapp/www --allow-root
notify: restart apache