salted-rails 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MDdiZWRhMWZmOGIzZmI4OTdjZmI3YTE2MjIzOGNmZGJkNzRiMzI3NQ==
5
+ data.tar.gz: !binary |-
6
+ NTMyYjkxMzI0NjkwOGJjZWU0NmMxMzFjN2I1ZGJmZmI4ZTQwZDE0ZA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTQzYTRhN2ExMDc4OWE0ZDc5N2U1MGI1N2Q1YjVjY2UzNjQxOTNlODIwYzg2
10
+ ZjQ3YjU0OTNkNDBkNjI3MTUxN2YxOWUzZGY5YTc4MDY5OGI3YTM0MmRmYmI0
11
+ YmY2NjdkMmE3YzAyYjFhNzM2ZDJlZWIzZjY3ZjQ1YzVkNDUxMTM=
12
+ data.tar.gz: !binary |-
13
+ MzUxODRhMDBiMGQ1NWQyYjJiMDJjNmIxNTE4ZGNlYWM4ZDUwMmE2MTA0N2U5
14
+ NzRkM2I5ZjE5NzQzMDFjYzdlYmIyOTgzNzIwZjFkYTJkYjJjYTBkMjJmNzY4
15
+ MDMxNzc1ODI2NmRkNWJjNjlkY2RkNGFmMTJkZDE2YWQ5Y2EzZGM=
data/.gitignore CHANGED
@@ -1,6 +1,3 @@
1
- # OS-specific
2
- .DS_Store
3
-
4
1
  # Vagrant stuff
5
2
  acceptance_config.yml
