Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Adding Vagrant and Ansible #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ config/secrets.yml
.svn
.project
.secret
.vagrant
config/database.yml
log/**/*
tmp/**/*
Expand Down
17 changes: 9 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,18 @@ end
# For locale in the route

gem "daemons"
gem 'delayed_job'
gem 'delayed_job'
gem 'delayed_job_active_record'

gem "figaro"

gem 'geocoder'
gem "select2-rails", '3.5.9.3'
gem 'country_select', github: 'stefanpenner/country_select'

gem 'planner-core', path: "../planner-core"
gem 'planner_konopas', path: "../planner_konopas"

# gem 'planner-core', path: "../planner-core"
# gem 'planner_konopas', path: "../planner_konopas"

gem 'planner-core', '>=0.1', :git => '[email protected]:conferenceplan/planner-core.git'
gem 'planner_konopas', '>=0.1', :git => '[email protected]:conferenceplan/planner_konopas.git'
# gem 'planner-core', '>=0.1', :git => '[email protected]:conferenceplan/planner-core.git'
# gem 'planner_konopas', '>=0.1', :git => '[email protected]:conferenceplan/planner_konopas.git'

# Needed for the new asset pipeline
group :assets do
Expand All @@ -58,3 +55,7 @@ end
group :development do
gem 'seed_dump', '0.5.3'
end

group :test do
gem 'test-unit', '~> 3.0'
end
44 changes: 24 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ GIT
i18n-active_record (0.0.2)
i18n (>= 0.6.0)

GIT
remote: [email protected]:conferenceplan/planner-core.git
revision: f199fddb5dae6bc5fec2811ede627bf403acf53f
PATH
remote: ../planner-core
specs:
planner-core (0.8.50)
planner-core (0.8.76)
actionmailer
activerecord
acts-as-taggable-on (= 3.1.1)
Expand Down Expand Up @@ -73,7 +72,6 @@ GIT
jquery-rails (= 2.2.1)
jquery-ui-rails (= 3.0.1)
log4r
momentjs-rails (>= 2.9.0)
prawn-table
prawn_rails
rails (~> 3.2.17)
Expand All @@ -87,9 +85,8 @@ GIT
twitter-typeahead-rails
will_paginate

GIT
remote: [email protected]:conferenceplan/planner_konopas.git
revision: 7824d4a01a7f1a1e11bcd17ad5dc8838483c5b13
PATH
remote: ../planner_konopas
specs:
planner_konopas (0.2.17)
devise
Expand Down Expand Up @@ -152,7 +149,7 @@ GEM
sass (~> 3.2)
bootstrap3-datetimepicker-rails (4.7.14)
momentjs-rails (>= 2.8.1)
browser (1.0.1)
browser (1.1.0)
builder (3.0.4)
cancancan (1.13.1)
carrierwave (0.10.0)
Expand All @@ -167,7 +164,7 @@ GEM
chunky_png (1.3.5)
ckeditor_rails (4.4.7)
railties (>= 3.0)
cloudinary (1.1.1)
cloudinary (1.1.2)
aws_cf_signer
rest-client
coffee-rails (3.2.2)
Expand Down Expand Up @@ -198,10 +195,10 @@ GEM
currencies (~> 0.4.2)
i18n_data (~> 0.7.0)
currencies (0.4.2)
d3_rails (3.5.10)
d3_rails (3.5.11)
railties (>= 3.1.0)
daemons (1.2.3)
dalli (2.7.4)
dalli (2.7.5)
declarative_authorization (0.5.7)
deep_cloneable (1.6.1)
activerecord (>= 3.1.0)
Expand All @@ -210,7 +207,7 @@ GEM
delayed_job_active_record (4.1.0)
activerecord (>= 3.0, < 5)
delayed_job (>= 3.0, < 5)
devise (3.5.2)
devise (3.5.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
Expand Down Expand Up @@ -243,8 +240,8 @@ GEM
http_accept_language (2.0.5)
i18n (0.7.0)
i18n_data (0.7.0)
jbuilder (2.3.2)
activesupport (>= 3.0.0, < 5)
jbuilder (2.4.0)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
journey (1.0.4)
jpbuilder (0.2.5)
Expand All @@ -268,7 +265,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.25.1)
mini_portile (0.6.0)
momentjs-rails (2.10.6)
momentjs-rails (2.11.0)
railties (>= 3.1)
multi_json (1.11.2)
mysql2 (0.3.20)
Expand All @@ -278,6 +275,7 @@ GEM
orm_adapter (0.5.0)
pdf-core (0.6.0)
polyglot (0.3.5)
power_assert (0.2.2)
prawn (2.0.2)
pdf-core (~> 0.6.0)
ttfunk (~> 1.4.0)
Expand Down Expand Up @@ -346,6 +344,8 @@ GEM
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
test-unit (3.0.8)
power_assert
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
Expand Down Expand Up @@ -377,9 +377,9 @@ GEM
unf_ext
unf_ext (0.0.7.1)
unicode_utils (1.4.0)
warden (1.2.3)
warden (1.2.4)
rack (>= 1.0)
will_paginate (3.0.7)
will_paginate (3.1.0)
ya2yaml (0.31)
yui-compressor (0.12.0)

