質問編集履歴

2

同様の悩みでここに来た人の為、最終的に採用したのをメモしておきます。

2016/07/26 04:00

投稿

chrokurojp
chrokurojp

スコア26

test CHANGED
File without changes
test CHANGED
@@ -189,3 +189,113 @@
189
189
  ruby -v
190
190
 
191
191
  ```
192
+
193
+
194
+
195
+ 最終的にコレに落ち着きました。
196
+
197
+ ```
198
+
199
+ ---
200
+
201
+ - hosts: 127.0.0.1
202
+
203
+ become: yes
204
+
205
+ vars:
206
+
207
+ - ver_ruby: 2.2.3
208
+
209
+ tasks:
210
+
211
+ # 【Roles : rbenv】
212
+
213
+ - name: Remove old directory rbenv
214
+
215
+ file: path=/usr/local/opt/rbenv state=absent
216
+
217
+
218
+
219
+ - name: Remove old directory ruby-build
220
+
221
+ file: path=/usr/local/opt/rbenv/plugins/ruby-build state=absent
222
+
223
+
224
+
225
+ - name: Remove old directory rbenv-gemset
226
+
227
+ file: path=/usr/local/opt/rbenv/plugins/rbenv-gemset state=absent
228
+
229
+
230
+
231
+ - name: Git clone rbenv
232
+
233
+ git:
234
+
235
+ repo=https://github.com/sstephenson/rbenv.git
236
+
237
+ dest=/usr/local/opt/rbenv
238
+
239
+ accept_hostkey=yes
240
+
241
+
242
+
243
+ - name: /usr/local/opt/rbenv rbenv.sh
244
+
245
+ shell: echo 'export RBENV_ROOT="/usr/local/opt/rbenv"' > /etc/profile.d/rbenv.sh
246
+
247
+
248
+
249
+ - name: $RBENV_ROOT/bin:$PATH rbenv.sh
250
+
251
+ shell: echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
252
+
253
+
254
+
255
+ - name: eval "$(rbenv init -)" rbenv.sh
256
+
257
+ shell: echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
258
+
259
+
260
+
261
+ - name: Git clone ruby-build
262
+
263
+ git:
264
+
265
+ repo=https://github.com/sstephenson/ruby-build.git
266
+
267
+ dest=/usr/local/opt/rbenv/plugins/ruby-build
268
+
269
+ accept_hostkey=yes
270
+
271
+
272
+
273
+ - name: Git clone rbenv-gemset
274
+
275
+ git:
276
+
277
+ repo=https://github.com/jamis/rbenv-gemset.git
278
+
279
+ dest=/usr/local/opt/rbenv/plugins/rbenv-gemset
280
+
281
+ accept_hostkey=yes
282
+
283
+
284
+
285
+ - name: rbenv install
286
+
287
+ shell: /bin/bash -lc "rbenv install {{ ver_ruby }} && rbenv rehash && rbenv global {{ ver_ruby }}"
288
+
289
+
290
+
291
+ - name: Gem install
292
+
293
+ yum: name=gem state=present
294
+
295
+
296
+
297
+ - name: exec $SHELL -l
298
+
299
+ shell: exec $SHELL -l
300
+
301
+ ```

1

yml更新

2016/07/26 03:59

投稿

chrokurojp
chrokurojp

スコア26

test CHANGED
File without changes
test CHANGED
@@ -32,13 +32,13 @@
32
32
 
33
33
  ---
34
34
 
35
+ ---
36
+
35
37
  - hosts: 127.0.0.1
36
38
 
37
39
  become: yes
38
40
 
39
41
 
40
-
41
- # 【Roles : init】
42
42
 
43
43
  tasks:
44
44
 
@@ -56,6 +56,24 @@
56
56
 
57
57
 
58
58
 
59
+ - name: echo 'export RBENV_ROOT="/usr/local/opt/rbenv"' > /etc/profile.d/rbenv.sh
60
+
61
+ shell: echo 'export RBENV_ROOT="/usr/local/opt/rbenv"' > /etc/profile.d/rbenv.sh
62
+
63
+
64
+
65
+ - name: echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
66
+
67
+ shell: echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
68
+
69
+
70
+
71
+ - name: echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
72
+
73
+ shell: echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
74
+
75
+
76
+
59
77
  - name: Git clone ruby-build
60
78
 
61
79
  shell: git clone https://github.com/sstephenson/ruby-build.git /usr/local/opt/rbenv/plugins/ruby-build
@@ -70,13 +88,19 @@
70
88
 
71
89
  - name: Reflection rbenv.sh
72
90
 
73
- shell: source /etc/profile.d/rbenv.sh
91
+ shell: /bin/bash -l /etc/profile.d/rbenv.sh
74
92
 
75
93
 
76
94
 
77
95
  - name: Rbenv local install
78
96
 
79
97
  shell: rbenv install $(rbenv install -l | grep -v - | tail -1)
98
+
99
+
100
+
101
+ - name: Gem install
102
+
103
+ shell: yum install -y gem
80
104
 
81
105
 
82
106