Ansible orchestration of php web servers
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
files
group_vars
roles/common/tasks
.gitignore
README.md
ROLES_FILE
Vagrantfile
ansible.cfg
deploy.yml
hosts
mysql_snapshot_create.yml
mysql_snapshot_restore.yml
requirements.txt
site.yml

README.md

my-ansible

Ansible orchestration of my web development environment

+--------------------+   +--------------------+   +--------------------+
|                    |   |                    |   |                    |
|       mysql        |   |   package_server   |   |        web         |
|                    |   |                    |   |                    |
+--------------------+   +--------------------+   +--------------------+

ansible roles

Installation

Clone the repository

git clone git://github.com/EHER/my-ansible.git
cd my-ansible

Use pip to install dependencies (virtualenv is also recommended)

pip install -r dependencies.txt

Install aditional ansible roles

ansible-galaxy install -fr ROLES_FILE

Configuration

Use the current vagrant configuration to power up a new virtual machine

vagrant up

Or add your own configurations into ansible.cfg and hosts file.

vim ansible.cfg
# ansible.cfg
[defaults]
hostfile = hosts
roles_path = roles
roles_file = ROLES_FILE
module_name = command
remote_user = vagrant
private_key_file = ~/.vagrant.d/insecure_private_key

Add your machines to hosts file:

vim hosts
# hosts
[mysql]
192.168.56.101

[package_server]
192.168.56.101

[web]
192.168.56.101

Use the ping module to test your configuration

ansible all -m ping

Using

Run the main playbook

ansible-playbook site.yml

You can also run just some part of the playbook usig tags

ansible-playbook site.yml --tags web

To deploy web projects to the latest version run the deploy playbook

ansible-playbook deploy.yml

Useful Commands

Add your private key to git user

cat ~/.ssh/id_rsa.pub >> files/authorized_keys

Get Vagrant private_key_file

vagrant ssh-config | grep IdentityFile  | awk '{print $2}'

Get Vagrant remote_user

vagrant ssh-config | grep 'User ' | awk '{print $2}'