• R/O
  • HTTP
  • SSH
  • HTTPS

grid-chef-repo: コミット

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


コミットメタ情報

リビジョンf54fc99b9df10b546e5367bca9a8d33b6499f857 (tree)
日時2018-07-14 16:18:03
作者whitestar <whitestar@user...>
コミッターwhitestar

ログメッセージ

add minim-server cookbook.

変更サマリ

差分

--- /dev/null
+++ b/cookbooks/minim-server/.foodcritic
@@ -0,0 +1,2 @@
1+~FC001
2+~FC019
--- /dev/null
+++ b/cookbooks/minim-server/.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/minim-server/Berksfile
@@ -0,0 +1,19 @@
1+#
2+# Copyright 2018 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/minim-server/CHANGELOG.md
@@ -0,0 +1,5 @@
1+# minim-server CHANGELOG
2+
3+0.1.0
4+-----
5+- Initial release of minim-server
--- /dev/null
+++ b/cookbooks/minim-server/Gemfile
@@ -0,0 +1,4 @@
1+source 'https://rubygems.org'
2+
3+# with Chef DK
4+gem 'stove'
--- /dev/null
+++ b/cookbooks/minim-server/README.md
@@ -0,0 +1,107 @@
1+minim-server Cookbook
2+===================
3+
4+This cookbook sets up a MinimServer by Docker-compose.
5+You can build MinimServer Docker image and run it by `docker-compose`.
6+
7+Note: do not push a Docker image including MinimServer to any public registries, because its re-distribution is not allowed by the [MinimServer license](http://minimserver.com/license.html).
8+
9+## Contents
10+
11+- [Requirements](#requirements)
12+ - [platforms](#platforms)
13+ - [packages](#packages)
14+- [Attributes](#attributes)
15+- [Usage](#usage)
16+ - [Recipes](#recipes)
17+ - [minim-server::default](#minim-serverdefault)
18+ - [minim-server::docker-compose](#minim-serverdocker-compose)
19+ - [Role Examples](#role-examples)
20+- [License and Authors](#license-and-authors)
21+
22+## Requirements
23+
24+### platforms
25+
26+- Debian >= 9.0
27+- Ubuntu >= 16.04
28+- CentOS,RHEL >= 7.3
29+
30+### packages
31+- none.
32+
33+## Attributes
34+
35+|Key|Type|Description, example|Default|
36+|:--|:--|:--|:--|
37+|`['minim-server']['Dockerfile']['FROM']`|String|Base image in the `Dockerfile`.|See `attributes/default.rb`|
38+|`['minim-server']['docker-compose']['app_dir']`|String||`"#{node['docker-grid']['compose']['app_dir']}/minim-server"`|
39+|`['minim-server']['docker-compose']['data_dir']`|String||`"#{node['minim-server']['docker-compose']['app_dir']}/data"`|
40+|`['minim-server']['docker-compose']['dot_env']`|Hash|`.env` configurations.|See `attributes/default.rb`|
41+|`['minim-server']['docker-compose']['config']`|Hash|`docker-compose.yml` configurations.|See `attributes/default.rb`|
42+
43+## Usage
44+
45+### Recipes
46+
47+#### minim-server::default
48+
49+This recipe does nothing.
50+
51+#### minim-server::docker-compose
52+
53+This recipe generates a `docker-compose.yml` for the Minim-server.
54+
55+### Role Examples
56+
57+- `roles/minim-server-on-docker.rb`
58+
59+```ruby
60+name 'minim-server-on-docker'
61+description 'Minim-server on Docker'
62+
63+run_list(
64+ 'role[docker]',
65+ 'recipe[minim-server::docker-compose]',
66+)
67+
68+#env_run_lists
69+
70+#default_attributes
71+
72+override_attributes(
73+ 'minim-server' => {
74+ 'docker-compose' => {
75+ 'config' => {
76+ 'services' => {
77+ 'minim-server' => {
78+ 'volumes' => [
79+ '/path/local/media:/media:ro',
80+ ],
81+ },
82+ },
83+ },
84+ },
85+ },
86+)
87+```
88+
89+## License and Authors
90+
91+- Author:: whitestar at osdn.jp
92+
93+```text
94+Copyright 2018, whitestar
95+
96+Licensed under the Apache License, Version 2.0 (the "License");
97+you may not use this file except in compliance with the License.
98+You may obtain a copy of the License at
99+
100+ http://www.apache.org/licenses/LICENSE-2.0
101+
102+Unless required by applicable law or agreed to in writing, software
103+distributed under the License is distributed on an "AS IS" BASIS,
104+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
105+See the License for the specific language governing permissions and
106+limitations under the License.
107+```
--- /dev/null
+++ b/cookbooks/minim-server/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/minim-server/attributes/default.rb
@@ -0,0 +1,77 @@
1+#
2+# Cookbook Name:: minim-server
3+# Attributes:: default
4+#
5+# Copyright 2018, 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+minim_ver = '0.8.5.2'
21+image_name = nil
22+base_image = nil
23+download_url = nil
24+
25+case node['kernel']['machine']
26+when 'x86_64'
27+ image_name = 'docker-minimserver'
28+ base_image = 'java:8-jre'
29+ download_url = "http://jminim.com/cada/MinimServer-#{minim_ver}-linux-intel.tar.gz"
30+when 'armv7l'
31+ image_name = 'docker-minimserver-armhf'
32+ base_image = 'arm32v7/openjdk:8-jre'
33+ download_url = "http://jminim.com/cada/MinimServer-#{minim_ver}-linux-armhf.tar.gz"
34+end
35+
36+default['minim-server']['Dockerfile'] = {
37+ 'FROM' => base_image,
38+}
39+
40+default['minim-server']['docker-compose']['app_dir'] = "#{node['docker-grid']['compose']['app_dir']}/minim-server"
41+default['minim-server']['docker-compose']['data_dir'] = "#{node['minim-server']['docker-compose']['app_dir']}/data"
42+
43+default['minim-server']['docker-compose']['dot_env'] = {
44+ 'NAME' => image_name,
45+ 'MINIM_VER' => minim_ver,
46+ # archive url
47+ 'url' => download_url,
48+ # already not found!
49+ #'url' => 'http://jminim.com/cada/MinimServer-0.8.4-linux-x64.tar.gz',
50+ # Internal registry context, e.g. gitlab.io.example.com:5050/images
51+ 'REGISTRY' => 'local',
52+}
53+
54+force_override['minim-server']['docker-compose']['config_format_version'] = '2'
55+version_2_config = {
56+ # Version 2 docker-compose format
57+ 'version' => '2',
58+ 'services' => {
59+ 'minim-server' => {
60+ 'build' => {
61+ 'context' => './',
62+ 'args' => {
63+ 'url' => '${url}',
64+ },
65+ },
66+ 'image' => '${REGISTRY}/${NAME}:${MINIM_VER}',
67+ 'restart' => 'always',
68+ 'network_mode' => 'host',
69+ 'volumes' => [
70+ # These volumes will be set by the minim-server::docker-compose recipe automatically.
71+ #"#{node['minim-server']['docker-compose']['data_dir']}:/opt/minimserver/data:rw",
72+ ],
73+ },
74+ },
75+}
76+
77+default['minim-server']['docker-compose']['config'] = version_2_config
--- /dev/null
+++ b/cookbooks/minim-server/concourse.yml
@@ -0,0 +1,100 @@
1+---
2+# $ fly -t $CC_TARGET sp -p minim-server-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: 6h # 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/minim-server/fly-vars.yml
@@ -0,0 +1,3 @@
1+---
2+cookbook-name: minim-server
3+chefdk-version: 1.4.3
--- /dev/null
+++ b/cookbooks/minim-server/metadata.rb
@@ -0,0 +1,19 @@
1+name 'minim-server'
2+maintainer 'whitestar'
3+maintainer_email ''
4+license 'Apache 2.0'
5+description 'Installs/Configures minim-server'
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', '>= 9.0'
16+supports 'ubuntu', '>= 16.04'
17+
18+depends 'docker-grid', '>= 0.4.0'
19+depends 'platform_utils', '>= 0.4.4'
--- /dev/null
+++ b/cookbooks/minim-server/recipes/default.rb
@@ -0,0 +1,18 @@
1+#
2+# Cookbook Name:: minim-server
3+# Recipe:: default
4+#
5+# Copyright 2018, 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/minim-server/recipes/docker-compose.rb
@@ -0,0 +1,77 @@
1+#
2+# Cookbook Name:: minim-server
3+# Recipe:: docker-compose
4+#
5+# Copyright 2018, 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://hub.docker.com/r/tromatik/docker-minimserver/'
21+
22+include_recipe 'platform_utils::kernel_user_namespace'
23+include_recipe 'docker-grid::compose'
24+
25+app_dir = node['minim-server']['docker-compose']['app_dir']
26+data_dir = node['minim-server']['docker-compose']['data_dir']
27+
28+[
29+ app_dir,
30+ data_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['minim-server']['docker-compose']['config']['services']
41+override_config_srvs = node.override['minim-server']['docker-compose']['config']['services']
42+force_override_config_srvs = node.force_override['minim-server']['docker-compose']['config']['services']
43+envs = {}
44+vols = config_srvs['minim-server']['volumes'].to_a
45+
46+vols.push("#{data_dir}:/opt/minimserver/data:rw")
47+
48+# merge environment hash
49+force_override_config_srvs['minim-server']['environment'] = envs unless envs.empty?
50+# reset vlumes array.
51+override_config_srvs['minim-server']['volumes'] = vols unless vols.empty?
52+
53+[
54+ 'Dockerfile',
55+ '.env',
56+ 'docker-compose.yml',
57+ 'minimserver.config',
58+].each {|conf_file|
59+ template "#{app_dir}/#{conf_file}" do
60+ source "opt/docker-compose/app/minim-server/#{conf_file}"
61+ owner 'root'
62+ group 'root'
63+ mode '0644'
64+ end
65+}
66+
67+log 'minim-server docker-compose post install message' do
68+ message <<-"EOM"
69+Note: You must execute the following command manually.
70+ See #{doc_url}
71+ * Start:
72+ $ cd #{app_dir}
73+ $ docker-compose up -d
74+ * Stop
75+ $ docker-compose down
76+EOM
77+end
--- /dev/null
+++ b/cookbooks/minim-server/spec/recipes/default_spec.rb
@@ -0,0 +1,9 @@
1+require_relative '../spec_helper'
2+
3+describe 'minim-server::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/minim-server/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/minim-server/templates/default/opt/docker-compose/app/minim-server/.env
@@ -0,0 +1,8 @@
1+<%
2+dot_env = node['minim-server']['docker-compose']['dot_env']
3+-%>
4+# for docker-compose.yml
5+NAME=<%= dot_env['NAME'] %>
6+MINIM_VER=<%= dot_env['MINIM_VER'] %>
7+url=<%= dot_env['url'] %>
8+REGISTRY=<%= dot_env['REGISTRY'] %>
--- /dev/null
+++ b/cookbooks/minim-server/templates/default/opt/docker-compose/app/minim-server/Dockerfile
@@ -0,0 +1,14 @@
1+FROM <%= node['minim-server']['Dockerfile']['FROM'] %>
2+
3+ARG url=http://jminim.com/cada/MinimServer-0.8.5.2-linux-intel.tar.gz
4+
5+RUN wget -O /opt/MinimServer.tar.gz ${url} && \
6+ cd /opt && \
7+ tar xf MinimServer.tar.gz && \
8+ rm MinimServer.tar.gz
9+
10+COPY ./minimserver.config /opt/minimserver/data/minimserver.config
11+
12+EXPOSE 9790 9791
13+
14+ENTRYPOINT [ "/opt/minimserver/bin/startc" ]
--- /dev/null
+++ b/cookbooks/minim-server/templates/default/opt/docker-compose/app/minim-server/docker-compose.yml
@@ -0,0 +1,5 @@
1+<%
2+require 'yaml'
3+yaml_str = node['minim-server']['docker-compose']['config'].to_hash.to_yaml
4+-%>
5+<%= yaml_str %>
--- /dev/null
+++ b/cookbooks/minim-server/templates/default/opt/docker-compose/app/minim-server/minimserver.config
@@ -0,0 +1,8 @@
1+minimserver.lastIndexTags = Artist, Date, Genre, All Artists, Composer
2+minimserver.tagOptions = Album.sortTags\={Album, Artist}
3+minimserver.systemUpdateID = 3
4+minimserver.previousAlbumArtistDisplayRole = true
5+minimserver.tagCustom = AlbumArtist.displayRole\={artist}, Composer.displayRole\={artist}
6+minimserver.alphaGroup = albums\=20, Artist\=20, Composer
7+minimserver.configVersion = 0.8.213
8+minimserver.contentDir = /media
--- /dev/null
+++ b/cookbooks/minim-server/version
@@ -0,0 +1 @@
1+0.1.0
旧リポジトリブラウザで表示