Permalink
Browse files

use vcv2 user for app (in preparation for deployment to production)

  • Loading branch information...
1 parent 30268fa commit b0c183d5ca7915f4b281318de74aaad6590b43b9 @cv cv committed Mar 15, 2013
View
@@ -6,6 +6,8 @@ Vagrant::Config.run do |config|
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
config.vm.forward_port 80, 8000
+ config.vm.share_folder 'vagrant-root', '/vcv2', '.'
+
options = {
:module_path => ['puppet/modules', 'puppet/modules/vendor'],
:facter => {
@@ -16,7 +18,7 @@ Vagrant::Config.run do |config|
config.vm.provision :puppet, options do |puppet|
puppet.manifests_path = 'puppet'
puppet.manifest_file = 'site.pp'
- puppet.options = %w[ --libdir=modules/vendor/rbenv/lib --verbose --debug]
+ puppet.options = ENV['DEBUG'] ? %w[--libdir=modules/vendor/rbenv/lib --verbose --debug] : %w[--libdir=modules/vendor/rbenv/lib]
end
end
@@ -22,6 +22,7 @@
$without = undef,
$gem_bin_path = undef,
$ruby_version = undef,
+ $real_user = undef,
) {
include bundler
@@ -41,7 +42,7 @@
cwd => $name,
path => "${gem_bin_path}:/bin:/usr/bin:/usr/local/bin",
unless => 'bundle check',
- require => Rbenv::Gem["rbenv::bundler vagrant ${ruby_version}"],
+ require => Rbenv::Gem["rbenv::bundler ${real_user} ${ruby_version}"],
logoutput => on_failure,
environment => "HOME='${name}'",
}
@@ -1,24 +1,39 @@
-class votocomovamos::app {
+class votocomovamos::app(
+ $user = 'vcv2',
+ $group = 'vcv2'
+) {
$ruby_version = '1.9.3-p392'
+ user {
+ $user:
+ home => '/home/vcv2',
+ ensure => 'present',
+ managehome => true,
+ comment => 'vcv2 daemon user',
+ ;
+ }
+
rbenv::install {
- 'vagrant':
- home => '/home/vagrant'
+ $user:
+ home => "/home/${user}",
+ require => User[$user],
;
}
rbenv::compile {
$ruby_version:
- user => 'vagrant',
- home => '/home/vagrant',
+ user => $user,
+ home => "/home/${user}",
global => true,
;
}
- Rbenv::Gem["rbenv::bundler vagrant ${ruby_version}"] -> Exec["rbenv::rehash vagrant ${ruby_version}"]
+ Rbenv::Gem["rbenv::bundler ${user} ${ruby_version}"] -> Exec["rbenv::rehash ${user} ${ruby_version}"]
$passenger_version = '3.0.19'
- $gem_path = '/opt/vagrant_ruby/lib/ruby/gems/1.8/gems'
+ $gem_path = "/home/${user}/.rbenv/versions/${ruby_version}/lib/ruby/gems/1.9.1/gems"
+
+ rbenv::gem { 'passenger': user => $user, ruby => $ruby_version } -> Exec["rbenv::rehash ${user} ${ruby_version}"] -> Class['passenger']
class {
'apache':
@@ -27,11 +42,11 @@
'passenger':
passenger_package => 'passenger',
passenger_version => $passenger_version,
- passenger_ruby => '/home/vagrant/.rbenv/shims/ruby',
+ passenger_ruby => "/home/${user}/.rbenv/versions/${ruby_version}/bin/ruby",
gem_path => $gem_path,
- gem_binary_path => '/opt/vagrant_ruby/bin',
+ gem_binary_path => "/home/${user}/.rbenv/versions/${ruby_version}/bin",
mod_passenger_location => "${gem_path}/passenger-${passenger_version}/ext/apache2/mod_passenger.so",
- require => Bundler::Install['/vagrant'],
+ require => Bundler::Install['/vcv2'],
;
}
@@ -42,20 +57,21 @@
vhost_name => '*',
port => '80',
template => 'apache/vhost-passenger.conf.erb',
- serveradmin => 'vcv@lixo.org',
- docroot => '/vagrant/public',
- docroot_owner => 'vagrant',
- docroot_group => 'vagrant',
+ serveradmin => "${user}@lixo.org",
+ docroot => '/vcv2/public',
+ docroot_owner => $user,
+ docroot_group => $group,
;
}
bundler::install {
- '/vagrant':
- gem_bin_path => '/home/vagrant/.rbenv/shims',
- user => 'vagrant',
- group => 'vagrant',
- require => Rbenv::Gem["rbenv::bundler vagrant ${ruby_version}"],
- ruby_version => $ruby_version
+ '/vcv2':
+ gem_bin_path => "/home/${user}/.rbenv/shims",
+ user => $user,
+ group => $group,
+ require => Rbenv::Gem["rbenv::bundler ${user} ${ruby_version}"],
+ ruby_version => $ruby_version,
+ real_user => $user,
;
}
@@ -1,11 +1,14 @@
-class votocomovamos::sidekiq {
+class votocomovamos::sidekiq(
+ $app_root = '/vcv2',
+ $user = 'vcv2',
+) {
file {
'/etc/init.d/sidekiq':
ensure => 'file',
mode => '0700',
require => Class['votocomovamos::app'],
- content => template('votocomovamos/sidekiq.init.sh'),
+ content => template('votocomovamos/sidekiq.init.sh.erb'),
owner => 'root',
group => 'root',
;
@@ -10,15 +10,15 @@
# Exit Code 5 - Incorrect User ID
# Exit Code 6 - Directory not found
-APP_DIR="/vagrant"
+APP_DIR="/vcv2"
APP_CONFIG="${APP_DIR}/config"
LOG_FILE="${APP_DIR}/log/sidekiq.log"
LOCK_FILE="${APP_DIR}/tmp/sidekiq.lock"
PID_FILE="${APP_DIR}/tmp/sidekiq.pid"
GEMFILE="${APP_DIR}/Gemfile"
SIDEKIQ="sidekiq"
APP_ENV="development"
-BUNDLE="/home/vagrant/.rbenv/shims/bundle"
+BUNDLE="/home/<%= @user %>/.rbenv/shims/bundle"
START_CMD="$BUNDLE exec $SIDEKIQ -e $APP_ENV -P $PID_FILE"
RETVAL=0
View
@@ -11,7 +11,6 @@
Exec['apt-get update'] -> Package <| |>
- class{ 'votocomovamos::db': } -> class { 'votocomovamos::app': }
- include votocomovamos::sidekiq
+ class { 'votocomovamos::db': } -> class { 'votocomovamos::app': } -> class { 'votocomovamos::sidekiq': }
}

0 comments on commit b0c183d

Please sign in to comment.