• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: コミット

Grid環境構築用のChefリポジトリです。


コミットメタ情報

リビジョン20e66a1b2ac0add589ceaad090d6be012e74adf2 (tree)
日時2019-03-03 18:25:49
作者whitestar <whitestar@user...>
コミッターwhitestar

ログメッセージ

add yarn-installer recipe to the nodejs_utils cookbook.

変更サマリ

差分

--- a/cookbooks/nodejs_utils/CHANGELOG.md
+++ b/cookbooks/nodejs_utils/CHANGELOG.md
@@ -1,5 +1,9 @@
11 # nodejs_utils CHANGELOG
22
3+0.2.0
4+-----
5+- add yarn-installer recipe.
6+
37 0.1.0
48 -----
59 - Initial release.
--- /dev/null
+++ b/cookbooks/nodejs_utils/Gemfile.lock
@@ -0,0 +1,22 @@
1+GEM
2+ remote: https://rubygems.org/
3+ specs:
4+ chef-api (0.8.0)
5+ logify (~> 0.1)
6+ mime-types
7+ logify (0.2.0)
8+ mime-types (3.2.2)
9+ mime-types-data (~> 3.2015)
10+ mime-types-data (3.2018.0812)
11+ stove (6.0.0)
12+ chef-api (~> 0.5)
13+ logify (~> 0.2)
14+
15+PLATFORMS
16+ ruby
17+
18+DEPENDENCIES
19+ stove
20+
21+BUNDLED WITH
22+ 1.16.0
--- a/cookbooks/nodejs_utils/README.md
+++ b/cookbooks/nodejs_utils/README.md
@@ -1,7 +1,7 @@
11 nodejs_utils Cookbook
22 =====================
33
4-This cookbook installs `n`, `nvm` (Node.js Version Managers) setup scripts.
4+This cookbook installs `n`, `nvm` (Node.js Version Managers) and `yarn` setup scripts.
55
66 ## Contents
77
@@ -15,6 +15,7 @@ This cookbook installs `n`, `nvm` (Node.js Version Managers) setup scripts.
1515 - [nodejs_utils::default](#nodejs_utilsdefault)
1616 - [nodejs_utils::n-installer](#nodejs_utilsn-installer)
1717 - [nodejs_utils::nvm-installer](#nodejs_utilsnvm-installer)
18+ - [nodejs_utils::yarn-installer](#nodejs_utilsyarn-installer)
1819 - [License and Authors](#license-and-authors)
1920
2021 ## Requirements
@@ -34,7 +35,8 @@ This cookbook installs `n`, `nvm` (Node.js Version Managers) setup scripts.
3435
3536 |Key|Type|Description, example|Default|
3637 |:--|:--|:--|:--|
37-|`['nodejs_utils']['nvm']['version']`|String|latest: 'master'|`'v0.33.6'`|
38+|`['nodejs_utils']['nvm']['version']`|String|latest: 'master'|`'v0.33.11'`|
39+|`['nodejs_utils']['yarn']['version']`|String||`'latest'`|
3840
3941 ## Usage
4042
@@ -52,12 +54,16 @@ This recipe installs the `n` setup script.
5254
5355 This recipe installs the `nvm` setup script.
5456
57+#### nodejs_utils::nvm-installer
58+
59+This recipe installs the `yarn` setup script.
60+
5561 ## License and Authors
5662
5763 - Author:: whitestar at osdn.jp
5864
5965 ```text
60-Copyright 2017, whitestar
66+Copyright 2017-2019, whitestar
6167
6268 Licensed under the Apache License, Version 2.0 (the "License");
6369 you may not use this file except in compliance with the License.
--- a/cookbooks/nodejs_utils/Rakefile
+++ b/cookbooks/nodejs_utils/Rakefile
@@ -3,12 +3,58 @@ require 'rubocop/rake_task'
33 require 'foodcritic'
44 require 'stove/rake_task'
55
6+tpl_cookbook = '00cookbook'
7+cookbook_name = File.basename(Dir.pwd)
8+
9+desc 'Initialize project'
10+task :init do
11+ next if cookbook_name == tpl_cookbook
12+
13+ [
14+ '.foodcritic',
15+ '.rubocop.yml',
16+ 'Berksfile',
17+ 'chefignore',
18+ 'concourse.yml',
19+ 'fly-vars.yml',
20+ 'fly-vars.local.yml',
21+ 'Gemfile',
22+ 'Gemfile.lock',
23+ 'version',
24+ ].each {|conf|
25+ sh "cp ../#{tpl_cookbook}/#{conf} ./" unless File.exist?(conf)
26+ }
27+
28+ ruby [
29+ %(-pne '$_.gsub!(/^cookbook-name: .*$/, "cookbook-name: #{cookbook_name}")'),
30+ '-i fly-vars.local.yml',
31+ ].join(' ')
32+end
33+
34+desc 'Update project'
35+task :update do
36+ next if cookbook_name == tpl_cookbook
37+
38+ [
39+ 'Rakefile',
40+ 'chefignore',
41+ 'concourse.yml',
42+ 'fly-vars.yml',
43+ 'Gemfile',
44+ 'Gemfile.lock',
45+ ].each {|conf|
46+ sh "cp ../#{tpl_cookbook}/#{conf} ./"
47+ }
48+end
49+
50+desc 'fly set-pipeline'
651 task :'set-pipeline' do
752 sh [
8- "fly -t $CC_TARGET sp -p #{File.basename(Dir.pwd)}-cookbook -c concourse.yml",
9- '-l fly-vars.yml -l ~/sec/credentials-prod.yml',
53+ "fly -t $CC_TARGET sp -p #{cookbook_name}-cookbook -c concourse.yml",
54+ '-l fly-vars.yml -l fly-vars.local.yml -l ~/sec/credentials-prod.yml',
1055 ].join(' ')
1156 end
57+desc 'rake set-pipeline alias'
1258 task sp: 'set-pipeline'
1359
1460 namespace :style do
--- a/cookbooks/nodejs_utils/attributes/default.rb
+++ b/cookbooks/nodejs_utils/attributes/default.rb
@@ -2,7 +2,7 @@
22 # Cookbook Name:: nodejs_utils
33 # Attributes:: default
44 #
5-# Copyright 2017, whitestar
5+# Copyright 2017-2019, whitestar
66 #
77 # Licensed under the Apache License, Version 2.0 (the "License");
88 # you may not use this file except in compliance with the License.
@@ -17,4 +17,5 @@
1717 # limitations under the License.
1818 #
1919
20-default['nodejs_utils']['nvm']['version'] = 'v0.33.6' # latest: 'master'
20+default['nodejs_utils']['nvm']['version'] = 'v0.33.11' # latest: 'master'
21+default['nodejs_utils']['yarn']['version'] = 'latest'
--- /dev/null
+++ b/cookbooks/nodejs_utils/chefignore
@@ -0,0 +1,20 @@
1+# Put files/directories that should be ignored in this file.
2+# Lines that start with '# ' are comments.
3+
4+Berksfile.lock
5+
6+# concourse
7+concourse.yml
8+fly-vars.yml
9+fly-vars.local.yml
10+
11+# emacs
12+*~
13+
14+.rubocop_todo.yml
15+
16+# vim
17+*.sw[a-z]
18+
19+# subversion
20+*/.svn/*
--- a/cookbooks/nodejs_utils/concourse.yml
+++ b/cookbooks/nodejs_utils/concourse.yml
@@ -1,5 +1,4 @@
11 ---
2-# $ fly -t $CC_TARGET sp -p nodejs_utils-cookbook -c concourse.yml -l fly-vars.yml -l ~/sec/credentials-prod.yml
32 resources:
43 - name: src-git
54 type: git
--- a/cookbooks/nodejs_utils/fly-vars.yml
+++ b/cookbooks/nodejs_utils/fly-vars.yml
@@ -1,3 +1,2 @@
11 ---
2-cookbook-name: nodejs_utils
32 chefdk-version: 1.6.11
--- /dev/null
+++ b/cookbooks/nodejs_utils/recipes/yarn-installer.rb
@@ -0,0 +1,53 @@
1+#
2+# Cookbook Name:: nodejs_utils
3+# Recipe:: yarn-installer
4+#
5+# Copyright 2019, whitestar
6+#
7+# Licensed under the Apache License, Version 2.0 (the "License");
8+# you may not use this file except in compliance with the License.
9+# You may obtain a copy of the License at
10+#
11+# http://www.apache.org/licenses/LICENSE-2.0
12+#
13+# Unless required by applicable law or agreed to in writing, software
14+# distributed under the License is distributed on an "AS IS" BASIS,
15+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+# See the License for the specific language governing permissions and
17+# limitations under the License.
18+#
19+
20+doc_url = 'https://yarnpkg.com/en/docs/'
21+
22+[
23+ 'curl',
24+].each {|pkg|
25+ resources(package: pkg) rescue package pkg do
26+ action :install
27+ end
28+}
29+
30+[
31+ 'yarn_install',
32+].each {|script|
33+ template "/usr/local/bin/#{script}" do
34+ source "usr/local/bin/#{script}"
35+ owner 'root'
36+ group 'root'
37+ mode '0755'
38+ action :create
39+ end
40+}
41+
42+log 'yarn-installer post install message' do
43+ message <<-"EOM"
44+Note: You must execute the following command manually.
45+ See #{doc_url}
46+ * install yarn:
47+ $ yarn_install
48+ ...
49+ $ source ~/.bashrc
50+ $ yarn -v
51+ 1.13.0
52+EOM
53+end
--- /dev/null
+++ b/cookbooks/nodejs_utils/templates/default/usr/local/bin/yarn_install
@@ -0,0 +1,13 @@
1+#!/bin/sh
2+
3+PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
4+
5+<%
6+yarn_ver = node['nodejs_utils']['yarn']['version']
7+
8+if yarn_ver == 'latest'
9+-%>
10+curl -o- -L https://yarnpkg.com/install.sh | bash
11+<% else -%>
12+curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version <%= yarn_ver %>
13+<% end -%>
--- a/cookbooks/nodejs_utils/version
+++ b/cookbooks/nodejs_utils/version
@@ -1 +1 @@
1-0.1.0
1+0.2.0
--- /dev/null
+++ b/roles/nodejs-utils.rb
@@ -0,0 +1,16 @@
1+name 'nodejs-utils'
2+description 'Node.js Setup Utilities'
3+
4+run_list(
5+ 'recipe[nodejs_utils::n-installer]',
6+ 'recipe[nodejs_utils::nvm-installer]',
7+ 'recipe[nodejs_utils::yarn-installer]',
8+)
9+
10+#env_run_lists
11+
12+default_attributes(
13+)
14+
15+override_attributes(
16+)
旧リポジトリブラウザで表示