• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: コミット

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


コミットメタ情報

リビジョン2ca69cf58d7a157ed03eac8991ea17dd639a36de (tree)
日時2017-09-07 21:36:41
作者whitestar <whitestar@user...>
コミッターwhitestar

ログメッセージ

Initial release of spinnaker.

変更サマリ

差分

--- /dev/null
+++ b/cookbooks/spinnaker/.foodcritic
@@ -0,0 +1 @@
1+~FC001
--- /dev/null
+++ b/cookbooks/spinnaker/.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/spinnaker/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/spinnaker/CHANGELOG.md
@@ -0,0 +1,5 @@
1+# spinnaker CHANGELOG
2+
3+0.1.0
4+-----
5+- Initial release of spinnaker.
--- /dev/null
+++ b/cookbooks/spinnaker/Gemfile
@@ -0,0 +1,4 @@
1+source 'https://rubygems.org'
2+
3+# with Chef DK
4+gem 'stove'
--- /dev/null
+++ b/cookbooks/spinnaker/README.md
@@ -0,0 +1,118 @@
1+spinnaker Cookbook
2+==================
3+
4+This cookbook sets up a Spinnaker Halyard service.
5+
6+## Contents
7+
8+- [Requirements](#requirements)
9+ - [platforms](#platforms)
10+ - [packages](#packages)
11+- [Attributes](#attributes)
12+- [Usage](#usage)
13+ - [Recipes](#recipes)
14+ - [spinnaker::default](#spinnakerdefault)
15+ - [spinnaker::halyard-ddocker-compose](#spinnakerhalyard-ddocker-compose)
16+ - [Role Examples](#role-examples)
17+- [License and Authors](#license-and-authors)
18+
19+## Requirements
20+
21+### platforms
22+
23+- Debian >= 9.0
24+- Ubuntu >= 14.04
25+- CentOS, RHEL >= 7.3
26+
27+### packages
28+- none.
29+
30+## Attributes
31+
32+|Key|Type|Description, example|Default|
33+|:--|:--|:--|:--|
34+|`['spinnaker']['halyard-docker-compose']['app_dir']`|String||`"#{node['docker-grid']['compose']['app_dir']}/halyard"`|
35+|`['spinnaker']['halyard-docker-compose']['config_dir']`|String||`"#{node['spinnaker']['halyard-docker-compose']['app_dir']}/.hal"`|
36+|`['spinnaker']['halyard-docker-compose']['config']`|Hash|`docker-compose.yml` configurations.|See `attributes/default.rb`|
37+
38+## Usage
39+
40+### Recipes
41+
42+#### spinnaker::default
43+
44+This recipe does nothing.
45+
46+#### spinnaker::halyard-ddocker-compose
47+
48+This recipe generates a `docker-compose.yml` for the Spinnaker Halyard service.
49+
50+### Role Examples
51+
52+- `roles/halyard-on-docker.rb`
53+
54+```ruby
55+name 'halyard-on-docker'
56+description 'Halyard on Docker'
57+
58+run_list(
59+ 'role[docker]',
60+ 'recipe[spinnaker::halyard-docker-compose]',
61+)
62+
63+#env_run_lists()
64+
65+#default_attributes()
66+
67+override_attributes(
68+ 'docker-grid' => {
69+ 'engine' => {
70+ 'skip_setup' => false,
71+ },
72+ 'compose' => {
73+ 'skip_setup' => false,
74+ },
75+ },
76+ 'spinnaker' => {
77+ 'halyard-docker-compose' => {
78+ 'config' => {
79+ 'services' => {
80+ 'halyard' => {
81+ 'restart' => 'always',
82+ 'image' => 'gcr.io/spinnaker-marketplace/halyard:stable',
83+ 'ports' => [
84+ # default
85+ #'127.0.0.1:8064:8064',
86+ ],
87+ 'volumes' => [
88+ # This volume will be set by the spinnaker::halyard-ddocker-compose recipe automatically.
89+ #"#{node['spinnaker']['halyard-docker-compose']['config_dir']}:/root/.hal:rw",
90+ ],
91+ 'environment' => {
92+ },
93+ },
94+ },
95+ },
96+ },
97+)
98+```
99+
100+## License and Authors
101+
102+- Author:: whitestar at osdn.jp
103+
104+```text
105+Copyright 2017, whitestar
106+
107+Licensed under the Apache License, Version 2.0 (the "License");
108+you may not use this file except in compliance with the License.
109+You may obtain a copy of the License at
110+
111+ http://www.apache.org/licenses/LICENSE-2.0
112+
113+Unless required by applicable law or agreed to in writing, software
114+distributed under the License is distributed on an "AS IS" BASIS,
115+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
116+See the License for the specific language governing permissions and
117+limitations under the License.
118+```
--- /dev/null
+++ b/cookbooks/spinnaker/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/spinnaker/attributes/default.rb
@@ -0,0 +1,45 @@
1+#
2+# Cookbook Name:: spinnaker
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['spinnaker']['halyard-docker-compose']['app_dir'] = "#{node['docker-grid']['compose']['app_dir']}/halyard"
21+default['spinnaker']['halyard-docker-compose']['config_dir'] = "#{node['spinnaker']['halyard-docker-compose']['app_dir']}/.hal"
22+
23+force_override['spinnaker']['halyard-docker-compose']['config_format_version'] = '2'
24+version_2_config = {
25+ # Version 2 docker-compose format
26+ 'version' => '2',
27+ 'services' => {
28+ 'halyard' => {
29+ 'restart' => 'always',
30+ 'image' => 'gcr.io/spinnaker-marketplace/halyard:stable',
31+ 'ports' => [
32+ # default
33+ #'127.0.0.1:8064:8064',
34+ ],
35+ 'volumes' => [
36+ # This volume will be set by the spinnaker::halyard-ddocker-compose recipe automatically.
37+ #"#{node['spinnaker']['halyard-docker-compose']['config_dir']}:/root/.hal:rw",
38+ ],
39+ 'environment' => {
40+ },
41+ },
42+ },
43+}
44+
45+default['spinnaker']['halyard-docker-compose']['config'] = version_2_config
--- /dev/null
+++ b/cookbooks/spinnaker/concourse.yml
@@ -0,0 +1,100 @@
1+---
2+# $ fly -t target sp -p spinnaker-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/spinnaker/fly-vars.yml
@@ -0,0 +1,3 @@
1+---
2+cookbook-name: spinnaker
3+chefdk-version: 1.4.3
--- /dev/null
+++ b/cookbooks/spinnaker/metadata.rb
@@ -0,0 +1,20 @@
1+name 'spinnaker'
2+maintainer 'whitestar'
3+maintainer_email ''
4+license 'Apache 2.0'
5+description 'Installs/Configures spinnaker'
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+supports 'debian', '>= 9.0'
16+supports 'ubuntu', '>= 14.04'
17+
18+depends 'docker-grid', '>= 0.5.3'
19+depends 'platform_utils', '>= 0.4.3'
20+depends 'ssl_cert', '>= 0.4.1'
--- /dev/null
+++ b/cookbooks/spinnaker/recipes/default.rb
@@ -0,0 +1,18 @@
1+#
2+# Cookbook Name:: spinnaker
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/spinnaker/recipes/halyard-docker-compose.rb
@@ -0,0 +1,81 @@
1+#
2+# Cookbook Name:: spinnaker
3+# Recipe:: halyard-docker-compose
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://www.spinnaker.io/setup/install/halyard/'
21+
22+include_recipe 'platform_utils::kernel_user_namespace'
23+include_recipe 'docker-grid::compose'
24+
25+app_dir = node['spinnaker']['halyard-docker-compose']['app_dir']
26+config_dir = node['spinnaker']['halyard-docker-compose']['config_dir']
27+
28+[
29+ app_dir,
30+ config_dir,
31+].each {|dir|
32+ resources(directory: dir) rescue directory dir do
33+ owner 'root'
34+ group 'root'
35+ mode '0755'
36+ recursive true
37+ end
38+}
39+
40+config_srvs = node['spinnaker']['halyard-docker-compose']['config']['services']
41+override_config_srvs = node.override['spinnaker']['halyard-docker-compose']['config']['services']
42+#force_override_config_srvs = node.force_override['spinnaker']['halyard-docker-compose']['config']['services']
43+#halyard_envs_org = config_srvs['halyard']['environment']
44+#halyard_envs = {}
45+halyard_vols = config_srvs['halyard']['volumes'].to_a
46+
47+ports = config_srvs['halyard']['ports']
48+if ports.empty?
49+ override_config_srvs['halyard']['ports'] = [
50+ '127.0.0.1:8064:8064',
51+ ]
52+end
53+
54+halyard_vols.push("#{config_dir}:/root/.hal:rw")
55+
56+# merge environment hash
57+#force_override_config_srvs['halyard']['environment'] = halyard_envs unless halyard_envs.empty?
58+# reset vlumes array.
59+override_config_srvs['halyard']['volumes'] = halyard_vols unless halyard_vols.empty?
60+
61+config_file = "#{app_dir}/docker-compose.yml"
62+template config_file do
63+ source 'opt/docker-compose/app/halyard/docker-compose.yml'
64+ owner 'root'
65+ group 'root'
66+ mode '0644'
67+end
68+
69+log <<-"EOM"
70+Note: You must execute the following command manually.
71+ See #{doc_url}
72+ * Start:
73+ $ cd #{app_dir}
74+ $ docker-compose up -d
75+ * Confirm:
76+ $ docker exec -it halyard_halyard_1 bash
77+ # hal -v
78+ 0.32.1-20170816204345
79+ * Stop
80+ $ docker-compose down
81+EOM
--- /dev/null
+++ b/cookbooks/spinnaker/spec/recipes/default_spec.rb
@@ -0,0 +1,9 @@
1+require_relative '../spec_helper'
2+
3+describe 'spinnaker::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/spinnaker/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/spinnaker/templates/default/opt/docker-compose/app/halyard/docker-compose.yml
@@ -0,0 +1,5 @@
1+<%
2+require 'yaml'
3+yaml_str = node['spinnaker']['halyard-docker-compose']['config'].to_hash.to_yaml
4+-%>
5+<%= yaml_str %>
--- /dev/null
+++ b/cookbooks/spinnaker/version
@@ -0,0 +1 @@
1+0.1.0
旧リポジトリブラウザで表示