itamae-plugin-recipe-rtn_rbenv 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa4583dde9dc934b2554a177935bd02c6e81ef38
4
- data.tar.gz: cb925ce3e789c05a3a60ba148f95f1f0c806fdb5
3
+ metadata.gz: 235e6a5f2c5eae574d3d7a972faa70e45655500a
4
+ data.tar.gz: 8c313976c8fbeafbeeb6d8bc5c14292a0d99ef6e
5
5
  SHA512:
6
- metadata.gz: 766f509bfb25475476e88b135387a70ca51b80c0f1dbd7b8a50c68b0f00b6b1ee3bf8f13a9591290f5be9c2e31651afe4c56d8cf0209b4c2e83526ea8800a9fd
7
- data.tar.gz: 3bda76b006981ae7da8ed240f7848b76abef535b638cf1b8945ac211163164f6c2bff49d12874f845d0b5fe21151f993d27173a6bd445ae69af7925ab410f2ff
6
+ metadata.gz: 1ce7ee2e210087587c230657c168f6d5b5a1ab9874bc4c6a68173b54043575a18e58a93dd9a267b1d9463a552e5da2c3e39e8ecc51527b66e811db9d61aaa5f8
7
+ data.tar.gz: 514e2f3624458ed6a58540c27f3dc66cf98ceb0b9ec0e1caf354f97284a186582f3a2c176178cf46f3d1309ebd384e87690660a57a88d2def00661bf5e3199e8
data/README.md CHANGED
@@ -38,7 +38,8 @@ include_recipe 'rtn_rbenv::system'
38
38
  "user": "vagrant",
