• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: Commit

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


Commit MetaInfo

Revision835f582f5ec0326769b288f290925f2f643f7b64 (tree)
Zeit2017-07-20 22:21:23
Autorwhitestar <whitestar@user...>
Commiterwhitestar

Log Message

Initial release of nexus-gird

Ändern Zusammenfassung

Diff

--- /dev/null
+++ b/cookbooks/nexus-grid/.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/MultilineIfModifier:
24+ Enabled: false
25+Style/RescueModifier:
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/nexus-grid/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/nexus-grid/CHANGELOG.md
@@ -0,0 +1,5 @@
1+# nexus-grid CHANGELOG
2+
3+0.1.0
4+-----
5+- Initial release of nexus-gird
--- /dev/null
+++ b/cookbooks/nexus-grid/Gemfile
@@ -0,0 +1,4 @@
1+source 'https://rubygems.org'
2+
3+# with Chef DK
4+gem 'stove'
--- /dev/null
+++ b/cookbooks/nexus-grid/README.md
@@ -0,0 +1,119 @@
1+nexus-grid Cookbook
2+===================
3+
4+This cookbook sets up a Sonatype Nexus Repository Manager by Docker Compose.
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+ - [nexus-grid::default](#nexus-griddefault)
16+ - [nexus-grid::docker-compose](#nexus-griddocker-compose)
17+ - [Role Examples](#role-examples)
18+- [License and Authors](#license-and-authors)
19+
20+## Requirements
21+
22+### platforms
23+- RHEL, CentOS >= 7.0
24+- Debian >= 8.0
25+- Ubuntu >= 14.04
26+
27+### packages
28+- none.
29+
30+### cookbooks
31+- `docker-grid`
32+- `platform_utils`
33+- `ssl_cert`
34+
35+## Attributes
36+
37+|Key|Type|Description, example|Default|
38+|:--|:--|:--|:--|
39+|`['nexus-grid']['docker-compose']['app_dir']`|String||`"#{node['docker-grid']['compose']['app_dir']}/nexus"`|
40+|`['nexus-grid']['docker-compose']['data_dir']`|String|Path string or nil (unset).|`"#{node['nexus-grid']['docker-compose']['app_dir']}/data"`|
41+|`['nexus-grid']['docker-compose']['config']`|Hash|`docker-compose.yml` configurations.|See `attributes/default.rb`|
42+
43+## Usage
44+
45+### Recipes
46+
47+#### nexus-grid::default
48+
49+This recipe does nothing.
50+
51+#### nexus-grid::docker-compose
52+
53+This recipe generates a `docker-compose.yml` file for the Sonatype Nexus Repository Manager service.
54+
55+### Role Examples
56+
57+- `roles/nexus.rb`
58+
59+```ruby
60+name 'nexus'
61+description 'Nexus'
62+
63+run_list(
64+ 'role[docker]',
65+ 'recipe[nexus-grid::docker-compose]',
66+)
67+
68+image = 'sonatype/nexus3'
69+port = '8081'
70+
71+override_attributes(
72+ 'nexus-grid' => {
73+ #'https_enabled' => true, # not supported yet.
74+ 'docker-compose' => {
75+ 'config' => {
76+ 'version' => '2',
77+ 'services' => {
78+ 'nexus' => {
79+ 'restart' => 'always',
80+ 'image' => image,
81+ 'ports' => [
82+ "#{port}:8081",
83+ ],
84+ 'volumes' => [
85+ # This volume will be set by the nexus-grid::docker-compose recipe automatically.
86+ #"#{node['nexus-grid']['docker-compose']['data_dir']}:/nexus-data",
87+ ],
88+ 'environment' => {
89+ #JAVA_MAX_HEAP => '1200m', # passed as -Xmx. Defaults to 1200m.
90+ #JAVA_MIN_HEAP => '1200m', # passed as -Xms. Defaults to 1200m.
91+ #EXTRA_JAVA_OPTS => '', # Additional options can be passed to the JVM via this variable.
92+ },
93+ },
94+ },
95+ },
96+ },
97+ },
98+)
99+```
100+
101+## License and Authors
102+
103+- Author:: whitestar at osdn.jp
104+
105+```text
106+Copyright 2017, whitestar
107+
108+Licensed under the Apache License, Version 2.0 (the "License");
109+you may not use this file except in compliance with the License.
110+You may obtain a copy of the License at
111+
112+ http://www.apache.org/licenses/LICENSE-2.0
113+
114+Unless required by applicable law or agreed to in writing, software
115+distributed under the License is distributed on an "AS IS" BASIS,
116+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
117+See the License for the specific language governing permissions and
118+limitations under the License.
119+```
--- /dev/null
+++ b/cookbooks/nexus-grid/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/nexus-grid/attributes/default.rb
@@ -0,0 +1,57 @@
1+#
2+# Cookbook Name:: nexus-grid
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+# Not supported yet.
21+force_override['nexus-grid']['https_enabled'] = false
22+force_override['nexus-grid']['with_ssl_cert_cookbook'] = false
23+# If ['nexus-grid']['with_ssl_cert_cookbook'] is true,
24+# node['nexus-grid']['docker-compose']['config']
25+# are overridden by the following 'common_name' attributes.
26+force_override['nexus-grid']['ssl_cert']['ca_names'] = []
27+force_override['nexus-grid']['ssl_cert']['common_name'] = node['fqdn']
28+
29+default['nexus-grid']['docker-compose']['app_dir'] = "#{node['docker-grid']['compose']['app_dir']}/nexus"
30+default['nexus-grid']['docker-compose']['data_dir'] = "#{node['nexus-grid']['docker-compose']['app_dir']}/data"
31+
32+force_override['nexus-grid']['docker-compose']['config_format_version'] = '2'
33+version_2_config = {
34+ # Version 2 docker-compose format
35+ 'version' => '2',
36+ 'services' => {
37+ 'nexus' => {
38+ 'restart' => 'always',
39+ 'image' => 'sonatype/nexus3',
40+ 'ports' => [
41+ #'8081:8081',
42+ #'8443:8443',
43+ ],
44+ 'volumes' => [
45+ # This volume will be set by the nexus-grid::docker-compose recipe automatically.
46+ #"#{node['nexus-grid']['docker-compose']['data_dir']}:/nexus-data",
47+ ],
48+ 'environment' => {
49+ #JAVA_MAX_HEAP => '1200m', # passed as -Xmx. Defaults to 1200m.
50+ #JAVA_MIN_HEAP => '1200m', # passed as -Xms. Defaults to 1200m.
51+ #EXTRA_JAVA_OPTS => '', # Additional options can be passed to the JVM via this variable.
52+ },
53+ },
54+ },
55+}
56+
57+default['nexus-grid']['docker-compose']['config'] = version_2_config
--- /dev/null
+++ b/cookbooks/nexus-grid/concourse.yml
@@ -0,0 +1,100 @@
1+---
2+# $ fly -t target sp -p nexus-grid-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/nexus-grid/fly-vars.yml
@@ -0,0 +1,3 @@
1+---
2+cookbook-name: nexus-grid
3+chefdk-version: 1.4.3
--- /dev/null
+++ b/cookbooks/nexus-grid/metadata.rb
@@ -0,0 +1,20 @@
1+name 'nexus-grid'
2+maintainer 'whitestar'
3+maintainer_email ''
4+license 'Apache 2.0'
5+description 'Installs/Configures Sonatype Nexus Repository Manager'
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.0'
14+end
15+supports 'debian', '>= 8.0'
16+supports 'ubuntu', '>= 14.04'
17+
18+depends 'docker-grid', '>= 0.2.7'
19+depends 'platform_utils', '>= 0.4.3'
20+depends 'ssl_cert', '>= 0.3.7'
--- /dev/null
+++ b/cookbooks/nexus-grid/recipes/default.rb
@@ -0,0 +1,18 @@
1+#
2+# Cookbook Name:: nexus-grid
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/nexus-grid/recipes/docker-compose.rb
@@ -0,0 +1,104 @@
1+#
2+# Cookbook Name:: nexus-grid
3+# Recipe:: 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+::Chef::Recipe.send(:include, SSLCert::Helper)
21+
22+doc_url = 'https://hub.docker.com/r/sonatype/nexus3/'
23+
24+include_recipe 'platform_utils::kernel_user_namespace'
25+include_recipe 'docker-grid::compose'
26+
27+app_dir = node['nexus-grid']['docker-compose']['app_dir']
28+data_dir = node['nexus-grid']['docker-compose']['data_dir']
29+#bin_dir = "#{app_dir}/bin"
30+
31+[
32+ app_dir,
33+ #bin_dir,
34+].each {|dir|
35+ resources(directory: dir) rescue directory dir do
36+ owner 'root'
37+ group 'root'
38+ mode '0755'
39+ recursive true
40+ end
41+}
42+
43+config_srvs = node['nexus-grid']['docker-compose']['config']['services']
44+override_config_srvs = node.override['nexus-grid']['docker-compose']['config']['services']
45+#force_override_config_srvs = node.force_override['nexus-grid']['docker-compose']['config']['services']
46+#envs_org = config_srvs['nexus']['environment']
47+#envs = {}
48+vols = config_srvs['nexus']['volumes'].to_a
49+
50+# Data persistent
51+resources(directory: data_dir) rescue directory data_dir do
52+ owner 200
53+ group 'root'
54+ mode '0700'
55+ recursive true
56+end if !data_dir.nil? && !data_dir.empty?
57+
58+vols.push("#{data_dir}:/nexus-data") if !data_dir.nil? && !data_dir.empty?
59+
60+ports = config_srvs['nexus']['ports']
61+override_config_srvs['nexus']['ports'] = ['8081:8081'] if ports.empty?
62+
63+if node['nexus-grid']['https_enabled']
64+ etc_dir = "#{data_dir}/etc"
65+ resources(directory: etc_dir) rescue directory etc_dir do
66+ owner 200
67+ group 200
68+ mode '0755'
69+ recursive true
70+ end
71+
72+ template "#{etc_dir}/nexus.properties" do
73+ source 'opt/docker-compose/app/nexus/data/etc/nexus.properties'
74+ owner 200
75+ group 200
76+ mode '0644'
77+ action :create
78+ end
79+
80+ override_config_srvs['nexus']['ports'] = ['8443:8443'] if ports.empty?
81+end
82+
83+# merge environment hash
84+#force_override_config_srvs['nexus']['environment'] = envs unless envs.empty?
85+# reset vlumes array.
86+override_config_srvs['nexus']['volumes'] = vols unless vols.empty?
87+
88+config_file = "#{app_dir}/docker-compose.yml"
89+template config_file do
90+ source 'opt/docker-compose/app/nexus/docker-compose.yml'
91+ owner 'root'
92+ group 'root'
93+ mode '0644'
94+end
95+
96+log <<-"EOM"
97+Note: You must execute the following command manually.
98+ See #{doc_url}
99+ - Start:
100+ $ cd #{app_dir}
101+ $ docker-compose up -d
102+ - Stop
103+ $ docker-compose down
104+EOM
--- /dev/null
+++ b/cookbooks/nexus-grid/spec/recipes/default_spec.rb
@@ -0,0 +1,9 @@
1+require_relative '../spec_helper'
2+
3+describe 'nexus-grid::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/nexus-grid/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/nexus-grid/templates/default/opt/docker-compose/app/nexus/data/etc/nexus.properties
@@ -0,0 +1,19 @@
1+# Jetty section
2+# application-port=8081
3+# application-host=0.0.0.0
4+# nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
5+# nexus-context-path=/${NEXUS_CONTEXT}
6+<%
7+if node['nexus-grid']['https_enabled']
8+-%>
9+# for HTTPS
10+application-port-ssl=8443
11+nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-https.xml,${jetty.etc}/jetty-requestlog.xml
12+<%
13+end
14+-%>
15+
16+# Nexus section
17+# nexus-edition=nexus-pro-edition
18+# nexus-features=\
19+# nexus-pro-feature
--- /dev/null
+++ b/cookbooks/nexus-grid/templates/default/opt/docker-compose/app/nexus/docker-compose.yml
@@ -0,0 +1,5 @@
1+<%
2+require 'yaml'
3+yaml_str = node['nexus-grid']['docker-compose']['config'].to_hash.to_yaml
4+-%>
5+<%= yaml_str %>
--- /dev/null
+++ b/cookbooks/nexus-grid/version
@@ -0,0 +1 @@
1+0.1.0
Show on old repository browser