-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gabrtv
committed
Apr 4, 2012
1 parent
0cce7c2
commit 7b2abc7
Showing
13 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class opdemand::framework::rails::postgresql { | ||
|
||
# require opdemand common and repo | ||
require opdemand::common | ||
require opdemand::repo::app | ||
|
||
# initialize dynamic parameters | ||
class {"rails::params": | ||
# admin | ||
admin_name => hiera("admin/name", "Administrator"), | ||
admin_username => hiera("admin/username", "admin"), | ||
admin_password => hiera("admin/password", "changeme123"), | ||
admin_email => hiera("admin/email", "admin@example.org"), | ||
# database | ||
database_type => hiera("database/type", "postgresql"), | ||
# service | ||
bind => hiera("application/bind", "0.0.0.0"), | ||
port => hiera("application/port", "8080"), | ||
# daemon/repository | ||
username => hiera("application/username", "ubuntu"), | ||
group => hiera("application/group", "ubuntu"), | ||
home => hiera("application/home", "/home/ubuntu"), | ||
repository_path => hiera("application/repository_path", "/home/ubuntu/repo"), | ||
} | ||
|
||
# include relevant classes | ||
include rails::install | ||
include rails::config | ||
include rails::service | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2012 OpDemand LLC | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name 'opdemand-rails' | ||
version '0.0.1' | ||
source 'UNKNOWN' | ||
author 'opdemand' | ||
license 'UNKNOWN' | ||
summary 'UNKNOWN' | ||
description 'UNKNOWN' | ||
project_page 'UNKNOWN' | ||
|
||
## Add dependencies, if any: | ||
# dependency 'username/name', '>= 1.2.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rails | ||
|
||
This is the rails module. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class rails::config { | ||
|
||
require rails::params | ||
|
||
file {"/etc/init/rails.conf": | ||
ensure => file, | ||
content => template("rails/rails.conf.erb"), | ||
require => Class[Rails::Install], | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
define rails::syncdb { | ||
exec { "sudo -u $rails::params::username rake db:migrate": | ||
path => $path, | ||
user => "$rails::params::username", | ||
cwd => "$rails::params::repository_path/app", | ||
require => Class[Rails::Install], | ||
subscribe => Vcsrepo["$rails::params::repository_path"], | ||
} | ||
} | ||
|
||
define rails::bundleinstall { | ||
exec { "sudo -u $rails::params::username bundle install": | ||
path => $path, | ||
user => "$rails::params::username", | ||
cwd => "$rails::params::repository_path/app", | ||
require => Class[Rails::Install], | ||
subscribe => Vcsrepo["$rails::params::repository_path"], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class rails::install { | ||
|
||
require rails::params | ||
|
||
$packages = [ "curl", "openssl", "ruby1.9.1", "ruby1.9.1-dev", "build-essential", "libsqlite3-ruby1.9.1", "libsqlite3-dev", "rubygems", "libv8-dev"] | ||
$gems = [ "bundler", "rails", "sinatra", "therubyracer" ] | ||
$db_packages = $rails::params::database_type ? { | ||
postgresql => [ "libpq-dev" ], | ||
} | ||
|
||
# install framework database packages | ||
package { $db_packages: | ||
ensure => latest, | ||
} | ||
|
||
# install framework packages | ||
package { $packages: | ||
ensure => latest, | ||
} | ||
|
||
# install gems | ||
package { $gems: | ||
provider => "gem", | ||
ensure => latest, | ||
require => Package[rubygems] | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class rails::params ( | ||
# admin settings | ||
$admin_email = "admin@example.com", | ||
$admin_name = "Admin User", | ||
$admin_username = "admin", | ||
$admin_password = "changeme123", | ||
# database settings | ||
$database_type = "postgresql", | ||
# service settings | ||
$bind = "0.0.0.0", | ||
$port = "8080", | ||
# daemon settings | ||
$username = "ubuntu", | ||
$group = "ubuntu", | ||
$home = "/home/ubuntu", | ||
$repository_path = "/home/ubuntu/repo") { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class rails::service { | ||
|
||
require rails::params | ||
|
||
service {"rails": | ||
ensure => running, | ||
name => "rails", | ||
provider => upstart, | ||
require => [ Class[Rails::Install], Class[Rails::Config] ], | ||
subscribe => Vcsrepo["$rails::params::repository_path"], | ||
} -> | ||
|
||
rails::bundleinstall {"rails":} -> | ||
rails::syncdb {"rails":} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!upstart | ||
description "rails app server" | ||
author "OpDemand" | ||
|
||
start on (local-filesystems and net-device-up IFACE=eth0) | ||
stop on shutdown | ||
|
||
script | ||
export HOME="<%= scope.lookupvar("rails::params::home") %>" | ||
cd $HOME/repo | ||
exec sudo -u <%= scope.lookupvar("rails::params::username") %> rails server 2>&1 >> /var/log/rails.log | ||
end script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include rails |