Expand All @@ -403,15 +403,19 @@ DEPENDENCIES
libv8 (= 3.16.14.7)
mysql2 (= 0.3.20)
nokogiri (= 1.6.2.1)
planner-core (>= 0.1)!
planner_konopas (>= 0.1)!
planner-core!
planner_konopas!
puma
rack (= 1.4.5)
rake
sass-rails (>= 3.2)
seed_dump (= 0.5.3)
select2-rails (= 3.5.9.3)
test-unit (~> 3.0)
therubyracer
turbo-sprockets-rails3
uglifier (= 2.5.1)
yui-compressor

BUNDLED WITH
1.11.2
34 changes: 34 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Use Ubuntu 14.04 Trusty Tahr 64-bit as our operating system
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "planner-web"

# Configurate the virtual machine to use 2GB of RAM
config.vm.provider "virtualbox" do |v|
v.memory = 2096
v.cpus = 2
end

config.ssh.forward_agent = true

# Forward the Rails server default port to the host
config.vm.network :forwarded_port, guest: 3000, host: 3001, auto_correct: true
config.vm.network :forwarded_port, guest: 3306, host: 3306, auto_correct: true

# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.99.90"

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder ".", "/planner-web", type: "nfs"
config.vm.synced_folder "../planner-core", "/planner-core", type: "nfs"
config.vm.synced_folder "../planner_konopas", "/planner_konopas", type: "nfs"
end
5 changes: 5 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[defaults]
hostfile = ansible/hosts
remote_user = vagrant
private_key_file = .vagrant/machines/default/virtualbox/private_key
host_key_checking = False
2 changes: 2 additions & 0 deletions ansible/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[vagrant]
devserver ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222
2 changes: 2 additions & 0 deletions ansible/roles/core/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
home_dir: /home/vagrant
3 changes: 3 additions & 0 deletions ansible/roles/core/tasks/git.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Install git
apt: "pkg=git-core state=installed update_cache=yes"
6 changes: 6 additions & 0 deletions ansible/roles/core/tasks/locales.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Install language pack
shell: "{{ item }}"
with_items:
- locale-gen en_US.UTF-8
- dpkg-reconfigure locales
5 changes: 5 additions & 0 deletions ansible/roles/core/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- include: git.yml
- include: ruby.yml
- include: locales.yml
- include: ntp.yml
3 changes: 3 additions & 0 deletions ansible/roles/core/tasks/ntp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Install ntp
apt: "pkg=ntp state=installed update_cache=yes"
38 changes: 38 additions & 0 deletions ansible/roles/core/tasks/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
- name: Install list of dependency packages for Ruby
apt: "pkg={{ item }} state=installed update_cache=yes"
with_items:
- g++
- curl
- zlib1g-dev
- libssl-dev
- build-essential
- libreadline-dev
- libyaml-dev
- libxml2-dev
- libxslt1-dev
- libcurl4-openssl-dev
- python-software-properties
- libffi-dev
- libqtwebkit-dev
- qt4-qmake
- ghostscript
- name: Get currently installed ruby version
command: ruby -v
register: result
ignore_errors: True
- name: Download Ruby Source
get_url: url=https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz dest={{ home_dir }}/ruby-2.2.3.tar.gz force=no
- name: Install Ruby
shell: "{{ item }}"
with_items:
- cd
- cd {{ home_dir }}; tar -xzvf ruby-2.2.3.tar.gz
- cd {{ home_dir }}/ruby-2.2.3/; sudo ./configure
- cd {{ home_dir }}/ruby-2.2.3/; sudo make
- cd {{ home_dir }}/ruby-2.2.3/; sudo make install
when: result.rc !=0 or result.stdout.split()[1] != '2.2.3p173'
- name: Install bundler
shell: "{{ item }}"
with_items:
- sudo gem install bundler
2 changes: 2 additions & 0 deletions ansible/roles/database/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
mysql_root_pass: '123456'
3 changes: 3 additions & 0 deletions ansible/roles/database/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Restart MySQL
service: name=mysql state=restarted
27 changes: 27 additions & 0 deletions ansible/roles/database/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: Install the MySQL packages
apt: name={{ item }} state=installed update_cache=yes
with_items:
- mysql-server-5.6
- mysql-client-5.6
- python-mysqldb
- libmysqlclient-dev

- name: Copy the configuration file (my.cnf)
template: src=my.cnf.j2 dest=/etc/mysql/my.cnf
notify:
- Restart MySQL

- name: Copy the root credentials as .my.cnf file
template: src=root.cnf.j2 dest=~/.my.cnf mode=0600

- name: Ensure Anonymous user(s) are not in the database
mysql_user: name='' host={{ item }} state=absent
with_items:
- localhost
- "{{ host_name }}"

- name: Remove the test database
mysql_db: name=test state=absent
notify:
- Restart MySQL
Loading