Skip to content

Commit e9203b4

Browse files
committed
Add Vagrant support
1 parent 5713691 commit e9203b4

File tree

10 files changed

+262
-0
lines changed

10 files changed

+262
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/inventory
33
/inventory-*
44
/*.sh
5+
/.vagrant
56

67
# Created by http://gitignore.io
78

Vagrantfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby
3+
4+
# Vagrantfile for ginas project
5+
# https://github.com/drybjed/ginas/
6+
7+
VAGRANTFILE_API_VERSION = '2'
8+
9+
DOMAIN = '.nat.example.com'
10+
NETWORK = '192.168.50.'
11+
NETMASK = '255.255.255.0'
12+
13+
# Source: https://github.com/drybjed/vagrant-debian-wheezy-64/tree/ginas
14+
DEFAULT_BOX = 'debian-wheezy-amd64-netinst'
15+
DEFAULT_BOX_URL = 'https://dl.dropboxusercontent.com/u/55426468/debian-wheezy-amd64-netinst.box'
16+
17+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
18+
19+
config.vm.box = DEFAULT_BOX
20+
config.vm.box_url = DEFAULT_BOX_URL
21+
22+
# LEMP webserver (Linux, nginx, MySQL, PHP5)
23+
config.vm.define :web do |web|
24+
web.vm.hostname = 'web' + DOMAIN
25+
web.vm.network :private_network, ip: NETWORK + "10", :netmask => NETMASK
26+
end
27+
28+
# MySQL server with PHPMyAdmin
29+
config.vm.define :db do |db|
30+
db.vm.hostname = 'db' + DOMAIN
31+
db.vm.network :private_network, ip: NETWORK + "20", :netmask => NETMASK
32+
end
33+
34+
# Ansible Controller
35+
config.vm.define :master do |master|
36+
master.vm.hostname = 'master' + DOMAIN
37+
master.vm.network :private_network, ip: NETWORK + "2", :netmask => NETMASK
38+
39+
config.vm.provision "ansible" do |ansible|
40+
ansible.host_key_checking = false
41+
ansible.inventory_path = "contrib/vagrant/inventory"
42+
ansible.playbook = "playbooks/site.yml"
43+
end
44+
end
45+
46+
end
47+
48+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
# host group: vagrant
3+
4+
# Default deployment user, database
5+
global_vagrant_deploy: 'deploy'
6+
7+
# Default password
8+
global_vagrant_password: 'vagrant'
9+
10+
# vagrant local network
11+
global_vagrant_network: '192.168.50.0/24'
12+
13+
# vagrant manages the network interfaces by itself, so let's get out of the way
14+
interfaces: False
15+
16+
# Enable local mail on each host
17+
postfix: [ 'local' ]
18+
19+
# Default admin accounts (vagrant and your username)
20+
auth_admin_accounts:
21+
- 'vagrant'
22+
- '{{ lookup("env","USER") }}'
23+
24+
# Install additional packages in the vagrant group
25+
apt_group_packages: [ 'mysql-client' ]
26+
27+
# root account configuration - set shell to /bin/zsh and install custom dotfiles
28+
# root should be in it's own hash variable
29+
users_root:
30+
- name: 'root'
31+
shell: '/bin/zsh'
32+
dotfiles: True
33+
34+
# Configuration of default accounts on all hosts in vagrant group
35+
users_default:
36+
37+
# vagrant account
38+
- name: 'vagrant'
39+
shell: '/bin/zsh'
40+
groups: 'admins'
41+
dotfiles: True
42+
sshkeys:
43+
44+
# Insecure vagrant SSH keys from https://github.com/mitchellh/vagrant/tree/master/keys
45+
- 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key'
46+
47+
# Install key from your account just in case
48+
- '{{ lookup("file","~/.ssh/id_rsa.pub") }}'
49+
50+
# Your own account
51+
- name: '{{ lookup("env","USER") }}'
52+
shell: '/bin/zsh'
53+
dotfiles: True
54+
groups: 'admins'
55+
sshkeys:
56+
57+
# SSH key from your account
58+
- '{{ lookup("file","~/.ssh/id_rsa.pub") }}'
59+
60+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
# host: db
3+
4+
# MySQL server with PHPMyAdmin
5+
6+
# Enable PHPMyAdmin
7+
mysql_phpmyadmin: True
8+
9+
# Default password for MySQL 'root' user
10+
mysql_root_password: '{{ global_vagrant_password }}'
11+
12+
# MySQL should listen on all interfaces
13+
# At the moment you might need to restart mysql-server on db for it to happen
14+
# Command: ansible -s -i inventory-vagrant -m service -a 'name=mysql state=restarted' db
15+
mysql_mysqld_bind_address: '0.0.0.0'
16+
17+
# Allow plaintext connections from local vagrant network
18+
mysql_network_allow_list: [ '{{ global_vagrant_network }}' ]
19+
20+
# List of MySQL databases
21+
mysql_databases:
22+
23+
# deploy
24+
- name: '{{ global_vagrant_deploy }}'
25+
26+
# List of MySQL users
27+
mysql_users:
28+
29+
# Your username, from localhost (db)
30+
- name: '{{ lookup("env","USER") }}'
31+
host: 'localhost'
32+
priv: '*.*:ALL,GRANT'
33+
password: '{{ global_vagrant_password }}'
34+
35+
# Your username, from local network
36+
- name: '{{ lookup("env","USER") }}'
37+
host: '192.168.50.%'
38+
priv: '*.*:ALL,GRANT'
39+
password: '{{ global_vagrant_password }}'
40+
41+
# deploy user, from localhost (db)
42+
- name: '{{ global_vagrant_deploy }}'
43+
host: 'localhost'
44+
priv: '{{ global_vagrant_deploy }}.*:ALL'
45+
password: '{{ global_vagrant_password }}'
46+
47+
# deploy user, from local network
48+
- name: '{{ global_vagrant_deploy }}'
49+
host: '192.168.50.%'
50+
priv: '{{ global_vagrant_deploy }}.*:ALL'
51+
password: '{{ global_vagrant_password }}'
52+
53+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
# host: master
3+
4+
# Ansible Controller
5+
6+
# Install additional packages on this host
7+
apt_host_packages: [ 'elinks', 'mutt' ]
8+
9+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# host: web
3+
4+
# LEMP webserver (Linux, nginx, MySQL, PHP5)
5+
6+
# Install additional PHP5 packages (it's good to add them in this variable
7+
# instead of 'apt_*_packages', so that packages depending on php5 are installed
8+
# after their dependencies)
9+
php5_packages: [ 'php5-mysql' ]
10+
11+
# List of additional users configured on this host
12+
users_host_list:
13+
14+
# Deploy user, with git access similar to Heroku cloud
15+
- name: '{{ global_vagrant_deploy }}'
16+
comment: 'Web Deployment'
17+
type: 'git'
18+
sshkeys:
19+
- '{{ lookup("file","~/.ssh/id_rsa.pub") }}'
20+
21+
# List of nginx servers configured on this host
22+
nginx_servers:
23+
- '{{ nginx_default_server }}'
24+
25+
# Default nginx server with custom configuration
26+
nginx_default_server:
27+
enabled: True
28+
default: True
29+
30+
# Enable userdir support, you can define one git repository as "userdir" and
31+
# it will be available as http://hostname/~deploy/
32+
# No PHP5 support though, just plain HTML/CSS
33+
userdir: True
34+
root: '/srv/users/{{ global_vagrant_deploy }}/sites/{{ ansible_hostname }}.{{ ansible_domain }}/public'
35+
upstream_php5: 'php5_www-data'
36+
37+

contrib/vagrant/inventory/hosts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Default 'inventory/hosts' file for vagrant environment
2+
3+
# Host machine needs to be in the inventory for 'encfs' and 'secret' roles to
4+
# work, otherwise it should be harmless
5+
localhost ansible_connection=local
6+
7+
# Hosts defined in the Vagrantfile
8+
[vagrant]
9+
master ansible_ssh_host=192.168.50.2 ansible_ssh_user=vagrant ansible_ssh_private_key_file=contrib/vagrant/ssh/id_rsa_insecure
10+
web ansible_ssh_host=192.168.50.10 ansible_ssh_user=vagrant ansible_ssh_private_key_file=contrib/vagrant/ssh/id_rsa_insecure
11+
db ansible_ssh_host=192.168.50.20 ansible_ssh_user=vagrant ansible_ssh_private_key_file=contrib/vagrant/ssh/id_rsa_insecure
12+
13+
# Hosts with installed nginx webserver
14+
[ginas_nginx]
15+
web
16+
17+
# Hosts with installed PHP5
18+
[ginas_php]
19+
web
20+
21+
# Hosts with installed MySQL database
22+
[ginas_mysql]
23+
db
24+
25+

contrib/vagrant/ssh/id_rsa_insecure

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-----BEGIN RSA PRIVATE KEY-----
2+
MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI
3+
w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP
4+
kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2
5+
hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO
6+
Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW
7+
yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd
8+
ELs4jJsdyky+ewdZeNds5tjcnHU5zUYE25K+ffJED9qUWICcLZDc81TGWjHyAqD1
9+
Bw7XpgUwFgeUJwUlzQurAv+/ySnxiwuaGJfhFM1CaQHzfXphgVml+fZUvnJUTvzf
10+
TK2Lg6EdbUE9TarUlBf/xPfuEhMSlIE5keb/Zz3/LUlRg8yDqz5w+QWVJ4utnKnK
11+
iqwZN0mwpwU7YSyJhlT4YV1F3n4YjLswM5wJs2oqm0jssQu/BT0ty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ions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
contrib/vagrant/inventory

vagrant.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
site.sh

0 commit comments

Comments
 (0)