• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: コミット

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


コミットメタ情報

リビジョン1280b4bf97206b032540c940fb3555d962ee4f65 (tree)
日時2017-12-03 16:10:08
作者whitestar <whitestar@user...>
コミッターwhitestar

ログメッセージ

initial revision of the nodejs_utils cookbook.

変更サマリ

差分

--- /dev/null
+++ b/cookbooks/nodejs_utils/.foodcritic
@@ -0,0 +1 @@
1+~FC001
--- /dev/null
+++ b/cookbooks/nodejs_utils/.rubocop.yml
@@ -0,0 +1,53 @@
1+AllCops:
2+ Exclude:
3+ - vendor/**/*
4+
5+AlignParameters:
6+ Enabled: false
7+LineLength:
8+ Enabled: false
9+Lint/UnusedBlockArgument:
10+ Enabled: false
11+Metrics/AbcSize:
12+ Enabled: false
13+Style/BlockComments:
14+ Enabled: false
15+Style/BlockDelimiters:
16+ Enabled: false
17+Style/ExtraSpacing:
18+ Enabled: false
19+Style/FileName:
20+ Enabled: false
21+Style/LeadingCommentSpace:
22+ Enabled: false
23+Style/RescueModifier:
24+ Enabled: false
25+Style/SpaceAroundOperators:
26+ Enabled: false
27+Style/SpaceBeforeFirstArg:
28+ Enabled: false
29+Style/SpaceInsideBlockBraces:
30+ Enabled: false
31+Style/SpaceInsidePercentLiteralDelimiters:
32+ Enabled: false
33+Style/TrailingCommaInLiteral:
34+ EnforcedStyleForMultiline: consistent_comma
35+Style/WordArray:
36+ Enabled: false
37+
38+#Lint/ShadowingOuterLocalVariable:
39+# Enabled: false
40+#Metrics/MethodLength:
41+# Max: 10
42+#Metrics/ModuleLength:
43+# Max: 100
44+#Metrics/CyclomaticComplexity:
45+# Max: 6
46+#Metrics/PerceivedComplexity:
47+# Max: 7
48+#Style/AccessorMethodName:
49+# Enabled: false
50+#Style/MultilineOperationIndentation:
51+# Enabled: false
52+#Style/PerlBackrefs:
53+# Enabled: false
--- /dev/null
+++ b/cookbooks/nodejs_utils/Berksfile
@@ -0,0 +1,19 @@
1+#
2+# Copyright 2017 whitestar
3+#
4+# Licensed under the Apache License, Version 2.0 (the "License");
5+# you may not use this file except in compliance with the License.
6+# You may obtain a copy of the License at
7+#
8+# http://www.apache.org/licenses/LICENSE-2.0
9+#
10+# Unless required by applicable law or agreed to in writing, software
11+# distributed under the License is distributed on an "AS IS" BASIS,
12+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+# See the License for the specific language governing permissions and
14+# limitations under the License.
15+#
16+
17+source 'https://supermarket.chef.io'
18+
19+metadata
--- /dev/null
+++ b/cookbooks/nodejs_utils/CHANGELOG.md
@@ -0,0 +1,5 @@
1+# nodejs_utils CHANGELOG
2+
3+0.1.0
4+-----
5+- Initial release.
--- /dev/null
+++ b/cookbooks/nodejs_utils/Gemfile
@@ -0,0 +1,4 @@
1+source 'https://rubygems.org'
2+
3+# with Chef DK
4+gem 'stove'
--- /dev/null
+++ b/cookbooks/nodejs_utils/README.md
@@ -0,0 +1,73 @@
1+nodejs_utils Cookbook
2+=====================
3+
4+This cookbook installs `n`, `nvm` (Node.js Version Managers) setup scripts.
5+
6+## Contents
7+
8+- [Requirements](#requirements)
9+ - [platforms](#platforms)
10+ - [packages](#packages)
11+ - [cookbooks](#cookbooks)
12+- [Attributes](#attributes)
13+- [Usage](#usage)
14+ - [Recipes](#recipes)
15+ - [nodejs_utils::default](#nodejs_utilsdefault)
16+ - [nodejs_utils::n-installer](#nodejs_utilsn-installer)
17+ - [nodejs_utils::nvm-installer](#nodejs_utilsnvm-installer)
18+- [License and Authors](#license-and-authors)
19+
20+## Requirements
21+
22+### platforms
23+- Debian >= 8.0
24+- Ubuntu >= 14.04
25+- CentOS, RHEL >= 7.3
26+
27+### packages
28+- none.
29+
30+### cookbooks
31+- none.
32+
33+## Attributes
34+
35+|Key|Type|Description, example|Default|
36+|:--|:--|:--|:--|
37+|`['nodejs_utils']['nvm']['version']`|String|latest: 'master'|`'v0.33.6'`|
38+
39+## Usage
40+
41+### Recipes
42+
43+#### nodejs_utils::default
44+
45+This recipe does nothing.
46+
47+#### nodejs_utils::n-installer
48+
49+This recipe installs the `n` setup script.
50+
51+#### nodejs_utils::nvm-installer
52+
53+This recipe installs the `nvm` setup script.
54+
55+## License and Authors
56+
57+- Author:: whitestar at osdn.jp
58+
59+```text
60+Copyright 2017, whitestar
61+
62+Licensed under the Apache License, Version 2.0 (the "License");
63+you may not use this file except in compliance with the License.
64+You may obtain a copy of the License at
65+
66+ http://www.apache.org/licenses/LICENSE-2.0
67+
68+Unless required by applicable law or agreed to in writing, software
69+distributed under the License is distributed on an "AS IS" BASIS,
70+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
71+See the License for the specific language governing permissions and
72+limitations under the License.
73+```
--- /dev/null
+++ b/cookbooks/nodejs_utils/Rakefile
@@ -0,0 +1,41 @@
1+require 'rspec/core/rake_task'
2+require 'rubocop/rake_task'
3+require 'foodcritic'
4+require 'stove/rake_task'
5+
6+namespace :style do
7+ desc 'Run Ruby style checks'
8+ RuboCop::RakeTask.new(:ruby) do |t|
9+ t.options = [
10+ '--auto-gen-config', # creates .rubocop_todo.yml
11+ ]
12+ end
13+
14+ desc 'Run Chef style checks'
15+ FoodCritic::Rake::LintTask.new(:chef) do |t|
16+ t.options = {
17+ fail_tags: ['any'],
18+ }
19+ end
20+end
21+
22+desc 'Run all style checks'
23+task style: ['style:chef', 'style:ruby']
24+
25+desc 'Run ChefSpec examples'
26+RSpec::Core::RakeTask.new(:spec)
27+
28+desc 'Publish cookbook'
29+Stove::RakeTask.new(:publish) do |t|
30+ t.stove_opts = [
31+ # `--username` and `--key` are set in ~/.stove typically.
32+ #'--username', 'somebody',
33+ #'--key', '~/chef/chef.io.example.com/somebody.pem',
34+ #'--endpoint', 'https://supermarket.io.example.com/api/v1', # default: supermarket.chef.io
35+ #'--no-ssl-verify',
36+ '--no-git',
37+ '--log-level', 'info',
38+ ]
39+end
40+
41+task default: ['style', 'spec']
--- /dev/null
+++ b/cookbooks/nodejs_utils/attributes/default.rb
@@ -0,0 +1,20 @@
1+#
2+# Cookbook Name:: nodejs_utils
3+# Attributes:: default
4+#
5+# Copyright 2017, 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+default['nodejs_utils']['nvm']['version'] = 'v0.33.6' # latest: 'master'
--- /dev/null
+++ b/cookbooks/nodejs_utils/concourse.yml
@@ -0,0 +1,100 @@
1+---
2+# $ fly -t target sp -p nodejs_utils-cookbook -c concourse.yml -l fly-vars.yml -l ~/sec/credentials-prod.yml
3+resources:
4+- name: src-git
5+ type: git
6+ source:
7+ uri: ((git-id-osdn))@git.osdn.net:/gitroot/metasearch/grid-chef-repo.git
8+ branch: master
9+ paths:
10+ - cookbooks/((cookbook-name))
11+ private_key: ((git-private-key))
12+ git_user: ((git-user-osdn))
13+ #check_every: 1h # default: 1m
14+- name: chefdk-cache
15+ type: docker-image
16+ source:
17+ repository: chef/chefdk
18+ tag: ((chefdk-version))
19+ # ((param)) style: fly >= 3.2.0
20+ registry_mirror: https://((registry-mirror-domain)) # e.g. https://registry.docker.example.com:5000
21+ ca_certs:
22+ - domain: ((registry-mirror-domain)) # e.g. registry.docker.example.com:5000
23+ cert: ((docker-reg-ca-cert))
24+ check_every: 12h # default: 1m
25+
26+jobs:
27+- name: test-cookbook
28+ plan:
29+ - aggregate:
30+ - get: src-git
31+ params:
32+ depth: 5
33+ trigger: true
34+ - get: chefdk-cache
35+ - task: ci-build
36+ image: chefdk-cache
37+ params:
38+ http_proxy: ((http-proxy)) # e.g. http://proxy.example.com:3128
39+ #HTTP_PROXY: ((http-proxy))
40+ config:
41+ platform: linux
42+ #image_resource:
43+ # type: docker-image
44+ # source:
45+ # repository: chef/chefdk
46+ # tag: ((chefdk-version))
47+ # NG, setting disable
48+ #registry_mirror: https://((registry-mirror-domain))
49+ #ca_certs:
50+ #- domain: ((registry-mirror-domain))
51+ # cert: ((docker-reg-ca-cert))
52+ inputs:
53+ - name: src-git
54+ run:
55+ #dir: ./src-git/cookbooks/((cookbook-name))
56+ #path: rake
57+ path: /bin/bash
58+ args:
59+ - -c
60+ - |
61+ cd ./src-git/cookbooks/((cookbook-name))
62+ bundle install
63+ rake
64+- name: publish-cookbook
65+ plan:
66+ - aggregate:
67+ - get: src-git
68+ params:
69+ depth: 5
70+ trigger: false
71+ passed: [test-cookbook]
72+ - get: chefdk-cache
73+ passed: [test-cookbook]
74+ - task: publish
75+ image: chefdk-cache
76+ params:
77+ http_proxy: ((http-proxy))
78+ chef_username: ((chef-username))
79+ chef_client_key: ((chef-client-key))
80+ config:
81+ platform: linux
82+ inputs:
83+ - name: src-git
84+ run:
85+ path: /bin/bash
86+ args:
87+ - -c
88+ - |
89+ echo '{"username":"((chef-username))","key":"/root/chef-client-key.pem"}' > /root/.stove
90+ echo "$chef_client_key" > /root/chef-client-key.pem
91+ cd ./src-git/cookbooks/((cookbook-name))
92+ bundle install
93+ rake publish
94+ - put: src-git
95+ params:
96+ repository: src-git
97+ tag_prefix: ((cookbook-name))-
98+ tag: src-git/cookbooks/((cookbook-name))/version
99+ only_tag: true
100+ annotate: ../src-git/cookbooks/((cookbook-name))/version
--- /dev/null
+++ b/cookbooks/nodejs_utils/fly-vars.yml
@@ -0,0 +1,3 @@
1+---
2+cookbook-name: nodejs_utils
3+chefdk-version: 1.4.3
--- /dev/null
+++ b/cookbooks/nodejs_utils/metadata.rb
@@ -0,0 +1,17 @@
1+name 'nodejs_utils'
2+maintainer 'whitestar'
3+maintainer_email ''
4+license 'Apache 2.0'
5+description 'Installs/Configures nodejs_utils'
6+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7+version IO.read(File.join(File.dirname(__FILE__), 'version')).chomp
8+source_url 'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
9+issues_url 'https://osdn.jp/projects/metasearch/ticket'
10+
11+chef_version '>= 12'
12+%w(centos redhat).each do |os|
13+ supports os, '>= 7.3'
14+end
15+
16+supports 'debian', '>= 8.0'
17+supports 'ubuntu', '>= 14.04'
--- /dev/null
+++ b/cookbooks/nodejs_utils/recipes/default.rb
@@ -0,0 +1,18 @@
1+#
2+# Cookbook Name:: nodejs_utils
3+# Recipe:: default
4+#
5+# Copyright 2017, 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+#
--- /dev/null
+++ b/cookbooks/nodejs_utils/recipes/n-installer.rb
@@ -0,0 +1,64 @@
1+#
2+# Cookbook Name:: nodejs_utils
3+# Recipe:: n-installer
4+#
5+# Copyright 2017, 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://github.com/tj/n'
21+
22+[
23+ 'curl',
24+].each {|pkg|
25+ resources(package: pkg) rescue package pkg do
26+ action :install
27+ end
28+}
29+
30+[
31+ 'n_install',
32+ #'n_update',
33+ #'n_uninstall',
34+].each {|script|
35+ template "/usr/local/bin/#{script}" do
36+ source "usr/local/bin/#{script}"
37+ owner 'root'
38+ group 'root'
39+ mode '0755'
40+ action :create
41+ end
42+}
43+
44+log 'n-installer post install message' do
45+ message <<-"EOM"
46+Note: You must execute the following command manually.
47+ See #{doc_url}
48+ * install n:
49+ $ n_install
50+ ...
51+ $ source .bashrc
52+ $ n -V
53+ 2.1.8
54+ * install the latest LTS Node.js
55+ $ n lts
56+ ...
57+ $ node -v
58+ v6.11.4
59+ * update n:
60+ $ n-update
61+ * uninstall n:
62+ $ n-uninstall
63+EOM
64+end
--- /dev/null
+++ b/cookbooks/nodejs_utils/recipes/nvm-installer.rb
@@ -0,0 +1,58 @@
1+#
2+# Cookbook Name:: nodejs_utils
3+# Recipe:: nvm-installer
4+#
5+# Copyright 2017, 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://github.com/creationix/nvm'
21+
22+[
23+ 'curl',
24+].each {|pkg|
25+ resources(package: pkg) rescue package pkg do
26+ action :install
27+ end
28+}
29+
30+[
31+ 'nvm_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 'nvm-installer post install message' do
43+ message <<-"EOM"
44+Note: You must execute the following command manually.
45+ See #{doc_url}
46+ * install n:
47+ $ nvm_install
48+ ...
49+ $ source .bashrc
50+ $ nvm --version
51+ 0.33.6
52+ * install the latest LTS Node.js
53+ $ nvm install --lts
54+ ...
55+ $ node -v
56+ v6.11.4
57+EOM
58+end
--- /dev/null
+++ b/cookbooks/nodejs_utils/spec/recipes/default_spec.rb
@@ -0,0 +1,9 @@
1+require_relative '../spec_helper'
2+
3+describe 'nodejs_utils::default' do
4+ let(:chef_run) { ChefSpec::SoloRunner.new.converge(described_recipe) }
5+
6+ #it 'does something' do
7+ # expect(chef_run).to do_something('...')
8+ #end
9+end
--- /dev/null
+++ b/cookbooks/nodejs_utils/spec/spec_helper.rb
@@ -0,0 +1,25 @@
1+# Added by ChefSpec
2+require 'chefspec'
3+
4+# Uncomment to use ChefSpec's Berkshelf extension
5+# require 'chefspec/berkshelf'
6+
7+RSpec.configure do |config|
8+ # Specify the path for Chef Solo to find cookbooks
9+ # config.cookbook_path = '/var/cookbooks'
10+
11+ # Specify the path for Chef Solo to find roles
12+ # config.role_path = '/var/roles'
13+
14+ # Specify the Chef log_level (default: :warn)
15+ # config.log_level = :debug
16+
17+ # Specify the path to a local JSON file with Ohai data
18+ # config.path = 'ohai.json'
19+
20+ # Specify the operating platform to mock Ohai data from
21+ # config.platform = 'ubuntu'
22+
23+ # Specify the operating version to mock Ohai data from
24+ # config.version = '12.04'
25+end
--- /dev/null
+++ b/cookbooks/nodejs_utils/templates/default/usr/local/bin/n_install
@@ -0,0 +1,5 @@
1+#!/bin/sh
2+
3+PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
4+
5+curl -L https://git.io/n-install | bash
--- /dev/null
+++ b/cookbooks/nodejs_utils/templates/default/usr/local/bin/n_uninstall
@@ -0,0 +1,5 @@
1+#!/bin/sh
2+
3+PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
4+
5+curl -L https://raw.githubusercontent.com/mklement0/n-install/stable/bin/n-uninstall | bash
--- /dev/null
+++ b/cookbooks/nodejs_utils/templates/default/usr/local/bin/n_update
@@ -0,0 +1,5 @@
1+#!/bin/sh
2+
3+PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
4+
5+curl -L https://raw.githubusercontent.com/mklement0/n-install/stable/bin/n-update | bash
--- /dev/null
+++ b/cookbooks/nodejs_utils/templates/default/usr/local/bin/nvm_install
@@ -0,0 +1,5 @@
1+#!/bin/sh
2+
3+PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
4+
5+curl -o- https://raw.githubusercontent.com/creationix/nvm/<%= node['nodejs_utils']['nvm']['version'] %>/install.sh | bash
--- /dev/null
+++ b/cookbooks/nodejs_utils/version
@@ -0,0 +1 @@
1+0.1.0
旧リポジトリブラウザで表示