39
39
  "versions": {
40
40
  "2.1.3": [
41
- "bundler": {
41
+ {
42
+ "name": "bundler",
42
43
  "version": "1.7.3",
43
44
  "force": true
44
45
  },
data/Rakefile CHANGED
@@ -11,15 +11,18 @@ namespace :spec do
11
11
  next unless File.directory?(dir)
12
12
  targets << File.basename(dir)
13
13
  end
14
+ platforms = %w[sl6 ubuntu1404]
14
15
 
15
16
  task :all => targets
16
17
  task :default => :all
17
18
 
18
19
  targets.each do |target|
19
- desc "Run serverspec tests to #{target}"
20
- RSpec::Core::RakeTask.new(target.to_sym) do |t|
21
- ENV['TARGET_HOST'] = target
22
- t.pattern = "spec/#{target}/*_spec.rb"
20
+ platforms.each do |platform|
21
+ desc "Run serverspec tests to #{target} in #{platform}"
22
+ RSpec::Core::RakeTask.new(target.to_sym) do |t|
23
+ ENV['TARGET_HOST'] = "#{platform}_#{target}"
24
+ t.pattern = "spec/#{target}/*_spec.rb"
25
+ end
23
26
  end
24
27
  end
25
28
  end
data/Vagrantfile CHANGED
@@ -4,13 +4,26 @@
4
4
  VAGRANTFILE_API_VERSION = "2"
5
5
 
6
6
  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7
- config.vm.box = "sl6"
8
- config.vm.box_url = 'http://files.rutan.info/box/scientific-6-5-x64-virtualbox.box'
9
7
 
10
- config.vm.define :user do |c|
8
+ config.vm.define :sl6_user do |c|
9
+ c.vm.box = "sl6"
10
+ c.vm.box_url = 'http://files.rutan.info/box/scientific-6-5-x64-virtualbox.box'
11
11
  c.vm.network :private_network, ip: '192.168.33.11'
12
12
  end
13
- config.vm.define :system do |c|
13
+ config.vm.define :sl6_system do |c|
14
+ c.vm.box = "sl6"
15
+ c.vm.box_url = 'http://files.rutan.info/box/scientific-6-5-x64-virtualbox.box'
14
16
  c.vm.network :private_network, ip: '192.168.33.12'
15
17
  end
18
+
19
+ config.vm.define :ubuntu1404_user do |c|
20
+ c.vm.box = "ubuntu1404"
21
+ c.vm.box_url = 'https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box'
22
+ c.vm.network :private_network, ip: '192.168.33.21'
23
+ end
24
+ config.vm.define :ubuntu1404_system do |c|
25
+ c.vm.box = "ubuntu1404"
26
+ c.vm.box_url = 'https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box'
27
+ c.vm.network :private_network, ip: '192.168.33.22'
28
+ end
16
29
  end
@@ -8,9 +8,9 @@ packages << 'git'
8
8
 
9
9
  case os[:family]
10
10
  when %r(debian|ubuntu)
11
- packages << 'zlib-dev'
12
- packages << 'openssl-dev'
13
- packages << 'readline-dev'
11
+ packages << 'zlib1g-dev'
12
+ packages << 'libssl-dev'
13
+ packages << 'libreadline6-dev'
14
14
  when %r(redhat|fedora)
15
15
  packages << 'zlib-devel'
16
16
  packages << 'openssl-devel'
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+
3
+ RBENV_DEFAULT_PROFILE_PATH = '/etc/profile.d/rbenv.sh'
4
+
5
+ # install rbenv and ruby_build
6
+ # @param name [String] install directory
7
+ # @param user [String] install user name
8
+ # @param profile_path [String] bash_profile path
9
+ define :rbenv_install, user: nil, profile_path: RBENV_DEFAULT_PROFILE_PATH do
10
+ params = self.params
11
+
12
+ git "#{params[:name]}" do
13
+ repository 'https://github.com/sstephenson/rbenv.git'
14
+ user params[:user] if params[:user]
15
+ end
16
+
17
+ git "#{params[:name]}/plugins/ruby_build" do
18
+ repository 'https://github.com/sstephenson/ruby-build.git'
19
+ user params[:user] if params[:user]
20
+ end
21
+
22
+ setting = <<"EOS"
23
+ export RBENV_ROOT=#{params[:name]}
24
+ export PATH="$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH"
25
+ eval "$(rbenv init -)"
26
+ EOS
27
+
28
+ execute 'add rbenv settings' do
29
+ command "echo '#{setting}' >> #{params[:profile_path]}"
30
+ user params[:user] if params[:user]
31
+ not_if "test `touch #{params[:profile_path]} && cat #{params[:profile_path]} | grep 'rbenv' -c` != 0"
32
+ end
33
+ end
34
+
35
+ # install ruby with rbenv
36
+ # @param name [String] ruby version
37
+ # @param user [String] install user name
38
+ # @param profile_path [String] bash_profile path
39
+ define :ruby_install, user: nil, profile_path: RBENV_DEFAULT_PROFILE_PATH do
40
+ params = self.params
41
+
42
+ execute "ruby install #{params[:name]}" do
43
+ command ". #{params[:profile_path]} && rbenv install #{params[:name]}"
44
+ user params[:user] if params[:user]
45
+ not_if "test `. #{params[:profile_path]} && rbenv versions | grep '#{params[:name]}' -c` != 0"
46
+ end
47
+ end
48
+
49
+ # install rubygems with rbenv
50
+ # @param name [String] gem name
51
+ # @param version [String] gem version
52
+ # @param ruby_version [String] use ruby version
53
+ # @param user [String] install user name
54
+ # @param profile_path [String] bash_profile path
55
+ define :gem_install, version: nil, ruby_version: nil, force: nil, user: nil, profile_path: RBENV_DEFAULT_PROFILE_PATH do
56
+ params = self.params
57
+
58
+ execute "gem install #{params[:name]}" do
59
+ command ". #{params[:profile_path]} && rbenv shell #{params[:ruby_version]} && gem install #{params[:name]} #{params[:version] ? "-v #{params[:version]}" : ''} #{params[:force] ? '--force' : ''}"
60
+ user params[:user] if params[:user]
61
+ end
62
+ end
@@ -1,52 +1,34 @@
1
1
  # encoding: utf-8
2
+ include_recipe './resource.rb'
2
3
  include_recipe 'rtn_rbenv::common'
3
4
 
4
5
  # load setting
5
6
  RBENV_ROOT = '/usr/local/rbenv'
6
7
  RBENV_PROFILE_PATH = '/etc/profile.d/rbenv.sh'
7
8
 
8
- RBENV_BASH_SETTING = <<"EOS"
9
- export RBENV_ROOT=#{RBENV_ROOT}
10
- export PATH="$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH"
11
- eval "$(rbenv init -)"
12
- EOS
13
-
14
- # define
15
- def ruby_install(version)
16
- execute "ruby install #{version}" do
17
- command "source #{RBENV_PROFILE_PATH} && rbenv install #{version}"
18
- not_if "test `source #{RBENV_PROFILE_PATH} && rbenv versions | grep '#{version}' -c` != 0"
19
- end
20
- end
21
-
22
- def gem_install(ruby_version, name, options = {})
23
- execute "gem install #{name}" do
24
- command "source #{RBENV_PROFILE_PATH} && rbenv shell #{ruby_version} && gem install #{name} #{options[:version] ? "-v #{options[:version]}" : ''} #{options[:force] ? '--force' : ''}"
25
- end
26
- end
27
-
28
9
  # install rbenv and ruby_build
29
- git "#{RBENV_ROOT}" do
30
- repository 'https://github.com/sstephenson/rbenv.git'
31
- end
32
-
33
- git "#{RBENV_ROOT}/plugins/ruby_build" do
34
- repository 'https://github.com/sstephenson/ruby-build.git'
35
- end
36
-
37
- execute 'add rbenv settings to /etc/profile.d/rbenv.sh' do
38
- command "echo '#{RBENV_BASH_SETTING}' >> #{RBENV_PROFILE_PATH}"
39
- not_if "test `touch #{RBENV_PROFILE_PATH} && cat #{RBENV_PROFILE_PATH} | grep 'rbenv' -c` != 0"
10
+ rbenv_install RBENV_ROOT do
11
+ profile_path RBENV_PROFILE_PATH
40
12
  end
41
13
 
42
14
  # install Ruby and Gems
43
15
  (node['rtn_rbenv']['versions'] || {}).each do |ruby_version, gems|
44
- ruby_install ruby_version
16
+ ruby_install ruby_version do
17
+ profile_path RBENV_PROFILE_PATH
18
+ end
45
19
  gems.each do |gem|
46
20
  if gem.kind_of?(Hash)
47
- gem_install ruby_version, gem['name'], :version => gem['version'], :force => gem['force']
21
+ gem_install gem['name'] do
22
+ self.ruby_version ruby_version
23
+ version gem['version'] if gem['version']
24
+ force gem['force'] if gem['force']
25
+ profile_path RBENV_PROFILE_PATH
26
+ end
48
27
  else
49
- gem_install ruby_version, gem
28
+ gem_install gem do
29
+ self.ruby_version ruby_version
30
+ profile_path RBENV_PROFILE_PATH
31
+ end
50
32
  end
51
33
  end
52
34
  end
@@ -54,6 +36,6 @@ end
54
36
  # set global
55
37
  if node['rtn_rbenv']['global']
56
38
  execute "rbenv global #{node['rtn_rbenv']['global']}" do
57
- command "source #{RBENV_PROFILE_PATH} && rbenv global #{node['rtn_rbenv']['global']}"
39
+ command ". #{RBENV_PROFILE_PATH} && rbenv global #{node['rtn_rbenv']['global']}"
58
40
  end
59
41
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ include_recipe './resource.rb'
2
3
  include_recipe 'rtn_rbenv::common'
3
4
 
4
5
  # load setting
@@ -7,53 +8,33 @@ RBENV_USER_HOME = "/home/#{RBENV_USER}"
7
8
  RBENV_ROOT = "#{RBENV_USER_HOME}/.rbenv"
8
9
  RBENV_PROFILE_PATH = "#{RBENV_USER_HOME}/.bash_profile"
9
10
 
10
- RBENV_BASH_SETTING = <<"EOS"
11
- export RBENV_ROOT=#{RBENV_ROOT}
12
- export PATH="$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH"
13
- eval "$(rbenv init -)"
14
- EOS
15
-
16
- # define
17
- def ruby_install(version)
18
- execute "ruby install #{version}" do
19
- command "source #{RBENV_PROFILE_PATH} && rbenv install #{version}"
20
- user RBENV_USER
21
- not_if "test `source #{RBENV_PROFILE_PATH} && rbenv versions | grep '#{version}' -c` != 0"
22
- end
23
- end
24
-
25
- def gem_install(ruby_version, name, options = {})
26
- execute "gem install #{name}" do
27
- command "source #{RBENV_PROFILE_PATH} && rbenv shell #{ruby_version} && gem install #{name} #{options[:version] ? "-v #{options[:version]}" : ''} #{options[:force] ? '--force' : ''}"
28
- user RBENV_USER
29
- end
30
- end
31
-
32
11
  # install rbenv and ruby_build
33
- git "#{RBENV_ROOT}" do
34
- repository 'https://github.com/sstephenson/rbenv.git'
12
+ rbenv_install RBENV_ROOT do
35
13
  user RBENV_USER
36
- end
37
-
38
- git "#{RBENV_ROOT}/plugins/ruby_build" do
39
- repository 'https://github.com/sstephenson/ruby-build.git'
40
- user RBENV_USER
41
- end
42
-
43
- execute 'add rbenv settings to .bash_profile' do
44
- command "echo '#{RBENV_BASH_SETTING}' >> #{RBENV_PROFILE_PATH}"
45
- user RBENV_USER
46
- not_if "test `touch #{RBENV_PROFILE_PATH} && cat #{RBENV_PROFILE_PATH} | grep 'rbenv' -c` != 0"
14
+ profile_path RBENV_PROFILE_PATH
47
15
  end
48
16
 
49
17
  # install Ruby and Gems
50
18
  (node['rtn_rbenv']['versions'] || {}).each do |ruby_version, gems|
51
- ruby_install ruby_version
19
+ ruby_install ruby_version do
20
+ user RBENV_USER
21
+ profile_path RBENV_PROFILE_PATH
22
+ end
52
23
  gems.each do |gem|
53
24
  if gem.kind_of?(Hash)
54
- gem_install ruby_version, gem['name'], :version => gem['version'], :force => gem['force']
25
+ gem_install gem['name'] do
26
+ self.ruby_version ruby_version
27
+ version gem['version'] if gem['version']
28
+ force gem['force'] if gem['force']
29
+ user RBENV_USER
30
+ profile_path RBENV_PROFILE_PATH
31
+ end
55
32
  else
56
- gem_install ruby_version, gem
33
+ gem_install gem do
34
+ self.ruby_version ruby_version
35
+ user RBENV_USER
36
+ profile_path RBENV_PROFILE_PATH
37
+ end
57
38
  end
58
39
  end
59
40
  end
@@ -61,7 +42,7 @@ end
61
42
  # set global
62
43
  if node['rtn_rbenv']['global']
63
44
  execute "rbenv global #{node['rtn_rbenv']['global']}" do
64
- command "source #{RBENV_PROFILE_PATH} && rbenv global #{node['rtn_rbenv']['global']}"
45
+ command ". #{RBENV_PROFILE_PATH} && rbenv global #{node['rtn_rbenv']['global']}"
65
46
  user RBENV_USER
66
47
  end
67
48
  end
@@ -2,7 +2,7 @@ module Itamae
2
2
  module Plugin
3
3
  module Recipe
4
4
  module RtnRbenv
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.2"
6
6
  end
7
7
  end
8
8
  end
data/spec/spec_helper.rb CHANGED
@@ -16,9 +16,10 @@ else
16
16
  end
17
17
 
18
18
  host = ENV['TARGET_HOST']
19
+ target = host.split('_')[1]
19
20
 
20
21
  `vagrant up #{host}`
21
- system("bundle exec itamae ssh -h #{host} --vagrant '#{File.expand_path("../#{host}/role.rb", __FILE__)}' -j '#{File.expand_path("../#{host}/node.json", __FILE__)}'")
22
+ system("bundle exec itamae ssh -h #{host} --vagrant '#{File.expand_path("../#{target}/role.rb", __FILE__)}' -j '#{File.expand_path("../#{target}/node.json", __FILE__)}'")
22
23
 
23
24
  config = Tempfile.new('', Dir.tmpdir)
24
25
  `vagrant ssh-config #{host} > #{config.path}`
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "rtn_rbenv": {
3
3
  "versions": {
4
- "2.1.3": [
4
+ "2.1.4": [
5
5
  "sinatra"
6
6
  ],
7
- "2.1.0": [
7
+ "2.1.3": [
8
8
  {
9
9
  "name": "rake",
10
10
  "version": "10.2.0",
@@ -12,6 +12,6 @@
12
12
  }
13
13
  ]
14
14
  },
15
- "global": "2.1.0"
15
+ "global": "2.1.3"
16
16
  }
17
17
  }
@@ -1,28 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe command('which rbenv') do
3
+ describe command('. /etc/profile && which rbenv') do
4
4
  let(:disable_sudo) { true }
5
5
  its(:stdout) { should match '/usr/local/rbenv/bin/rbenv' }
6
6
  end
7
7
 
8
- %w[2.1.3 2.1.0].each do |ruby_version|
9
- describe command("source /etc/profile && rbenv versions | grep '#{ruby_version}'") do
8
+ %w[2.1.4 2.1.3].each do |ruby_version|
9
+ describe command(". /etc/profile && rbenv versions | grep '#{ruby_version}'") do
10
10
  let(:disable_sudo) { true }
11
11
  its(:stdout) { should match /#{Regexp.escape(ruby_version)}/ }
12
12
  end
13
13
  end
14
14
 
15
- describe command("source /etc/profile && rbenv shell 2.1.3 && gem list") do
15
+ describe command(". /etc/profile && rbenv shell 2.1.4 && gem list") do
16
16
  let(:disable_sudo) { true }
17
17
  its(:stdout) { should match /sinatra/ }
18
18
  end
19
19
 
20
- describe command("source /etc/profile && rbenv shell 2.1.0 && gem list | grep 'rake'") do
20
+ describe command(". /etc/profile && rbenv shell 2.1.3 && gem list | grep 'rake'") do
21
21
  let(:disable_sudo) { true }
22
22
  its(:stdout) { should match /10\.2\.0/ }
23
23
  end
24
24
 
25
- describe command("source /etc/profile && ruby -v") do
25
+ describe command(". /etc/profile && ruby -v") do
26
26
  let(:disable_sudo) { true }
27
- its(:stdout) { should match /2\.1\.0/ }
27
+ its(:stdout) { should match /2\.1\.3/ }
28
28
  end
data/spec/user/node.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "rtn_rbenv": {
3
3
  "user": "vagrant",
4
4
  "versions": {
5
- "2.1.3": [
5
+ "2.1.4": [
6
6
  "sinatra"
7
7
  ],
8
- "2.1.0": [
8
+ "2.1.3": [
9
9
  {
10
10
  "name": "rake",
11
11
  "version": "10.2.0",
@@ -13,6 +13,6 @@
13
13
  }
14
14
  ]
15
15
  },
16
- "global": "2.1.3"
16
+ "global": "2.1.4"
17
17
  }
18
18
  }
@@ -1,29 +1,29 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe command('source /home/vagrant/.bash_profile; which rbenv') do
3
+ describe command('. /home/vagrant/.bash_profile; which rbenv') do
4
4
  let(:disable_sudo) { true }
5
5
  its(:stdout) { should match '/home/vagrant/.rbenv/bin/rbenv' }
6
6
  end
7
7
 
8
- %w[2.1.3 2.1.0].each do |ruby_version|
9
- describe command("source /home/vagrant/.bash_profile; rbenv versions | grep '#{ruby_version}'") do
8
+ %w[2.1.4 2.1.3].each do |ruby_version|
9
+ describe command(". /home/vagrant/.bash_profile; rbenv versions | grep '#{ruby_version}'") do
10
10
  let(:disable_sudo) { true }
11
11
  its(:stdout) { should match /#{Regexp.escape(ruby_version)}/ }
12
12
  end
13
13
  end
14
14
 
15
- describe command("source /home/vagrant/.bash_profile; rbenv shell 2.1.3; gem list | grep 'sinatra'") do
15
+ describe command(". /home/vagrant/.bash_profile; rbenv shell 2.1.4; gem list | grep 'sinatra'") do
16
16
  let(:disable_sudo) { true }
17
17
  its(:stdout) { should match /sinatra/ }
18
18
  end
19
19
 
20
- describe command("source /home/vagrant/.bash_profile; rbenv shell 2.1.0; gem list | grep 'rake'") do
20
+ describe command(". /home/vagrant/.bash_profile; rbenv shell 2.1.3; gem list | grep 'rake'") do
21
21
  let(:disable_sudo) { true }
22
22
  its(:stdout) { should match /10\.2\.0/ }
23
23
  end
24
24
 
25
- describe command("source /home/vagrant/.bash_profile; ruby -v") do
25
+ describe command(". /home/vagrant/.bash_profile; ruby -v") do
26
26
  let(:disable_sudo) { true }
27
- its(:stdout) { should match /2\.1\.3/ }
27
+ its(:stdout) { should match /2\.1\.4/ }
28
28
  end
29
29
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae-plugin-recipe-rtn_rbenv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ru/MuckRu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-11 00:00:00.000000000 Z
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: itamae
@@ -82,6 +82,7 @@ files:
82
82
  - itamae-plugin-recipe-rtn_rbenv.gemspec
83
83
  - lib/itamae/plugin/recipe/rtn_rbenv.rb
84
84
  - lib/itamae/plugin/recipe/rtn_rbenv/common.rb
85
+ - lib/itamae/plugin/recipe/rtn_rbenv/resource.rb
85
86
  - lib/itamae/plugin/recipe/rtn_rbenv/system.rb
86
87
  - lib/itamae/plugin/recipe/rtn_rbenv/user.rb
87
88
  - lib/itamae/plugin/recipe/rtn_rbenv/version.rb