Skip to content

Commit 80cb2e9

Browse files
committed
initial commit of scripts
1 parent 8e82f79 commit 80cb2e9

File tree

23 files changed

+724
-0
lines changed

23 files changed

+724
-0
lines changed

Vagrantfile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
VAGRANTFILE_API_VERSION = "2"
5+
6+
machines_file = ENV['MACHINES']
7+
machines_file ||= './vagrant/one_machine'
8+
require machines_file
9+
10+
11+
# Assign machines to their Ansible groups
12+
def generate_ansible_groups(machines)
13+
require 'set'
14+
ansible_groups = {}
15+
all = Set.new
16+
machines.each do |m|
17+
m["ansible_groups"].each do |group|
18+
if not ansible_groups.has_key?(group)
19+
ansible_groups[group] = []
20+
end
21+
if not ansible_groups.has_key?("proxy:vars")
22+
ansible_groups["proxy:vars"] = []
23+
end
24+
ansible_groups[group].push(m["hostname"])
25+
all = all.add(group)
26+
end
27+
end
28+
ansible_groups["proxy:children"] = all.to_a
29+
return ansible_groups
30+
end
31+
32+
33+
34+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
35+
36+
config.vm.provision "ansible" do |ansible|
37+
ansible.groups = generate_ansible_groups(MACHINES)
38+
ansible.playbook = "main.yml"
39+
ansible.extra_vars = { mongodb_host: MONGO_HOST }
40+
# Useful during testing
41+
ansible.host_key_checking = false
42+
# ansible.verbose = "vvvv"
43+
# ansible.inventory_path = "path" # In this case we directly generate it
44+
# ansible.limit = "local"
45+
# ansible.raw_arguments = "--ask-vault-pass"
46+
end
47+
48+
49+
# Disabling the default /vagrant share.
50+
# http://docs.vagrantup.com/v2/synced-folders/
51+
# (Reason to disable it: In MacOS GuestAdditions trend to fail screwing the "up" or "reload".
52+
config.vm.synced_folder ".", "/vagrant", disabled: true
53+
54+
MACHINES.each do |m|
55+
config.vm.define m["hostname"] do |node|
56+
node.vm.box = m["box"]
57+
node.vm.hostname = m["hostname"]
58+
node.vm.network :private_network, ip: m["ip"]
59+
60+
m["ports"].each do |port|
61+
node.vm.network :forwarded_port, guest: port[0], host: port[1]
62+
end
63+
64+
node.vm.provider :virtualbox do |vb|
65+
vb.cpus = m["cpus"]
66+
vb.memory = m["memory"]
67+
end
68+
end
69+
end
70+
end
71+

database.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
3+
# file: database.yml
4+
5+
- name: Install and configure MongoDB
6+
hosts: database
7+
roles:
8+
- mongodb
9+
vars_files:
10+
- vars.secret.yml
11+
tags:
12+
- mongodb
13+
- database

group_vars/learninglocker

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ll_path: "/var/www/learninglocker"
2+
ll_repo: "https://github.com/LearningLocker/learninglocker.git"
3+
ll_repo_version: "HEAD"
4+
5+
# MongoDB's public configuration
6+
mongodb:
7+
database: learninglocker
8+
host: "{{ mongodb_host | default('localhost')}}"

group_vars/proxy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
3+
# Proxy environments. They can be empty.
4+
proxy_env:
5+
# http_proxy: http://wwwcache.open.ac.uk:80
6+
# https_proxy: http://wwwcache.open.ac.uk:80
7+
# ftp_proxy: http://wwwcache.open.ac.uk:80
8+
http_proxy:
9+
https_proxy:
10+
ftp_proxy:

learninglocker.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
3+
# file: learninglocker.yml
4+
5+
- name: Install and configure LearningLocker
6+
hosts: learninglocker
7+
roles:
8+
- apache
9+
- learninglocker
10+
vars_files:
11+
- vars.secret.yml
12+
tags:
13+
- learninglocker
14+
- apache

main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
3+
4+
# file: main.yml
5+
- include: database.yml
6+
- include: learninglocker.yml

roles/apache/meta/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
3+
dependencies:
4+
- { role: proxy }

roles/apache/tasks/configure.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
3+
- name: Start the Firewall Daemon and enable automatic startup
4+
shell: "systemctl {{ item }} firewalld.service"
5+
ignore_errors: True
6+
with_items:
7+
- start
8+
- enable
9+
tags:
10+
- start
11+
- enable
12+
- firewall
13+
- daemon
14+
- systemctl
15+
16+
17+
- name: Allow HTTP Access through Firewall
18+
shell: "{{ item }}"
19+
ignore_errors: True
20+
with_items:
21+
- "firewall-cmd --permanent --zone=public --add-service=http"
22+
- "systemctl restart firewalld.service"
23+
tags:
24+
- allow
25+
- http
26+
- firewall
27+
- daemon
28+
- systemctl
29+
30+
31+
- name: Start Apache HTTP Daemon and enable automatic startup
32+
shell: "systemctl {{ item }} httpd.service"
33+
with_items:
34+
- start
35+
- enable
36+
tags:
37+
- start
38+
- enable
39+
- http
40+
- daemon
41+
- systemctl

roles/apache/tasks/dependencies.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
3+
- name: Install yum-config-manager
4+
yum:
5+
name: yum-utils
6+
state: latest
7+
8+
- name: Install Remi Collet Repository
9+
yum: name="http://rpms.famillecollet.com/enterprise/remi-release-7.rpm" state=present
10+
tags:
11+
- install
12+
- repository
13+
- remi collet
14+
15+
16+
- name: Enable Remi Collet Repository for future updates
17+
shell: yum-config-manager --enable remi remi-php56
18+
tags:
19+
- enable
20+
- repository
21+
- remi collet
22+
23+
24+
- name: Install Apache, PHP and its dependencies
25+
yum: name="{{ item }}" enablerepo=remi,remi-php56 state=present
26+
with_items:
27+
- httpd
28+
- php
29+
- php-common
30+
- php-cli
31+
- php-pear
32+
- php-mysqlnd
33+
- php-pecl-mongo
34+
- php-gd
35+
- php-mbstring
36+
- php-mcrypt
37+
- php-xml
38+
tags:
39+
- install
40+
- apache
41+
- php

roles/apache/tasks/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
3+
- name: Install dependencies
4+
include: dependencies.yml
5+
become: True
6+
7+
8+
- name: Configure firewall and Apache
9+
include: configure.yml
10+
become: True

0 commit comments

Comments
 (0)