itamae-plugin-recipe-rvm 1.0.0
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 +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +18 -0
- data/README.md +170 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/examples/rvm_system_sample/Vagrantfile +11 -0
- data/examples/rvm_system_sample/cookbooks/rvm_sample/default.rb +39 -0
- data/examples/rvm_system_sample/node.yml +7 -0
- data/examples/rvm_user_sample/Vagrantfile +11 -0
- data/examples/rvm_user_sample/cookbooks/rvm_sample/default.rb +39 -0
- data/examples/rvm_user_sample/node.yml +8 -0
- data/itamae-plugin-recipe-rvm.gemspec +24 -0
- data/lib/itamae/plugin/recipe/rvm.rb +0 -0
- data/lib/itamae/plugin/recipe/rvm/common.rb +12 -0
- data/lib/itamae/plugin/recipe/rvm/system.rb +17 -0
- data/lib/itamae/plugin/recipe/rvm/user.rb +16 -0
- data/lib/itamae/plugin/recipe/rvm/version.rb +9 -0
- data/lib/itamae/plugin/resource/rvm_config.rb +61 -0
- data/lib/itamae/plugin/resource/rvm_execute.rb +18 -0
- data/lib/itamae/plugin/resource/rvm_gem_package.rb +21 -0
- data/lib/itamae/plugin/resource/rvm_gemset_create.rb +28 -0
- data/lib/itamae/plugin/resource/rvm_get.rb +77 -0
- data/lib/itamae/plugin/resource/rvm_install.rb +23 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 95388a31e4549da8ccb945ea0cc0e31d636ca405
|
4
|
+
data.tar.gz: dfc26fbc67a13f2da2cab977d608beaec90ad060
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9d218d31f70707de0a3305083ce47b0822c61edc18e450efa6361893a7707df0fe4e6bf3f2447389fdc65d37940a0a90cf1c3c72e1e77cd60520663e41c2da41
|
7
|
+
data.tar.gz: 1c653eccdd7b41d7a66c25275bc8575ded25b582247e7e561255b078b6e1f754c98aca6467c3472173f02af8cdb47ed1d16e5ce38b3094e9bccab0fed821cfbe
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
itamae-plugin-recipe-rvm
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.2.2
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'bundler', '1.10.5'
|
4
|
+
gem 'rake', '~> 10.0'
|
5
|
+
gem 'rspec', require: false
|
6
|
+
gem 'cucumber', require: false
|
7
|
+
gem 'aruba', require: false
|
8
|
+
gem 'serverspec', require: false
|
9
|
+
gem 'docker-api', require: false
|
10
|
+
gem 'highline', require: false
|
11
|
+
|
12
|
+
gem 'pry-doc' #, require: false
|
13
|
+
gem 'pry-byebug' #, require: false
|
14
|
+
gem 'pry-stack_explorer' #, require: false
|
15
|
+
|
16
|
+
# Specify your gem's dependencies in itamae-plugin-recipe-rvm.gemspec
|
17
|
+
gemspec
|
18
|
+
|
data/README.md
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
Itamae::Plugin::Recipe::Rvm
|
2
|
+
========
|
3
|
+
|
4
|
+
Itamae plugin for Rvm.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
--------
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
``` ruby
|
12
|
+
gem 'itamae-plugin-recipe-rvm'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```sh
|
18
|
+
$ bundle
|
19
|
+
```
|
20
|
+
|
21
|
+
Usage1: System RVM
|
22
|
+
--------
|
23
|
+
|
24
|
+
Include your recipe (ex:`cookbooks/rvm/default.rb`).
|
25
|
+
``` ruby
|
26
|
+
include_recipe 'rvm::system'
|
27
|
+
```
|
28
|
+
|
29
|
+
Then execute itamae.
|
30
|
+
|
31
|
+
For example.
|
32
|
+
|
33
|
+
Vagrant:
|
34
|
+
``` sh
|
35
|
+
$ itamae ssh --vagrant --host {YOUR_HOST_NAME} cookbooks/rvm/default.rb
|
36
|
+
```
|
37
|
+
|
38
|
+
If you have to config params then You should set node.yml
|
39
|
+
|
40
|
+
``` yaml
|
41
|
+
rvm:
|
42
|
+
version: 1.26.11
|
43
|
+
gemset_create_on_use_flag: 1
|
44
|
+
install_on_use_flag: 1
|
45
|
+
project_rvmrc: 1
|
46
|
+
auto_reload_flag: 2
|
47
|
+
autoinstall_bundler_flag: 1
|
48
|
+
```
|
49
|
+
Then execute itamae with --node-yaml= option.
|
50
|
+
|
51
|
+
For example.
|
52
|
+
|
53
|
+
Vagrant:
|
54
|
+
``` sh
|
55
|
+
$ itamae ssh --vagrant --host {YOUR_HOST_NAME} cookbooks/rvm/default.rb --node-yaml=node.yml
|
56
|
+
```
|
57
|
+
|
58
|
+
If you install ruby and create gemset, append your recipe.
|
59
|
+
|
60
|
+
``` ruby
|
61
|
+
rvm_install '2.2' do
|
62
|
+
user 'root'
|
63
|
+
end
|
64
|
+
|
65
|
+
rvm_gemset_create 'sample' do
|
66
|
+
user 'root'
|
67
|
+
ruby_version '2.2'
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
And you install gem and execute commands.
|
72
|
+
|
73
|
+
``` ruby
|
74
|
+
rvm_execute 'ruby -v' do
|
75
|
+
user 'root'
|
76
|
+
rvm_use '2.2@sample'
|
77
|
+
end
|
78
|
+
|
79
|
+
rvm_gem_package 'rspec' do
|
80
|
+
user 'root'
|
81
|
+
rvm_use '2.2@sample'
|
82
|
+
end
|
83
|
+
|
84
|
+
rvm_execute 'gem list' do
|
85
|
+
user 'root'
|
86
|
+
rvm_use '2.2@sample'
|
87
|
+
end
|
88
|
+
|
89
|
+
rvm_execute 'rspec -v' do
|
90
|
+
user 'root'
|
91
|
+
rvm_use '2.2@sample'
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
95
|
+
Usage2: User RVM
|
96
|
+
--------
|
97
|
+
|
98
|
+
Include your recipe (ex:`cookbooks/rvm/default.rb`).
|
99
|
+
``` ruby
|
100
|
+
include_recipe 'rvm::user'
|
101
|
+
```
|
102
|
+
|
103
|
+
And add config to `node.yml`
|
104
|
+
|
105
|
+
``` yaml
|
106
|
+
rvm:
|
107
|
+
user: vagrant
|
108
|
+
```
|
109
|
+
|
110
|
+
Then execute itamae.
|
111
|
+
|
112
|
+
For example.
|
113
|
+
|
114
|
+
Vagrant:
|
115
|
+
|
116
|
+
``` sh
|
117
|
+
$ itamae ssh --vagrant --host {YOUR_HOST_NAME} cookbooks/rvm/default.rb --node-yaml=node.yml
|
118
|
+
```
|
119
|
+
|
120
|
+
If you have to config params then You should set node.yml
|
121
|
+
|
122
|
+
``` yaml
|
123
|
+
rvm:
|
124
|
+
user: vagrant
|
125
|
+
version: 1.26.11
|
126
|
+
gemset_create_on_use_flag: 1
|
127
|
+
install_on_use_flag: 1
|
128
|
+
project_rvmrc: 1
|
129
|
+
auto_reload_flag: 2
|
130
|
+
autoinstall_bundler_flag: 1
|
131
|
+
```
|
132
|
+
|
133
|
+
Then re-execute itamae.
|
134
|
+
|
135
|
+
If you install ruby and create gemset, append your recipe.
|
136
|
+
|
137
|
+
``` ruby
|
138
|
+
rvm_install '2.2' do
|
139
|
+
user 'vagrant'
|
140
|
+
end
|
141
|
+
|
142
|
+
rvm_gemset_create 'sample' do
|
143
|
+
user 'vagrant'
|
144
|
+
ruby_version '2.2'
|
145
|
+
end
|
146
|
+
```
|
147
|
+
|
148
|
+
And you install gem and execute commands.
|
149
|
+
|
150
|
+
``` ruby
|
151
|
+
rvm_execute 'ruby -v' do
|
152
|
+
user 'vagrant'
|
153
|
+
rvm_use '2.2@sample'
|
154
|
+
end
|
155
|
+
|
156
|
+
rvm_gem_package 'rspec' do
|
157
|
+
user 'vagrant'
|
158
|
+
rvm_use '2.2@sample'
|
159
|
+
end
|
160
|
+
|
161
|
+
rvm_execute 'gem list' do
|
162
|
+
user 'vagrant'
|
163
|
+
rvm_use '2.2@sample'
|
164
|
+
end
|
165
|
+
|
166
|
+
rvm_execute 'rspec -v' do
|
167
|
+
user 'vagrant'
|
168
|
+
rvm_use '2.2@sample'
|
169
|
+
end
|
170
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "itamae/plugin/recipe/rvm"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure(2) do |config|
|
5
|
+
config.vm.box = 'centos7'
|
6
|
+
config.vm.box_url = 'https://f0fff3908f081cb6461b407be80daf97f07ac418.googledrive.com/host/0BwtuV7VyVTSkUG1PM3pCeDJ4dVE/centos7.box'
|
7
|
+
config.vm.network 'private_network', ip: '192.168.33.10'
|
8
|
+
config.vm.provider 'virtualbox' do |vb|
|
9
|
+
vb.memory = '1024'
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
include_recipe 'rvm::system'
|
2
|
+
|
3
|
+
rvm_get '1.26.11' do
|
4
|
+
user 'root'
|
5
|
+
end
|
6
|
+
|
7
|
+
rvm_config '.rvmrc' do
|
8
|
+
user 'root'
|
9
|
+
end
|
10
|
+
|
11
|
+
rvm_install '2.2' do
|
12
|
+
user 'root'
|
13
|
+
end
|
14
|
+
|
15
|
+
rvm_gemset_create 'sample' do
|
16
|
+
user 'root'
|
17
|
+
ruby_version '2.2'
|
18
|
+
end
|
19
|
+
|
20
|
+
rvm_execute 'ruby -v' do
|
21
|
+
user 'root'
|
22
|
+
rvm_use '2.2@sample'
|
23
|
+
end
|
24
|
+
|
25
|
+
rvm_gem_package 'rspec' do
|
26
|
+
user 'root'
|
27
|
+
rvm_use '2.2@sample'
|
28
|
+
end
|
29
|
+
|
30
|
+
rvm_execute 'gem list' do
|
31
|
+
user 'root'
|
32
|
+
rvm_use '2.2@sample'
|
33
|
+
end
|
34
|
+
|
35
|
+
rvm_execute 'rspec -v' do
|
36
|
+
user 'root'
|
37
|
+
rvm_use '2.2@sample'
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure(2) do |config|
|
5
|
+
config.vm.box = 'centos7'
|
6
|
+
config.vm.box_url = 'https://f0fff3908f081cb6461b407be80daf97f07ac418.googledrive.com/host/0BwtuV7VyVTSkUG1PM3pCeDJ4dVE/centos7.box'
|
7
|
+
config.vm.network 'private_network', ip: '192.168.33.10'
|
8
|
+
config.vm.provider 'virtualbox' do |vb|
|
9
|
+
vb.memory = '1024'
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
include_recipe 'rvm::user'
|
2
|
+
|
3
|
+
rvm_get '1.26.11' do
|
4
|
+
user 'vagrant'
|
5
|
+
end
|
6
|
+
|
7
|
+
rvm_config '.rvmrc' do
|
8
|
+
user 'vagrant'
|
9
|
+
end
|
10
|
+
|
11
|
+
rvm_install '2.2' do
|
12
|
+
user 'vagrant'
|
13
|
+
end
|
14
|
+
|
15
|
+
rvm_gemset_create 'sample' do
|
16
|
+
user 'vagrant'
|
17
|
+
ruby_version '2.2'
|
18
|
+
end
|
19
|
+
|
20
|
+
rvm_execute 'ruby -v' do
|
21
|
+
user 'vagrant'
|
22
|
+
rvm_use '2.2@sample'
|
23
|
+
end
|
24
|
+
|
25
|
+
rvm_gem_package 'rspec' do
|
26
|
+
user 'vagrant'
|
27
|
+
rvm_use '2.2@sample'
|
28
|
+
end
|
29
|
+
|
30
|
+
rvm_execute 'gem list' do
|
31
|
+
user 'vagrant'
|
32
|
+
rvm_use '2.2@sample'
|
33
|
+
end
|
34
|
+
|
35
|
+
rvm_execute 'rspec -v' do
|
36
|
+
user 'vagrant'
|
37
|
+
rvm_use '2.2@sample'
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'itamae/plugin/recipe/rvm/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'itamae-plugin-recipe-rvm'
|
8
|
+
spec.version = Itamae::Plugin::Recipe::Rvm::VERSION
|
9
|
+
spec.authors = ['Takahiro HAMAGUCHI']
|
10
|
+
spec.email = ['tk.hamaguchi@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'RVM installer with itemae'
|
13
|
+
spec.description = 'RVM installer with itemae.'
|
14
|
+
spec.homepage = 'https://github.com/tk-hamaguchi/itamae-plugin-recipe-rvm'
|
15
|
+
|
16
|
+
spec.licenses = ['MIT']
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_runtime_dependency 'itamae', '~> 1.6', '>= 1.6.1'
|
24
|
+
end
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'itamae/plugin/resource/rvm_get'
|
2
|
+
require 'itamae/plugin/resource/rvm_install'
|
3
|
+
require 'itamae/plugin/resource/rvm_gemset_create'
|
4
|
+
require 'itamae/plugin/resource/rvm_execute'
|
5
|
+
require 'itamae/plugin/resource/rvm_gem_package'
|
6
|
+
require 'itamae/plugin/resource/rvm_config'
|
7
|
+
|
8
|
+
package 'curl'
|
9
|
+
package 'git'
|
10
|
+
package 'which'
|
11
|
+
|
12
|
+
node['rvm'] ||= {}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
include_recipe 'rvm::common'
|
2
|
+
|
3
|
+
package 'sudo'
|
4
|
+
|
5
|
+
rvm_get node['rvm']['version'] do
|
6
|
+
user 'root'
|
7
|
+
end
|
8
|
+
|
9
|
+
rvm_config '/etc/rvmrc' do
|
10
|
+
user 'root'
|
11
|
+
gemset_create_on_use_flag node['rvm']['gemset_create_on_use_flag']
|
12
|
+
install_on_use_flag node['rvm']['install_on_use_flag']
|
13
|
+
project_rvmrc node['rvm']['project_rvmrc']
|
14
|
+
auto_reload_flag node['rvm']['auto_reload_flag']
|
15
|
+
autoinstall_bundler_flag node['rvm']['autoinstall_bundler_flag']
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
include_recipe 'rvm::common'
|
2
|
+
|
3
|
+
if node['rvm']['user']
|
4
|
+
rvm_get node['rvm']['version'] do
|
5
|
+
user node['rvm']['user']
|
6
|
+
end
|
7
|
+
|
8
|
+
rvm_config '.rvmrc' do
|
9
|
+
user node['rvm']['user']
|
10
|
+
gemset_create_on_use_flag node['rvm']['gemset_create_on_use_flag']
|
11
|
+
install_on_use_flag node['rvm']['install_on_use_flag']
|
12
|
+
project_rvmrc node['rvm']['project_rvmrc']
|
13
|
+
auto_reload_flag node['rvm']['auto_reload_flag']
|
14
|
+
autoinstall_bundler_flag node['rvm']['autoinstall_bundler_flag']
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Itamae::Plugin::Resource
|
2
|
+
class RvmConfig < ::Itamae::Resource::File
|
3
|
+
define_attribute :action, default: %i(create edit)
|
4
|
+
define_attribute :install_on_use_flag, type: Integer, default: 1
|
5
|
+
define_attribute :project_rvmrc, type: Integer, default: 1
|
6
|
+
define_attribute :gemset_create_on_use_flag, type: Integer, default: 1
|
7
|
+
define_attribute :auto_reload_flag, type: Integer, default: 2
|
8
|
+
define_attribute :autoinstall_bundler_flag, type: Integer, default: 1
|
9
|
+
|
10
|
+
def pre_action
|
11
|
+
user = attributes.user
|
12
|
+
unless user
|
13
|
+
user = run_command('id -un').stdout.strip
|
14
|
+
end
|
15
|
+
::Itamae.logger.debug "user: #{user}"
|
16
|
+
|
17
|
+
if rvm_path == '/usr/local/rvm'
|
18
|
+
attributes.path = '/etc/rvmrc'
|
19
|
+
else
|
20
|
+
attributes.path = '.rvmrc'
|
21
|
+
end
|
22
|
+
::Itamae.logger.debug "attributes.path: #{attributes.path}"
|
23
|
+
|
24
|
+
case @current_action
|
25
|
+
when :create
|
26
|
+
attributes.exist = true
|
27
|
+
when :delete
|
28
|
+
attributes.exist = false
|
29
|
+
when :edit
|
30
|
+
attributes.exist = true
|
31
|
+
|
32
|
+
content = backend.receive_file(attributes.path)
|
33
|
+
%w(rvm_install_on_use_flag rvm_project_rvmrc rvm_gemset_create_on_use_flag rvm_auto_reload_flag rvm_autoinstall_bundler_flag).each do |key|
|
34
|
+
content.gsub!(/[ \t]*#{key}[ \t]*=[ \t]*\w+[ \t]*\n?/,'')
|
35
|
+
end
|
36
|
+
content.gsub!(/\s*\z/,'')
|
37
|
+
content.concat(<<-"EOS".gsub(/^\s+\|/, ''))
|
38
|
+
|
|
39
|
+
|rvm_install_on_use_flag=#{attributes.install_on_use_flag || 1}
|
40
|
+
|rvm_project_rvmrc=#{attributes.project_rvmrc || 1}
|
41
|
+
|rvm_gemset_create_on_use_flag=#{attributes.gemset_create_on_use_flag || 1}
|
42
|
+
|rvm_auto_reload_flag=#{attributes.auto_reload_flag || 2}
|
43
|
+
|rvm_autoinstall_bundler_flag=#{attributes.autoinstall_bundler_flag || 1}
|
44
|
+
EOS
|
45
|
+
attributes.content = content
|
46
|
+
end
|
47
|
+
|
48
|
+
send_tempfile
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def rvm_path
|
54
|
+
current.rvm_path ||= begin
|
55
|
+
match = run_command('/bin/bash --login -c "echo \$rvm_path"').stdout.match(/^(\/.+)$/)
|
56
|
+
return nil unless match
|
57
|
+
match[1].strip
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Itamae::Plugin::Resource
|
2
|
+
class RvmExecute < ::Itamae::Resource::Execute
|
3
|
+
define_attribute :rvm_use, type: String, default: 'default'
|
4
|
+
|
5
|
+
def set_current_attributes
|
6
|
+
run_command('/bin/bash --login -c "which rvm-shell"', error: false)
|
7
|
+
.stdout.strip.each_line do |line|
|
8
|
+
current.rvm_shell = line
|
9
|
+
end
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def action_run(options)
|
14
|
+
attributes.command = "#{current.rvm_shell} #{attributes.rvm_use} -c '#{attributes.command}'"
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Itamae::Plugin::Resource
|
2
|
+
class RvmGemPackage < ::Itamae::Resource::GemPackage
|
3
|
+
define_attribute :rvm_use, type: String, default: 'default'
|
4
|
+
|
5
|
+
alias_method :org_run_command, :run_command
|
6
|
+
|
7
|
+
def run_command(cmd,option={})
|
8
|
+
unless current.rvm_shell
|
9
|
+
org_run_command('/bin/bash --login -c "which rvm-shell"', error: false)
|
10
|
+
.stdout.strip.each_line do |line|
|
11
|
+
current.rvm_shell = line
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
::Itamae.logger.debug "current.rvm_shell: #{current.rvm_shell}"
|
16
|
+
|
17
|
+
command = "#{current.rvm_shell} #{attributes.rvm_use} -c '#{cmd.is_a?(Array) ? cmd.join(' ') : cmd}'"
|
18
|
+
super(command, option)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Itamae::Plugin::Resource
|
2
|
+
class RvmGemsetCreate < ::Itamae::Resource::Base
|
3
|
+
define_attribute :action, default: :create
|
4
|
+
define_attribute :ruby_version, type: String, required: true
|
5
|
+
define_attribute :gemset_name, type: String, default_name: true
|
6
|
+
|
7
|
+
def pre_action
|
8
|
+
case @current_action
|
9
|
+
when :create
|
10
|
+
attributes.executed = true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def set_current_attributes
|
15
|
+
current.executed = false
|
16
|
+
run_command('/bin/bash --login -c "which rvm-shell"', error: false)
|
17
|
+
.stdout.strip.each_line do |line|
|
18
|
+
current.rvm_shell = line
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def action_create(options)
|
23
|
+
command = "#{current.rvm_shell} #{attributes.ruby_version} -c 'rvm gemset create #{attributes.gemset_name}'"
|
24
|
+
run_command(command)
|
25
|
+
updated!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Itamae::Plugin::Resource
|
2
|
+
class RvmGet < ::Itamae::Resource::Base
|
3
|
+
DEFAULT_GPG_KEY = '409B6B1796C275462A1703113804BB82D39DC0E3'
|
4
|
+
|
5
|
+
define_attribute :action, default: :install
|
6
|
+
define_attribute :version, type: String, default_name: true
|
7
|
+
define_attribute :gpg_key, type: String, default: DEFAULT_GPG_KEY
|
8
|
+
|
9
|
+
def pre_action
|
10
|
+
case @current_action
|
11
|
+
when :install
|
12
|
+
attributes.gpg_installed = true
|
13
|
+
attributes.version ||= 'latest'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_current_attributes
|
18
|
+
current.gpg_installed = gpgkey_installed?
|
19
|
+
::Itamae.logger.debug "GPG-Key was #{"not " unless current.gpg_installed}installed."
|
20
|
+
|
21
|
+
return true unless current.gpg_installed
|
22
|
+
|
23
|
+
version = installed_rvm
|
24
|
+
current.installed = !!version
|
25
|
+
if version == attributes.version
|
26
|
+
current.version = attributes.version.strip
|
27
|
+
else
|
28
|
+
current.version = version
|
29
|
+
end
|
30
|
+
|
31
|
+
if current.installed
|
32
|
+
::Itamae.logger.debug "Current RVM version: #{current.version}"
|
33
|
+
else
|
34
|
+
::Itamae.logger.debug 'RVM was not installed.'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def action_install(options)
|
39
|
+
install_gpgkey! unless current.gpg_installed
|
40
|
+
::Itamae.logger.debug "GPG-Key(#{attributes.gpg_key}) was installed."
|
41
|
+
|
42
|
+
if current.installed
|
43
|
+
if attributes.version && current.version != attributes.version.strip
|
44
|
+
install!
|
45
|
+
updated!
|
46
|
+
end
|
47
|
+
else
|
48
|
+
install!
|
49
|
+
updated!
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def gpgkey_installed?
|
56
|
+
(run_command('gpg --list-key').stdout =~ /\/#{attributes.gpg_key[-8,8]}\s+/)
|
57
|
+
end
|
58
|
+
|
59
|
+
def installed_rvm
|
60
|
+
match = run_command("/bin/bash --login -c 'rvm version'", error: false)
|
61
|
+
.stdout
|
62
|
+
.match(/\s*rvm\s+(\d+\.\d+\.\d+)\s+\(/)
|
63
|
+
return nil unless match
|
64
|
+
match[1].strip
|
65
|
+
end
|
66
|
+
|
67
|
+
def install_gpgkey!
|
68
|
+
cmd = "gpg --keyserver hkp://keys.gnupg.net --recv-keys #{attributes.gpg_key}"
|
69
|
+
run_command(cmd)
|
70
|
+
end
|
71
|
+
|
72
|
+
def install!
|
73
|
+
::Itamae.logger.debug "attributes.version: #{attributes.version}"
|
74
|
+
run_command("\\curl -sSL https://get.rvm.io | bash -s -- --version #{attributes.version}")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Itamae::Plugin::Resource
|
2
|
+
class RvmInstall < ::Itamae::Resource::Base
|
3
|
+
define_attribute :action, default: :install
|
4
|
+
define_attribute :ruby_version, type: String, default_name: true
|
5
|
+
|
6
|
+
def pre_action
|
7
|
+
case @current_action
|
8
|
+
when :install
|
9
|
+
attributes.executed = true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_current_attributes
|
14
|
+
current.executed = false
|
15
|
+
end
|
16
|
+
|
17
|
+
def action_install(options)
|
18
|
+
command = "/bin/bash --login -c 'rvm install #{attributes.ruby_version}'"
|
19
|
+
run_command(command)
|
20
|
+
updated!
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: itamae-plugin-recipe-rvm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Takahiro HAMAGUCHI
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: itamae
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.6.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.6'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.6.1
|
33
|
+
description: RVM installer with itemae.
|
34
|
+
email:
|
35
|
+
- tk.hamaguchi@gmail.com
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- ".gitignore"
|
41
|
+
- ".rspec"
|
42
|
+
- ".ruby-gemset"
|
43
|
+
- ".ruby-version"
|
44
|
+
- ".travis.yml"
|
45
|
+
- Gemfile
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- bin/console
|
49
|
+
- bin/setup
|
50
|
+
- examples/rvm_system_sample/Vagrantfile
|
51
|
+
- examples/rvm_system_sample/cookbooks/rvm_sample/default.rb
|
52
|
+
- examples/rvm_system_sample/node.yml
|
53
|
+
- examples/rvm_user_sample/Vagrantfile
|
54
|
+
- examples/rvm_user_sample/cookbooks/rvm_sample/default.rb
|
55
|
+
- examples/rvm_user_sample/node.yml
|
56
|
+
- itamae-plugin-recipe-rvm.gemspec
|
57
|
+
- lib/itamae/plugin/recipe/rvm.rb
|
58
|
+
- lib/itamae/plugin/recipe/rvm/common.rb
|
59
|
+
- lib/itamae/plugin/recipe/rvm/system.rb
|
60
|
+
- lib/itamae/plugin/recipe/rvm/user.rb
|
61
|
+
- lib/itamae/plugin/recipe/rvm/version.rb
|
62
|
+
- lib/itamae/plugin/resource/rvm_config.rb
|
63
|
+
- lib/itamae/plugin/resource/rvm_execute.rb
|
64
|
+
- lib/itamae/plugin/resource/rvm_gem_package.rb
|
65
|
+
- lib/itamae/plugin/resource/rvm_gemset_create.rb
|
66
|
+
- lib/itamae/plugin/resource/rvm_get.rb
|
67
|
+
- lib/itamae/plugin/resource/rvm_install.rb
|
68
|
+
homepage: https://github.com/tk-hamaguchi/itamae-plugin-recipe-rvm
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.4.8
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: RVM installer with itemae
|
92
|
+
test_files: []
|
93
|
+
has_rdoc:
|