6
3
  boxes/*
@@ -15,27 +12,13 @@ tags
15
12
  /Gemfile.lock
16
13
  test/tmp/
17
14
 
15
+ /bin
16
+
18
17
  # Documentation
19
18
  _site/*
20
19
  .yardoc/
21
20
  doc/
22
21
 
23
- # Python
24
- *.pyc
25
-
26
- # Rubinius
27
- *.rbc
28
-
29
- # IDE junk
30
- .idea/*
31
- *.iml
32
-
33
- # Ruby Managers
34
- .rbenv
35
- .ruby-gemset
36
- .ruby-version
37
- .rvmrc
38
-
39
22
  # Website: docs
40
23
  website/docs/.sass-cache
41
24
  website/docs/build
@@ -50,7 +33,5 @@ website/www/Rakefile
50
33
  /salt/railsapp/files
51
34
  /pillar/application.sls
52
35
 
53
- # Temp files
54
- ,*
55
- *~
56
-
36
+ # See: https://gist.github.com/ianheggie/9327010
37
+ # for Global git ignore for OS/IDE/temp/backup files
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,19 @@
1
+ language: ruby
2
+ notifications:
3
+ email:
4
+ on_success: change
5
+ on_failure: always
6
+
7
+ before_install:
8
+ - gem update --system $RUBYGEMS_VERSION
9
+ - gem --version
10
+ - gem install bundler
11
+ - bundle --version
12
+
13
+ bundler_args: "--binstubs"
14
+
15
+ script: bin/rspec
16
+
17
+ rvm:
18
+ - 1.9.3
19
+
data/README.md CHANGED
@@ -20,10 +20,7 @@ This configures vagrant in the way that I personally like:
20
20
  * forward post 3000, 80, 443
21
21
  * Include fix vbguest fix for upgrading virtualbox additions with ubunutu cloud
22
22
 
23
- I am thinking of doing the following in the future:
24
- * Configuring up vim with a standard set of plugins
25
- * Expand it for use with capistrano (for deployment to staging and production servers), including hardening up the server for security
26
- * Expand it to construct continuous testing / delivery servers
23
+ **I am currently investigating ansible and alternative approaches, so this project is currently on hold**
27
24
 
28
25
  ## Installation
29
26
 
@@ -31,8 +28,8 @@ I am thinking of doing the following in the future:
31
28
 
32
29
  Download init.sh script and run:
33
30
 
34
- $ wget https://raw.github.com/ianheggie/salted-rails/master/init.sh
35
- $ sh init.sh
31
+ $ wget https://raw.github.com/ianheggie/salted-rails/master/init.sh
32
+ $ sh init.sh
36
33
 
37
34
  This will:
38
35
 
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/init.sh CHANGED
@@ -3,37 +3,41 @@
3
3
  msg='OK: Vagrant has been setup: ready for vagrant up [--provider=digital_ocean]'
4
4
 
5
5
  if which VirtualBox; then
6
- echo Found Virtualbox
6
+ echo Found VirtualBox
7
+ VirtualBox --help | line
7
8
  else
8
- echo ACTION REQUIRED: Please install Virtualbox 4.2.18 or later from https://www.virtualbox.org/wiki/Downloads
9
+ echo 'ACTION REQUIRED: Please install VirtualBox 4.2.18 or later from https://www.virtualbox.org/wiki/Downloads'
9
10
  msg='(PLEASE RERUN SCRIPT AFTERWARDS)'
10
11
  fi
11
12
 
12
13
  if which vagrant; then
13
- echo Found vagrant
14
- echo Checking vagrant plugins are installed ...
14
+ echo 'Found vagrant:'
15
+ vagrant -v
16
+ echo 'Checking vagrant plugins are installed ...'
15
17
 
16
18
  vagrant plugin list > /tmp/t$$
17
19
  for plugin in deep_merge vagrant-digitalocean vagrant-vbguest salted-rails
18
20
  do
19
21
  if grep $plugin < /tmp/t$$; then
22
+ echo Updating plugin $plugin
20
23
  vagrant plugin update $plugin
21
24
  else
25
+ echo Installing plugin $plugin
22
26
  vagrant plugin install $plugin
23
27
  fi
24
28
  done
25
29
 
26
30
  else
27
- echo ACTION REQUIRED: Please install vagrant 1.3.3 (1.3.4 has a bug) from http://www.vagrantup.com/
31
+ echo 'ACTION REQUIRED: Please install vagrant 1.3.3 (1.3.4 has a bug) from http://www.vagrantup.com/'
28
32
  msg='(PLEASE RERUN SCRIPT AFTERWARDS)'
29
33
  fi
30
34
 
31
35
  if [ ! -f Vagrantfile ]; then
32
36
  if [ -f Vagrantfile.example ]; then
33
37
  if [ -f Vagrantfile ]; then
34
- echo Found Vagrantfile '(previously copied from example)'
38
+ echo 'Found Vagrantfile (previously copied from example)'
35
39
  else
36
- echo Copying Vagrantfile.example to Vagrantfile '(so you can customize it)'
40
+ echo 'Copying Vagrantfile.example to Vagrantfile (so you can customize it)'
37
41
  cp Vagrantfile.example Vagrantfile
38
42
  fi
39
43
  else
@@ -42,16 +46,18 @@ if [ ! -f Vagrantfile ]; then
42
46
  fi
43
47
  fi
44
48
 
45
- mkdir -p $HOME/.vagrant.d
49
+ mkdir -p "$HOME/.vagrant.d"
46
50
 
47
- if [ -f "$HOME/.vagrant.d/Vagrantfile" ]; then
48
- echo Found global Vagrantfile
51
+ global_Vagrantfile="$HOME/.vagrant.d/Vagrantfile"
52
+ if [ -f "$global_Vagrantfile" ]; then
53
+ echo Found global Vagrantfile: $global_Vagrantfile
49
54
  else
50
- echo "About to set up ~/.vagrant.d/Vagrantfile"
55
+ echo "About to set up $global_Vagrantfile"
51
56
  echo -n "Enter your digital ocean client key (defaul none): "
52
57
  read client_id
53
58
  echo -n "Enter your digital ocean API key (defaul none): "
54
59
  read api_key
60
+ if [ -n "$client_id" -a -n "$api_key" ] ; then
55
61
  echo "
56
62
  Vagrant.configure('2') do |config|
57
63
  config.vm.provider :digital_ocean do |provider|
@@ -59,7 +65,8 @@ Vagrant.configure('2') do |config|
59
65
  provider.api_key = '$api_key'
60
66
  end
61
67
  end
62
- " > $HOME/.vagrant.d/Vagrantfile
68
+ " > $global_Vagrantfile
69
+ fi
63
70
  fi
64
71
  echo
65
72
  echo "$msg"
@@ -53,7 +53,12 @@ module SaltedRails
53
53
  @private_key_path = nil
54
54
  @mirror = nil
55
55
  @memory = nil
56
- @ports = [ 80, 443, 880, 3000 ]
56
+
57
+ # app in production mode: 80, 443
58
+ # admin: 880
59
+ # app in dev mode: 3000
60
+ # gem server: 8808
61
+ @ports = [ 80, 443, 880, 3000, 8808 ]
57
62
  @mapped_ports = { }
58
63
  @sync_vagrant = nil
59
64
  @box = nil
@@ -165,7 +170,7 @@ module SaltedRails
165
170
  @versions['mysql'] ||= '5.5' if @roles.include?('mysql')
166
171
  @versions['teamcity'] ||= '8.0.4' if @roles.include?('teamcity')
167
172
  @versions['rubymine'] ||= '5.4.3' if @roles.include?('rubymine')
168
- @roles << 'gui' if @roles.include?('rubymine') and not @roles.include?('gui')
173
+ @roles << 'gui' if @roles.include?('rubymine') and not gui?
169
174
 
170
175
  %w{ ruby php java }.each do |lang|
171
176
  version = File.open(@project_root + ".#{lang}-version", 'r') do |f_in|
@@ -27,7 +27,7 @@ module SaltedRails
27
27
  @config.machines.each do |machine_config|
28
28
  machine_config.logger.info "Configuring machine #{machine_config.machine}, hostname: #{machine_config.hostname}"
29
29
  vagrant_config.vm.define(machine_config.machine.to_sym) do |vagrant_vm_config|
30
- configure_gui(vagrant_vm_config) if @config.gui?
30
+ configure_gui(vagrant_vm_config) if machine_config.gui?
31
31
  configure_hostname(vagrant_vm_config, machine_config)
32
32
  configure_ports(vagrant_vm_config, port_offset, machine_config)
33
33
  configure_memory(vagrant_vm_config, machine_config.memory, machine_config)
@@ -1,3 +1,3 @@
1
1
  module SaltedRails
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -13,28 +13,32 @@ runit()
13
13
  0)
14
14
  echo "Running all states ..."
15
15
  sudo salt-call saltutil.sync_all
16
- sudo salt-call state.highstate
16
+ sudo salt-call --retcode-passthrough state.highstate
17
+ ret=$?
18
+ echo "exit status: $ret"
17
19
  ;;
18
20
  *)
19
21
  for file; do
20
22
  echo "Running $file ..."
21
- sudo salt-call state.sls "$file"
23
+ sudo salt-call --retcode-passthrough state.sls "$file"
24
+ ret=$?
25
+ echo "exit status: $ret"
22
26
  done
23
27
  ;;
24
28
  esac
25
29
  }
26
30
  case "$1" in
27
31
  run)
32
+ ret=
28
33
  shift
29
34
  if $no_check; then
30
35
  # Color is used when there is no checking (piped output)
31
36
  runit "$@"
32
- exit
37
+ exit $ret
33
38
  fi
34
39
  runit "$@" 2>&1 | tee /tmp/t$$
35
40
  echo
36
41
  echo Checking results log:
37
- ret=
38
42
  if egrep '^\[ERROR *\]' /tmp/t$$; then
39
43
  echo ERROR: `egrep '^\[ERROR *\]' /tmp/t$$ | wc -l` ERRORS FOUND IN LOG
40
44
  ret=1
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "log4r"
21
22
  spec.add_development_dependency "bundler", "~> 1.3"
22
23
  spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec", '~> 2.14'
23
25
  end
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+ #
3
+ # Installs other plugins that we use for testing
4
+
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ #
3
+ # Installs this plugin into vagrant
4
+
5
+
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+ #
3
+ # Installs vagrant if it is missing
4
+
5
+ if which vagrant && vagrant -v ; then
6
+ echo 'found vagrant!'
7
+ else
8
+ wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.4.3_x86_64.deb
9
+ sudo dpkg -i vagrant_1.4.3_x86_64.deb
10
+ fi
File without changes
@@ -0,0 +1 @@
1
+ gem 'mysql'
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'init.sh' do
4
+ context 'when run', :slow => true do
5
+
6
+ before(:all) do
7
+ @output = `sh init.sh < /dev/null`
8
+ @exit_status = $?
9
+ end
10
+
11
+ it 'should not exit with an error' do
12
+ expect(@exit_status).to be == 0
13
+ end
14
+
15
+ it "should create ~/.vagrant.d directory" do
16
+ expect(File.directory?("#{ENV['HOME']}/.vagrant.d")).to be == true
17
+ end
18
+
19
+ context "output" do
20
+ subject { @output }
21
+
22
+ it { should =~ /VirtualBox/ }
23
+
24
+ if system 'which vagrant > /dev/null'
25
+ it { should =~ /Found vagrant/ }
26
+ it { should =~ /Vagrant\s*\d+\.\d+\.\d+/ }
27
+ # should mention plugins
28
+ %w{deep_merge vagrant-digitalocean vagrant-vbguest salted-rails}.each do |plugin|
29
+ it { should =~ /plugin #{plugin}/ }
30
+ end
31
+ else
32
+ it { should =~ /Please install vagrant/ }
33
+ end
34
+
35
+ if system 'which VirtualBox > /dev/null'
36
+ it { should =~ /Found VirtualBox/ }
37
+ it { should =~ /VirtualBox\D+\d+\.\d+\.\d+/ }
38
+ else
39
+ it { should =~ /Please install VirtualBox/ }
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,21 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+ config.expect_with :rspec do |c|
12
+ # disable the `should` syntax...
13
+ c.syntax = :expect
14
+ end
15
+
16
+ # Run specs in random order to surface order dependencies. If you find an
17
+ # order dependency and want to debug it, you can fix the order by providing
18
+ # the seed, which is printed after each run.
19
+ # --seed 1234
20
+ config.order = 'random'
21
+ end
@@ -0,0 +1,77 @@
1
+ #require 'rspec'
2
+ require 'spec_helper'
3
+
4
+ require 'salted-rails/config'
5
+
6
+ describe 'SaltedRails::Config' do
7
+
8
+ context '.new with empty project' do
9
+ subject { SaltedRails::Config.new(File.expand_path('../examples/empty_project', File.dirname(__FILE__))) }
10
+
11
+ context 'attributes' do
12
+ %w{ admin_password box ca_path copy_from_home databases domain files forward_agent gems hostname
13
+ logger machine machines mapped_ports memory mirror packages ports private_key_path project_root
14
+ region roles salt_root staging_password sync_vagrant versions }.each do |attr|
15
+ it { should respond_to(attr) }
16
+ it { should respond_to("#{attr}=") }
17
+ end
18
+ end
19
+
20
+ context '#sanitize_dns_name' do
21
+ it 'should lowercase names' do
22
+ expect(subject.sanitize_dns_name('FRED')).to be == 'fred'
23
+ end
24
+
25
+ it 'should replace one or more illegal chars with hyphen' do
26
+ expect(subject.sanitize_dns_name('apple\'s')).to be == 'apple-s'
27
+ expect(subject.sanitize_dns_name('what!_*&fruit')).to be == 'what-fruit'
28
+ end
29
+
30
+ it 'should not leave hyphens on the end' do
31
+ expect(subject.sanitize_dns_name('one-')).to be == 'one'
32
+ expect(subject.sanitize_dns_name('no!!!!')).to be == 'no'
33
+ end
34
+ end
35
+
36
+ describe '.machines' do
37
+ it { expect(subject.machines).to be == [ ] }
38
+ end
39
+
40
+ describe '.machine' do
41
+ it { expect(subject.machine).to be == 'default' }
42
+ end
43
+
44
+ describe '.roles' do
45
+ it { expect(subject.roles).to be == %w{ app web db } }
46
+ end
47
+
48
+ describe '.ports' do
49
+ it { expect(subject.ports).to be == [ 80, 443, 880, 3000, 8808 ] }
50
+ end
51
+
52
+ describe '.files' do
53
+ it { expect(subject.files).to be == [ ] }
54
+ end
55
+
56
+ describe '.gems' do
57
+ it { expect(subject.gems).to be == { } }
58
+ end
59
+
60
+ end
61
+
62
+ context '.new with project having Gemfile' do
63
+ subject { SaltedRails::Config.new(File.expand_path('../examples/project_with_Gemfile', File.dirname(__FILE__))) }
64
+
65
+ describe '.files' do
66
+ it { expect(subject.files).to be == %w{ Gemfile } }
67
+ end
68
+
69
+ describe '.gems' do
70
+ it { expect(subject.gems).to be == { 'mysql' => true } }
71
+ end
72
+
73
+ describe '.roles' do
74
+ it { expect(subject.roles).to be == %w{ app web db mysql } }
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,13 @@
1
+ require 'rspec'
2
+ require 'spec_helper'
3
+
4
+ require 'salted-rails'
5
+
6
+ describe 'SaltedRails' do
7
+
8
+ context "::VESION" do
9
+ subject { SaltedRails::VERSION }
10
+ it { should =~ /^\d+\.\d+\.\d+/ }
11
+ end
12
+
13
+ end
metadata CHANGED
@@ -1,20 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salted-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
5
- prerelease:
4
+ version: 0.0.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ian Heggie
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-31 00:00:00.000000000 Z
11
+ date: 2014-03-24 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: log4r
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
14
27
  - !ruby/object:Gem::Dependency
15
28
  name: bundler
16
29
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
30
  requirements:
19
31
  - - ~>
20
32
  - !ruby/object:Gem::Version
@@ -22,7 +34,6 @@ dependencies:
22
34
  type: :development
23
35
  prerelease: false
24
36
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
37
  requirements:
27
38
  - - ~>
28
39
  - !ruby/object:Gem::Version
@@ -30,7 +41,6 @@ dependencies:
30
41
  - !ruby/object:Gem::Dependency
31
42
  name: rake
32
43
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
44
  requirements:
35
45
  - - ! '>='
36
46
  - !ruby/object:Gem::Version
@@ -38,11 +48,24 @@ dependencies:
38
48
  type: :development
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
52
  - - ! '>='
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.14'
46
69
  description: Provision rails using salt to vagrant or capistrano controlled systems
47
70
  email:
48
71
  - ian@heggie.biz
@@ -51,6 +74,8 @@ extensions: []
51
74
  extra_rdoc_files: []
52
75
  files:
53
76
  - .gitignore
77
+ - .rspec
78
+ - .travis.yml
54
79
  - Gemfile
55
80
  - LICENSE
56
81
  - README.md
@@ -190,31 +215,48 @@ files:
190
215
  - salt/www/nginx/srv/www/admin/robots.txt
191
216
  - salt/www/users.sls
192
217
  - salted-rails.gemspec
218
+ - spec/bin/install_other_plugins
219
+ - spec/bin/install_this_plugin
220
+ - spec/bin/install_vagrant
221
+ - spec/examples/empty_project/.gitkeep
222
+ - spec/examples/project_with_Gemfile/Gemfile
223
+ - spec/integration/init_sh_spec.rb
224
+ - spec/spec_helper.rb
225
+ - spec/unit/config_spec.rb
226
+ - spec/unit/salted_rails_spec.rb
193
227
  homepage: https://github.com/ianheggie/salted-rails
194
228
  licenses:
195
229
  - MIT
230
+ metadata: {}
196
231
  post_install_message:
197
232
  rdoc_options: []
198
233
  require_paths:
199
234
  - lib
200
235
  required_ruby_version: !ruby/object:Gem::Requirement
201
- none: false
202
236
  requirements:
203
237
  - - ! '>='
204
238
  - !ruby/object:Gem::Version
205
239
  version: '0'
206
240
  required_rubygems_version: !ruby/object:Gem::Requirement
207
- none: false
208
241
  requirements:
209
242
  - - ! '>='
210
243
  - !ruby/object:Gem::Version
211
244
  version: '0'
212
245
  requirements: []
213
246
  rubyforge_project:
214
- rubygems_version: 1.8.23
247
+ rubygems_version: 2.2.2
215
248
  signing_key:
216
- specification_version: 3
249
+ specification_version: 4
217
250
  summary: Provision rails using salt to vagrant or capistrano controlled systems. Uses
218
251
  details from .ruby-version, config/database.yml, Gemfile and Gemfile.lock to configure
219
252
  system
220
- test_files: []
253
+ test_files:
254
+ - spec/bin/install_other_plugins
255
+ - spec/bin/install_this_plugin
256
+ - spec/bin/install_vagrant
257
+ - spec/examples/empty_project/.gitkeep
258
+ - spec/examples/project_with_Gemfile/Gemfile
259
+ - spec/integration/init_sh_spec.rb
260
+ - spec/spec_helper.rb
261
+ - spec/unit/config_spec.rb
262
+ - spec/unit/salted_rails_spec.rb