Tag Archives: ansible

Playing with GaleraDB

Using vagrant and playbook from https://github.com/cocoy/ansible-galera/tests/galera.yml

$ mkdir galera-test
$ cd galera-test ; mkdir roles;  cd roles 
$ git checkout https://github.com/cocoy/ansible-galera.git 
$ cd ..
$ cp roles/ansible-galera/tests/* .

Here’s the final galera-test directory contents:

Vagrantfile     
ansible.cfg     
galera.yml      
roles/
  - ansible-galera

To run:

 $ vagrant up galera1
 $ vagrant up galera2
 $ vagrant up galera3

References:
https://www.percona.com/blog/2014/11/17/typical-misconceptions-on-galera-for-mysql/
http://www.severalnines.com/blog/9-tips-going-production-galera-cluster-mysql
http://www.severalnines.com/clustercontrol-mysql-galera-tutorial
https://mariadb.com/kb/en/mariadb/about-xtradb/
https://www.percona.com/blog/2013/05/14/is-synchronous-replication-right-for-your-app/
https://mariadb.com/kb/en/mariadb/mariadb-vs-mysql-features/
https://www.percona.com/blog/2014/09/01/galera-replication-how-to-recover-a-pxc-cluster/

Vagrant + Ansible provisioning add roles using Ansible Galaxy

This guide will show how to setup Nginx+php5-fpm development VM’s using Vagrant with Ansible as provisioner with added bonus using Ansible Galaxy for roles.

Requirements:
Ubuntu 12.04 or higher
Virtualbox 4.14+
Vagrant 1.4.3
Ansible 1.4+

Setup Ansible using VirtualEnv to isolate working environment:

$ virtualenv ansi_env
$ cd ansi_env
$ source bin/activate
$ pip install ansible
 

Assuming Virtualbox and vagrant are already installed:

$ mkdir ~/vagrant 
$ cd ~/vagrant 
$ vagrant box add precise64 http://files.vagrantup.com/precise64.box
$ git clone https://github.com/cocoy/vagrant_ansible.git 
$ cd vagrant_ansible
$ vagrant up web 

The commands will launch vagrant web vm with simply nginx installed.
The nice part is using Ansible Galaxy by adding more roles to speedup environment setup.

$ export ANSIBLE_ROLES_PATH=playbooks/roles/
$  ansible-galaxy install nbz4live.php-fpm

Edit playbook/web.xml under roles add the line below:

 ---
 - hosts: all
   roles:
    - common 
    - nginx
    - nbz4live.php-fpm

Now let’s provision the web server with php-fpm added:

$ vagrant provision web 
 

Now we can see nginx + php5-fpm installed. Let’s try adding site config and index.php then.

 ---
 - hosts: all
   roles:
    - common 
    - nginx
    - nbz4live.php-fpm
    - nginx-fpm-setup 

This time just run ansible provision web and hit localhost:8080 on your browser.
In summary Ansible Galaxy can ease our setup and ready to use Ansible roles!