Skip to content

Instantly share code, notes, and snippets.

@klenwell
Last active August 29, 2015 13:57
Show Gist options
  • Save klenwell/9860685 to your computer and use it in GitHub Desktop.
Save klenwell/9860685 to your computer and use it in GitHub Desktop.
Sets up Wikka repository locally to test fresh installation

This playbook automates local installation of a Wikka wiki webserver:

ansible-playbook -v -i .dev/deploy/dev .dev/deploy/dev_install.yml --connection=local
# Ansible inventory file
[locally]
127.0.0.1
#
# dev_install.yml
# Github Gist: https://gist.github.com/klenwell/9860685
#
# Clones wikka from github, install locally, and configures to test fresh install.
#
# WARNING
# This is designed to create a temporary directory that will be rebuilt each time
# this script is run. Make sure you settings are safe and won't delete anything
# important. (They shouldn't by default.)
#
# USAGE
# ansible-playbook -v -i .dev/deploy/dev .dev/deploy/dev_install.yml --connection=local
#
# BEFORE YOU RUN THIS:
# 1. You need an inventory file at the path specified in -i option. Find an example
# here: https://gist.github.com/klenwell/9860685#file-dev
#
# 2. You need a wikka.config.php template file for wikka.src.config. Find an
# example here: https://gist.github.com/klenwell/9860685#file-wikka-config-php-install-j2
#
# 3. Find the PLAYBOOK VARS section below and put in the correct settings. Also set
# user at top of playbook.
#
# 4. You need to install Python mysqldb module. On Debian/Ubuntu, you can install
# with pip. (See http://stackoverflow.com/q/5178292/1093087):
#
# $ sudo apt-get install libmysqlclient-dev
# $ sudo pip install mysql-python
#
#
# The Playbook!
#
- name: Configure wikka to test fresh install
sudo: no
hosts: locally
gather_facts: false
user: LOCAL_USER
#
# PLAYBOOK VARS
#
vars:
wikka:
install:
dir: wikka-tmp-install
db_name: wikka_tmp_install
src:
config: local/wikka.config.php-install.j2
database:
user: MYSQL_USER
pass: MYSQL_PASS
github:
repo: https://github.com/klenwell/WikkaWiki.git
branch: x1D5dQDA-refactor-install-process
tasks:
- name: Clear existing project dir
file:
path=/tmp/{{ wikka.install.dir }}
state=absent
- name: Clone github repository
git:
repo={{ github.repo }}
dest=/tmp/{{ wikka.install.dir }}
version={{ github.branch }}
- name: Delete and recreate empty test database
mysql_db:
db={{ wikka.install.db_name }}
state=absent
login_user={{ database.user }}
login_password={{ database.pass }}
- mysql_db:
db={{ wikka.install.db_name }}
state=present
login_user={{ database.user }}
login_password={{ database.pass }}
- name: Create initial config file from scratch
template:
src={{ wikka.src.config }}
dest=/tmp/{{ wikka.install.dir }}/wikka.config.php
- name: Link directory to /var/www
file:
src=/tmp/{{ wikka.install.dir }}
path=/var/www/{{ wikka.install.dir }}
state=link
- name: Cleanup
debug: 'msg="Setup complete. In your browser, go to http://localhost/{{ wikka.install.dir }}"'
<?php
/**
* WikkaWiki Configuration File
* Default settings for install testing
*/
$wakkaConfig = array(
'wakka_version' => '0',
'admin_email' => '[email protected]',
'admin_users' => 'WikkaInstallAdmin',
'mysql_host' => 'localhost',
'mysql_database' => '{{ wikka.install.db_name }}',
'mysql_password' => '{{ database.pass }}',
'mysql_user' => '{{ database.user }}'
);
@klenwell
Copy link
Author

Simple Ansible playbook to clone Wikka locally from my Githhub repository and quickly install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment