salted-rails 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +65 -20
- data/init.sh +64 -0
- data/lib/salted-rails.rb +4 -6
- data/lib/salted-rails/capistrano_helper.rb +106 -0
- data/lib/salted-rails/cloud_vbguest_installer.rb +14 -0
- data/lib/salted-rails/config.rb +212 -0
- data/lib/salted-rails/helper_base.rb +90 -0
- data/lib/salted-rails/vagrant_helper.rb +159 -0
- data/lib/salted-rails/version.rb +3 -0
- data/lib/salted_rails_base.rb +6 -0
- data/pillar/capistrano/top.sls +1 -1
- data/pillar/common.sls +5 -0
- data/pillar/vagrant/top.sls +1 -1
- data/salt/bin/change_mirror.sh +29 -20
- data/salt/bin/fix_hostname.sh +6 -0
- data/salt/bin/provision +37 -0
- data/salt/capistrano/deploy_requirements.sls +5 -0
- data/salt/capistrano/minion +8 -4
- data/salt/capistrano/top.sls +1 -5
- data/salt/ci/cruisecontrolrb.sls +72 -0
- data/salt/ci/teamcity/etc/init.d/teamcity +17 -0
- data/salt/ci/teamcity/init.sls +58 -0
- data/salt/databases/client.sls +18 -0
- data/salt/{common.sls → databases/init.sls} +1 -16
- data/salt/databases/phpmyadmin/etc/nginx/{sites-available → admin.d}/phpmyadmin.conf +1 -1
- data/salt/databases/phpmyadmin/init.sls +2 -11
- data/salt/databases/server.sls +19 -0
- data/salt/editors/gvim.sls +5 -0
- data/salt/editors/rubymine.sls +51 -0
- data/salt/gui/init.sls +3 -0
- data/salt/gui/lxde.sls +5 -0
- data/salt/gui/x2go.sls +23 -0
- data/salt/lang/java/etc/profile.d/java.sh +2 -0
- data/salt/lang/java/init.sls +48 -0
- data/salt/lang/php/composer.sls +0 -3
- data/salt/lang/ruby.sls +3 -3
- data/salt/lang/ruby.sls.bak +3 -3
- data/salt/railsapp/gems.sls +16 -3
- data/salt/railsapp/init.sls +1 -0
- data/salt/railsapp/mysql_database.sls +11 -6
- data/salt/salt/minion/init.sls +19 -18
- data/salt/vagrant/minion +8 -4
- data/salt/vagrant/minion.sls +4 -5
- data/salt/vagrant/top.sls +32 -6
- data/salt/www/admin/etc/nginx/nginx.conf +53 -0
- data/salt/{databases/phpmyadmin → www/admin}/etc/nginx/sites-available/.gitignore +0 -0
- data/salt/www/admin/etc/nginx/sites-available/phpmyadmin.conf +7 -0
- data/salt/www/admin/init.sls +31 -0
- data/salt/www/nginx/init.sls +17 -4
- data/salt/www/users.sls +4 -0
- data/salted-rails.gemspec +1 -1
- metadata +30 -13
- data/lib/salted_rails/capistrano.rb +0 -8
- data/lib/salted_rails/vagrant_helper.rb +0 -169
- data/lib/salted_rails/version.rb +0 -5
- data/salt/capistrano.sls +0 -0
- data/salt/develop/init.sls +0 -3
- data/salt/echo_pillar.sls +0 -9
- data/salt/run-standalone +0 -3
- data/salt/vagrant.sls +0 -0
data/salt/salt/minion/init.sls
CHANGED
@@ -17,7 +17,7 @@ restart_minion:
|
|
17
17
|
- order: last
|
18
18
|
- watch:
|
19
19
|
- pkg: salt-minion
|
20
|
-
|
20
|
+
#- file: /etc/salt/minion
|
21
21
|
- file: /etc/salt/minion.d
|
22
22
|
- require:
|
23
23
|
- pkg: at
|
@@ -30,20 +30,21 @@ salt-minion:
|
|
30
30
|
- names:
|
31
31
|
- salt-minion
|
32
32
|
- at
|
33
|
-
|
34
|
-
|
35
|
-
-
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
- /srv/salt/
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
- /srv/salt/
|
33
|
+
# Don't want to override minion copied in by vagrant!
|
34
|
+
# file.managed:
|
35
|
+
# - name: /etc/salt/minion
|
36
|
+
# - owner: root
|
37
|
+
# - group: root
|
38
|
+
# - mode: 0644
|
39
|
+
# - source: salt://salt/minion/config.template
|
40
|
+
# - template: jinja
|
41
|
+
# - context:
|
42
|
+
# master: salt
|
43
|
+
# file_roots:
|
44
|
+
# base:
|
45
|
+
# - /srv/salt/private
|
46
|
+
# - /srv/salt/base
|
47
|
+
# pillar_roots:
|
48
|
+
# base:
|
49
|
+
# - /srv/salt/private/pillar
|
50
|
+
# - /srv/salt/base/pillar
|
data/salt/vagrant/minion
CHANGED
@@ -5,10 +5,14 @@ state_auto_order: True
|
|
5
5
|
|
6
6
|
file_roots:
|
7
7
|
base:
|
8
|
-
- /srv/salt/vagrant
|
9
|
-
- /srv/salt
|
8
|
+
- /srv/salt/config/vagrant
|
9
|
+
- /srv/salt/salted-rails/vagrant
|
10
|
+
- /srv/salt/salted-rails
|
11
|
+
- /srv/salt/generated
|
10
12
|
|
11
13
|
pillar_roots:
|
12
14
|
base:
|
13
|
-
- /srv/pillar/vagrant
|
14
|
-
- /srv/pillar
|
15
|
+
- /srv/pillar/config/vagrant
|
16
|
+
- /srv/pillar/salted-rails/vagrant
|
17
|
+
- /srv/pillar/salted-rails
|
18
|
+
- /srv/pillar/generated
|
data/salt/vagrant/minion.sls
CHANGED
data/salt/vagrant/top.sls
CHANGED
@@ -1,8 +1,34 @@
|
|
1
1
|
base:
|
2
2
|
'*':
|
3
|
-
-
|
4
|
-
- vagrant
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
- apt.partner-sources
|
4
|
+
- vagrant.minion
|
5
|
+
- apt.unwanted
|
6
|
+
- www.users
|
7
|
+
- sysutils
|
8
|
+
- capistrano/deploy_requirements
|
9
|
+
- editors.vim
|
10
|
+
- sysutils.tmux
|
11
|
+
{%- if 'app' in pillar['roles'] %}
|
12
|
+
- databases.client
|
13
|
+
- lang.ruby
|
14
|
+
- railsapp
|
15
|
+
{%- endif %}
|
16
|
+
{%- if 'web' in pillar['roles'] %}
|
17
|
+
- www.nginx
|
18
|
+
{%- endif %}
|
19
|
+
{%- if 'db' in pillar['roles'] %}
|
20
|
+
- databases
|
21
|
+
{%- endif %}
|
22
|
+
{%- if 'gui' in pillar['roles'] %}
|
23
|
+
- gui.lxde
|
24
|
+
- gui.x2go
|
25
|
+
- editors.gvim
|
26
|
+
- editors.rubymine
|
27
|
+
- www.chromium
|
28
|
+
{%- endif %}
|
29
|
+
{%- if 'teamcity' in pillar['roles'] %}
|
30
|
+
- ci.teamcity
|
31
|
+
{%- endif %}
|
32
|
+
{%- if 'cruisecontrolrb' in pillar['roles'] %}
|
33
|
+
- ci.cruisecontrolrb
|
34
|
+
{%- endif %}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
user www-data www-data;
|
2
|
+
worker_processes 4;
|
3
|
+
pid /var/run/nginx.pid;
|
4
|
+
|
5
|
+
events {
|
6
|
+
worker_connections 768;
|
7
|
+
# multi_accept on;
|
8
|
+
}
|
9
|
+
|
10
|
+
http {
|
11
|
+
sendfile on;
|
12
|
+
tcp_nopush on;
|
13
|
+
tcp_nodelay on;
|
14
|
+
types_hash_max_size 2048;
|
15
|
+
server_tokens off;
|
16
|
+
|
17
|
+
# Headers
|
18
|
+
add_header X-Server-ID $hostname;
|
19
|
+
|
20
|
+
# Size Limits & Buffer Overflows
|
21
|
+
# One of the most important things to tweak
|
22
|
+
client_body_buffer_size 128k;
|
23
|
+
client_header_buffer_size 1k;
|
24
|
+
client_max_body_size 20m;
|
25
|
+
large_client_header_buffers 4 16k;
|
26
|
+
|
27
|
+
# Timeouts
|
28
|
+
client_body_timeout 10;
|
29
|
+
client_header_timeout 20;
|
30
|
+
keepalive_timeout 15 15;
|
31
|
+
send_timeout 10;
|
32
|
+
|
33
|
+
# SSL settings
|
34
|
+
ssl_session_cache shared:SSL:10m;
|
35
|
+
ssl_session_timeout 10m;
|
36
|
+
|
37
|
+
# server_names_hash_bucket_size 64;
|
38
|
+
# server_name_in_redirect off;
|
39
|
+
|
40
|
+
##
|
41
|
+
# Gzip Settings
|
42
|
+
##
|
43
|
+
|
44
|
+
gzip on;
|
45
|
+
gzip_disable "msie6";
|
46
|
+
|
47
|
+
include mime.types;
|
48
|
+
default_type application/octet-stream;
|
49
|
+
|
50
|
+
# include /etc/nginx/naxsi_core.rules;
|
51
|
+
include conf.d/*.autoload.conf;
|
52
|
+
include sites-enabled/*.conf;
|
53
|
+
}
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
nginx:
|
2
|
+
pkg.installed:
|
3
|
+
- name: nginx-full
|
4
|
+
service:
|
5
|
+
- running
|
6
|
+
- enable: True
|
7
|
+
- reload: True
|
8
|
+
- watch:
|
9
|
+
#- file: {{ pillar['etc_dir'] }}nginx/nginx.conf
|
10
|
+
#- file: {{ pillar['etc_dir'] }}nginx/sites-enabled/*
|
11
|
+
- file: {{ pillar['etc_dir'] }}nginx/*
|
12
|
+
require:
|
13
|
+
- file: {{ pillar['etc_dir'] }}nginx/nginx.conf
|
14
|
+
|
15
|
+
admin-site:
|
16
|
+
file.managed:
|
17
|
+
- source: salt://www/nginx/etc/nginx/admin.d/phpmyadmin.conf
|
18
|
+
- name: {{ pillar['etc_dir'] }}nginx/admin.d/phpmyadmin.conf
|
19
|
+
- user: root
|
20
|
+
- group: root
|
21
|
+
- template: jinja
|
22
|
+
- mode: 644
|
23
|
+
|
24
|
+
admin_conf:
|
25
|
+
|
26
|
+
#{{ pillar['etc_dir'] }}nginx/nginx.conf:
|
27
|
+
# file.managed:
|
28
|
+
# - source: salt://www/nginx/etc/nginx/nginx.conf
|
29
|
+
# - user: root
|
30
|
+
# - group: root
|
31
|
+
# - mode: 644
|
data/salt/www/nginx/init.sls
CHANGED
@@ -5,12 +5,25 @@ nginx:
|
|
5
5
|
- running
|
6
6
|
- enable: True
|
7
7
|
- reload: True
|
8
|
-
|
8
|
+
#- watch:
|
9
9
|
#- file: {{ pillar['etc_dir'] }}nginx/nginx.conf
|
10
10
|
#- file: {{ pillar['etc_dir'] }}nginx/sites-enabled/*
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
#- file: {{ pillar['etc_dir'] }}nginx/admin.d/*
|
12
|
+
- require:
|
13
|
+
- file.directory: admin-d
|
14
|
+
- pkg: nginx
|
15
|
+
|
16
|
+
admin-d:
|
17
|
+
file.directory:
|
18
|
+
- name: {{ pillar['etc_dir'] }}nginx/admin.d
|
19
|
+
- user: root
|
20
|
+
- group: root
|
21
|
+
- mode: 755
|
22
|
+
- require:
|
23
|
+
- pkg: nginx
|
24
|
+
|
25
|
+
# require:
|
26
|
+
# - file: {{ pillar['etc_dir'] }}nginx/nginx.conf
|
14
27
|
|
15
28
|
#{{ pillar['etc_dir'] }}nginx/nginx.conf:
|
16
29
|
# file.managed:
|
data/salt/www/users.sls
CHANGED
data/salted-rails.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salted-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09
|
12
|
+
date: 2013-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -55,10 +55,14 @@ files:
|
|
55
55
|
- LICENSE
|
56
56
|
- README.md
|
57
57
|
- Rakefile
|
58
|
+
- init.sh
|
58
59
|
- lib/salted-rails.rb
|
59
|
-
- lib/
|
60
|
-
- lib/
|
61
|
-
- lib/
|
60
|
+
- lib/salted-rails/capistrano_helper.rb
|
61
|
+
- lib/salted-rails/cloud_vbguest_installer.rb
|
62
|
+
- lib/salted-rails/config.rb
|
63
|
+
- lib/salted-rails/helper_base.rb
|
64
|
+
- lib/salted-rails/vagrant_helper.rb
|
65
|
+
- lib/salted-rails/version.rb
|
62
66
|
- lib/salted_rails_base.rb
|
63
67
|
- pillar/capistrano.sls
|
64
68
|
- pillar/capistrano/top.sls
|
@@ -68,12 +72,18 @@ files:
|
|
68
72
|
- salt/apt/partner-sources.sls
|
69
73
|
- salt/apt/unwanted.sls
|
70
74
|
- salt/bin/change_mirror.sh
|
71
|
-
- salt/
|
75
|
+
- salt/bin/fix_hostname.sh
|
76
|
+
- salt/bin/provision
|
77
|
+
- salt/capistrano/deploy_requirements.sls
|
72
78
|
- salt/capistrano/minion
|
73
79
|
- salt/capistrano/minion.sls
|
74
80
|
- salt/capistrano/top.sls
|
75
|
-
- salt/
|
81
|
+
- salt/ci/cruisecontrolrb.sls
|
82
|
+
- salt/ci/teamcity/etc/init.d/teamcity
|
83
|
+
- salt/ci/teamcity/init.sls
|
76
84
|
- salt/crons/init.sls
|
85
|
+
- salt/databases/client.sls
|
86
|
+
- salt/databases/init.sls
|
77
87
|
- salt/databases/mysql/client-encoding-and-collation.cnf
|
78
88
|
- salt/databases/mysql/client.sls
|
79
89
|
- salt/databases/mysql/common.sls
|
@@ -84,13 +94,18 @@ files:
|
|
84
94
|
- salt/databases/mysql/init.sls
|
85
95
|
- salt/databases/mysql/server-encoding-and-collation.cnf
|
86
96
|
- salt/databases/mysql/server.sls
|
87
|
-
- salt/databases/phpmyadmin/etc/nginx/
|
88
|
-
- salt/databases/phpmyadmin/etc/nginx/sites-available/phpmyadmin.conf
|
97
|
+
- salt/databases/phpmyadmin/etc/nginx/admin.d/phpmyadmin.conf
|
89
98
|
- salt/databases/phpmyadmin/init.sls
|
90
|
-
- salt/
|
91
|
-
- salt/
|
99
|
+
- salt/databases/server.sls
|
100
|
+
- salt/editors/gvim.sls
|
101
|
+
- salt/editors/rubymine.sls
|
92
102
|
- salt/editors/vim/init.sls
|
93
103
|
- salt/editors/vim/vimrc
|
104
|
+
- salt/gui/init.sls
|
105
|
+
- salt/gui/lxde.sls
|
106
|
+
- salt/gui/x2go.sls
|
107
|
+
- salt/lang/java/etc/profile.d/java.sh
|
108
|
+
- salt/lang/java/init.sls
|
94
109
|
- salt/lang/php/composer.sls
|
95
110
|
- salt/lang/php/etc/php5/fpm/php.fpm.ini
|
96
111
|
- salt/lang/php/etc/php5/fpm/pool.d/www.conf
|
@@ -120,7 +135,6 @@ files:
|
|
120
135
|
- salt/railsapp/init.sls
|
121
136
|
- salt/railsapp/mysql_database.sls
|
122
137
|
- salt/railsapp/packages.sls
|
123
|
-
- salt/run-standalone
|
124
138
|
- salt/salt/minion/config.template
|
125
139
|
- salt/salt/minion/debconf.sls
|
126
140
|
- salt/salt/minion/init.sls
|
@@ -135,10 +149,13 @@ files:
|
|
135
149
|
- salt/sysutils/net.sls
|
136
150
|
- salt/sysutils/status.sls
|
137
151
|
- salt/sysutils/tmux.sls
|
138
|
-
- salt/vagrant.sls
|
139
152
|
- salt/vagrant/minion
|
140
153
|
- salt/vagrant/minion.sls
|
141
154
|
- salt/vagrant/top.sls
|
155
|
+
- salt/www/admin/etc/nginx/nginx.conf
|
156
|
+
- salt/www/admin/etc/nginx/sites-available/.gitignore
|
157
|
+
- salt/www/admin/etc/nginx/sites-available/phpmyadmin.conf
|
158
|
+
- salt/www/admin/init.sls
|
142
159
|
- salt/www/chromium.sls
|
143
160
|
- salt/www/nginx/etc/nginx/nginx.conf
|
144
161
|
- salt/www/nginx/init.sls
|
@@ -1,169 +0,0 @@
|
|
1
|
-
# -*- mode: ruby -*-
|
2
|
-
# vi: set ft=ruby :
|
3
|
-
#
|
4
|
-
|
5
|
-
require 'erb'
|
6
|
-
require 'yaml'
|
7
|
-
require 'fileutils'
|
8
|
-
require "salted_rails_base"
|
9
|
-
|
10
|
-
class SaltedRails < SaltedRailsBase
|
11
|
-
class VagrantHelper
|
12
|
-
|
13
|
-
def initialize(rails_root, debug = false)
|
14
|
-
@logger = if debug
|
15
|
-
self
|
16
|
-
end
|
17
|
-
|
18
|
-
@rails_root = rails_root
|
19
|
-
@rails_root += '/' unless @rails_root =~ /\/$/
|
20
|
-
|
21
|
-
@gem_root = File.dirname(__FILE__) + '/../../'
|
22
|
-
|
23
|
-
@logger.info "RAILS_ROOT = #{@rails_root}" if @logger
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def configure_vagrant(config)
|
28
|
-
config.vm.box = 'UbuntuCloud_12.04_32bit'
|
29
|
-
config.vm.box_url = 'http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-i386-disk1.box'
|
30
|
-
end
|
31
|
-
|
32
|
-
def configure_ubuntu_mirror(config, mirror = 'mirror://mirrors.ubuntu.com/mirrors.txt')
|
33
|
-
config.vm.provision "shell" do |s|
|
34
|
-
s.path = @gem_root + 'salt/bin/change_mirror.sh'
|
35
|
-
s.args = "'#{mirror}'"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def configure_digital_ocean(config, private_key_path = '~/.ssh/id_rsa', disable_vagrant_sync = true)
|
40
|
-
@logger.info 'Configuring digital ocean provider' if @logger
|
41
|
-
config.vm.provider :digital_ocean do |provider, override|
|
42
|
-
override.ssh.username = 'vagrant'
|
43
|
-
override.vm.box = 'digital_ocean'
|
44
|
-
override.vm.box_url = 'https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box'
|
45
|
-
provider.image = 'Ubuntu 12.04 x32'
|
46
|
-
provider.region = 'San Francisco 1'
|
47
|
-
provider.ca_path = '/etc/ssl/certs/ca-certificates.crt' if File.exist?('/etc/ssl/certs/ca-certificates.crt')
|
48
|
-
override.vm.synced_folder '.', '/vagrant', :disabled => true if disable_vagrant_sync
|
49
|
-
override.ssh.private_key_path = private_key_path
|
50
|
-
@private_key_name = 'Vagrant ' + private_key_path.sub(/~\//, '').sub(/\.ssh\//, '').sub(/^id_/, '').gsub(/\W+/, ' ')
|
51
|
-
provider.ssh_key_name = @private_key_name if @private_key_name
|
52
|
-
override.ssh.forward_agent = true
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def configure_salt(config)
|
57
|
-
pillarize_application_configuration
|
58
|
-
config.vm.synced_folder salt_root + 'salt/', '/srv/salt/'
|
59
|
-
config.vm.synced_folder salt_root + 'pillar/', '/srv/pillar/'
|
60
|
-
# Bootstrap salt
|
61
|
-
## config.vm.provision :shell, :inline => 'salt-call --version || wget -O - http://bootstrap.saltstack.org | sudo sh'
|
62
|
-
# Provisioning #2: masterless highstate call
|
63
|
-
config.vm.provision :salt do |salt|
|
64
|
-
@logger.info 'Configuring salt provisioner' if @logger
|
65
|
-
salt.minion_config = salt_root + 'salt/vagrant/minion'
|
66
|
-
salt.run_highstate = true
|
67
|
-
salt.verbose = true
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def configure_ports(vm_config)
|
72
|
-
vm_config.vm.network :forwarded_port, :guest => 3000, :host => 3000, auto_correct: true
|
73
|
-
[ 80, 443 ].each do |port|
|
74
|
-
vm_config.vm.network :forwarded_port, :guest => port, :host => 3000+port, auto_correct: true
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def configure_gui(vm_config)
|
79
|
-
vm_config.vm.boot_mode == :gui
|
80
|
-
vm_config.vm.provision :salt do |salt|
|
81
|
-
salt.minion_config = salt_root + 'salt/vagrant/gui_minion'
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def info(msg)
|
86
|
-
puts msg
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
|
91
|
-
def salt_root
|
92
|
-
@salt_root ||= @rails_root + (File.directory?(@rails_root + 'salt/salt') ? 'salt/' : 'tmp/')
|
93
|
-
end
|
94
|
-
|
95
|
-
# Add ruby version and gemfiles
|
96
|
-
|
97
|
-
def pillarize_application_configuration
|
98
|
-
salt_dir = @rails_root + 'salt/salt/'
|
99
|
-
pillar_dir = @rails_root + 'salt/pillar/'
|
100
|
-
copy_in_tmp = ! File.directory?(salt_dir)
|
101
|
-
if copy_in_tmp
|
102
|
-
salt_dir = @rails_root + 'tmp/salt/'
|
103
|
-
pillar_dir = @rails_root + 'tmp/pillar/'
|
104
|
-
end
|
105
|
-
copy_all = ! File.directory?(salt_dir)
|
106
|
-
|
107
|
-
pillar_app_file = pillar_dir + 'application.sls'
|
108
|
-
version_file = @rails_root + '.ruby-version'
|
109
|
-
database_file = @rails_root + 'config/database.yml'
|
110
|
-
gemfile = @rails_root + 'Gemfile'
|
111
|
-
|
112
|
-
rails_config_changed = ! (File.exist?(pillar_app_file) and File.directory?(salt_dir))
|
113
|
-
rails_config_changed ||= (File.mtime(__FILE__) > File.mtime(pillar_app_file))
|
114
|
-
files = [ version_file, database_file, gemfile ]
|
115
|
-
files <<= "#{gemfile}.lock" if File.exist? "#{gemfile}.lock"
|
116
|
-
files.each do |f|
|
117
|
-
rails_config_changed ||= (File.mtime(f) > File.mtime(pillar_app_file))
|
118
|
-
end
|
119
|
-
copy_all ||= rails_config_changed if copy_in_tmp
|
120
|
-
|
121
|
-
if copy_all
|
122
|
-
@logger.info "Copying default rules to tmp/salt and tmp/pillar" if @logger
|
123
|
-
FileUtils.rm_rf(pillar_dir)
|
124
|
-
FileUtils.rm_rf(salt_dir)
|
125
|
-
FileUtils.mkdir_p(pillar_dir)
|
126
|
-
FileUtils.mkdir_p(salt_dir)
|
127
|
-
|
128
|
-
FileUtils.cp_r(@gem_root + 'pillar/.', pillar_dir)
|
129
|
-
FileUtils.cp_r(@gem_root + 'salt/.', salt_dir)
|
130
|
-
else
|
131
|
-
@logger.info 'skipped creation of salt and pillar (up to date)' if @logger
|
132
|
-
end
|
133
|
-
|
134
|
-
if rails_config_changed
|
135
|
-
dest = salt_dir + "railsapp/files"
|
136
|
-
FileUtils.mkdir_p dest
|
137
|
-
files.each do |file|
|
138
|
-
@logger.info "Copying #{file} to #{dest}" if @logger
|
139
|
-
FileUtils.cp(file, dest)
|
140
|
-
end
|
141
|
-
|
142
|
-
File.open(pillar_app_file, 'w') do |f_out|
|
143
|
-
ENV['VAGRANT_MACHINE'] = 'true'
|
144
|
-
database_conf = YAML.load(ERB.new(IO.read(database_file)).result)
|
145
|
-
ruby_version = File.open(version_file, 'r') do |f_in|
|
146
|
-
f_in.gets.gsub(/\s/,'')
|
147
|
-
end
|
148
|
-
app_config = {
|
149
|
-
'database' => database_conf,
|
150
|
-
'ruby-version' => ruby_version,
|
151
|
-
'gems' => { }
|
152
|
-
}
|
153
|
-
database_conf.each do |key, details|
|
154
|
-
app_config['gems'][details['adapter']] = true
|
155
|
-
end
|
156
|
-
File.foreach(gemfile) do |line|
|
157
|
-
app_config['gems'][$1] = true if (line =~ /^\s*gem\s*['"]([^'"]+)/)
|
158
|
-
end
|
159
|
-
f_out.puts app_config.to_yaml
|
160
|
-
end
|
161
|
-
else
|
162
|
-
@logger.info 'skipped configuration of salt and pillar (up to date)' if @logger
|
163
|
-
end
|
164
|
-
|
165
|
-
end
|
166
|
-
|
167
|
-
end
|
168
|
-
|
169
|
-
end
|