Grid環境構築用のChefリポジトリです。
Revision | 9d1bb029bb33fa53fe8f35ca3fb95faf39395e0e (tree) |
---|---|
Zeit | 2016-12-21 23:13:26 |
Autor | whitestar <whitestar@gaea...> |
Commiter | whitestar |
adds the jenkins-grid cookbook.
@@ -0,0 +1 @@ | ||
1 | +~FC001 |
@@ -0,0 +1,37 @@ | ||
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/SpaceBeforeFirstArg: | |
26 | + Enabled: false | |
27 | +Style/TrailingCommaInLiteral: | |
28 | + EnforcedStyleForMultiline: comma | |
29 | +Style/WordArray: | |
30 | + Enabled: false | |
31 | + | |
32 | +#Style/AccessorMethodName: | |
33 | +# Enabled: false | |
34 | +#Metrics/MethodLength: | |
35 | +# Max: 15 | |
36 | +#Style/ModuleLength: | |
37 | +# Max: 150 |
@@ -0,0 +1,5 @@ | ||
1 | +# jenkins-grid CHANGELOG | |
2 | + | |
3 | +0.1.0 | |
4 | +----- | |
5 | +- Initial release of jenkins-grid |
@@ -0,0 +1,3 @@ | ||
1 | +source 'https://rubygems.org' | |
2 | + | |
3 | +#gem 'foodcritic' |
@@ -0,0 +1,111 @@ | ||
1 | +jenkins-grid Cookbook | |
2 | +===================== | |
3 | + | |
4 | +This cookbook sets up a Jenkins service. | |
5 | + | |
6 | +## Contents | |
7 | + | |
8 | +- [Requirements](#requirements) | |
9 | + - [platforms](#platforms) | |
10 | + - [packages](#packages) | |
11 | +- [Attributes](#attributes) | |
12 | +- [Usage](#usage) | |
13 | + - [Recipes](#recipes) | |
14 | + - [jenkins-grid::default](#jenkins-griddefault) | |
15 | + - [jenkins-grid::docker-compose](#jenkins-griddocker-compose) | |
16 | + - [Role Examples](#role-examples) | |
17 | +- [License and Authors](#license-and-authors) | |
18 | + | |
19 | +## Requirements | |
20 | + | |
21 | +### platforms | |
22 | +- none. | |
23 | + | |
24 | +### packages | |
25 | +- none. | |
26 | + | |
27 | +## Attributes | |
28 | + | |
29 | +|Key|Type|Description, example|Default| | |
30 | +|:--|:--|:--|:--| | |
31 | +|`['jenkins-grid']['docker-compose']['app_dir']`|String||`"#{node['docker-grid']['compose']['app_dir']}/jenkins"`| | |
32 | +|`['jenkins-grid']['docker-compose']['jenkins_home']['path']`|String|Path string or nil (unset).|`'/var/lib/jenkins_home'`| | |
33 | +|`['jenkins-grid']['docker-compose']['jenkins_home']['owner']`|String, Int|Owner user name or uid.|`1000`| | |
34 | +|`['jenkins-grid']['docker-compose']['config']`|Hash|`docker-compose.yml` configurations.|See `attributes/default.rb`| | |
35 | + | |
36 | +## Usage | |
37 | + | |
38 | +### Recipes | |
39 | + | |
40 | +#### jenkins-grid::default | |
41 | + | |
42 | +This recipe does nothing. | |
43 | + | |
44 | +#### jenkins-grid::docker-compose | |
45 | + | |
46 | +This recipe generates a docker-compose.yml for the Jenkins CI service. | |
47 | + | |
48 | +### Role Examples | |
49 | + | |
50 | +- `roles/jenkins.rb` | |
51 | + | |
52 | +```ruby | |
53 | +name 'jenkins' | |
54 | +description 'Jenkins' | |
55 | + | |
56 | +run_list( | |
57 | + 'role[docker]', | |
58 | + 'recipe[jenkins-grid::docker-compose]', | |
59 | +) | |
60 | + | |
61 | +#env_run_lists() | |
62 | + | |
63 | +#default_attributes() | |
64 | + | |
65 | +override_attributes( | |
66 | + 'jenkins-grid' => { | |
67 | + 'docker-compose' => { | |
68 | + 'config' => { | |
69 | + # Version 2 docker-compose format | |
70 | + 'version' => '2', | |
71 | + 'services' => { | |
72 | + 'jenkins' => { | |
73 | + 'restart' => 'always', | |
74 | + 'image' => 'jenkins:2.19.4', | |
75 | + 'ports' => [ | |
76 | + '8080:8080', | |
77 | + '50000:50000', | |
78 | + ], | |
79 | + #'environment' => { | |
80 | + #}, | |
81 | + #'volumes' => [ | |
82 | + # # set automatically, if the node['jenkins-grid']['docker-compose']['jenkins_home']['path'] is not nil. | |
83 | + # "#{node['jenkins-grid']['docker-compose']['jenkins_home']['path']}:/var/jenkins_home", | |
84 | + #], | |
85 | + }, | |
86 | + }, | |
87 | + }, | |
88 | + }, | |
89 | + }, | |
90 | +) | |
91 | +``` | |
92 | + | |
93 | +## License and Authors | |
94 | + | |
95 | +- Author:: whitestar at osdn.jp | |
96 | + | |
97 | +```text | |
98 | +Copyright 2016, whitestar | |
99 | + | |
100 | +Licensed under the Apache License, Version 2.0 (the "License"); | |
101 | +you may not use this file except in compliance with the License. | |
102 | +You may obtain a copy of the License at | |
103 | + | |
104 | + http://www.apache.org/licenses/LICENSE-2.0 | |
105 | + | |
106 | +Unless required by applicable law or agreed to in writing, software | |
107 | +distributed under the License is distributed on an "AS IS" BASIS, | |
108 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
109 | +See the License for the specific language governing permissions and | |
110 | +limitations under the License. | |
111 | +``` |
@@ -0,0 +1,23 @@ | ||
1 | +require 'rspec/core/rake_task' | |
2 | +require 'rubocop/rake_task' | |
3 | +require 'foodcritic' | |
4 | + | |
5 | +namespace :style do | |
6 | + desc 'Run Ruby style checks' | |
7 | + RuboCop::RakeTask.new(:ruby) | |
8 | + | |
9 | + desc 'Run Chef style checks' | |
10 | + FoodCritic::Rake::LintTask.new(:chef) do |t| | |
11 | + t.options = { | |
12 | + fail_tags: ['any'], | |
13 | + } | |
14 | + end | |
15 | +end | |
16 | + | |
17 | +desc 'Run all style checks' | |
18 | +task style: ['style:chef', 'style:ruby'] | |
19 | + | |
20 | +desc 'Run ChefSpec examples' | |
21 | +RSpec::Core::RakeTask.new(:spec) | |
22 | + | |
23 | +task default: ['style', 'spec'] |
@@ -0,0 +1,46 @@ | ||
1 | +# | |
2 | +# Cookbook Name:: jenkins-grid | |
3 | +# Attributes:: default | |
4 | +# | |
5 | +# Copyright 2016, 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['jenkins-grid']['with_ssl_cert_cookbook'] = false | |
21 | +#default['jenkins-grid']['ssl_cert']['common_name'] = node['fqdn'] | |
22 | +default['jenkins-grid']['docker-compose']['app_dir'] = "#{node['docker-grid']['compose']['app_dir']}/jenkins" | |
23 | +default['jenkins-grid']['docker-compose']['jenkins_home'] = { | |
24 | + 'path' => '/var/lib/jenkins_home', | |
25 | + 'owner' => 1000, | |
26 | +} | |
27 | +jenkins_home_path = node['jenkins-grid']['docker-compose']['jenkins_home']['path'] | |
28 | +default['jenkins-grid']['docker-compose']['config'] = { | |
29 | + # Version 2 docker-compose format | |
30 | + 'version' => '2', | |
31 | + 'services' => { | |
32 | + 'jenkins' => { | |
33 | + 'restart' => 'always', | |
34 | + 'image' => 'jenkins:2.19.4', | |
35 | + #'ports' => [ | |
36 | + # '8080:8080', | |
37 | + # '50000:50000', | |
38 | + #], | |
39 | + #'environment' => { | |
40 | + #}, | |
41 | + 'volumes' => [ | |
42 | + jenkins_home_path.nil? ? nil : "#{jenkins_home_path}:/var/jenkins_home", | |
43 | + ], | |
44 | + }, | |
45 | + }, | |
46 | +} |
@@ -0,0 +1,13 @@ | ||
1 | +# $ knife supermarket share jenkins-grid "Applications" | |
2 | +name 'jenkins-grid' | |
3 | +maintainer 'whitestar' | |
4 | +maintainer_email '' | |
5 | +license 'Apache 2.0' | |
6 | +description 'Installs/Configures jenkins-grid' | |
7 | +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | |
8 | +version '0.1.0' | |
9 | +source_url 'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git' | |
10 | +issues_url 'https://osdn.jp/projects/metasearch/ticket' | |
11 | + | |
12 | +depends 'docker-grid', '>= 0.2.7' | |
13 | +depends 'ssl_cert', '>= 0.3.3' |
@@ -0,0 +1,18 @@ | ||
1 | +# | |
2 | +# Cookbook Name:: jenkins-grid | |
3 | +# Recipe:: default | |
4 | +# | |
5 | +# Copyright 2016, 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 | +# |
@@ -0,0 +1,74 @@ | ||
1 | +# | |
2 | +# Cookbook Name:: jenkins-grid | |
3 | +# Recipe:: docker-compose | |
4 | +# | |
5 | +# Copyright 2016, 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/_/jenkins/' | |
21 | + | |
22 | +include_recipe 'docker-grid::compose' | |
23 | + | |
24 | +app_dir = node['jenkins-grid']['docker-compose']['app_dir'] | |
25 | +#auth_dir = "#{app_dir}/auth" | |
26 | +#etc_dir = "#{app_dir}/etc" | |
27 | +[ | |
28 | + app_dir, | |
29 | + #auth_dir, | |
30 | + #etc_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 | +directory node['jenkins-grid']['docker-compose']['jenkins_home']['path'] do | |
41 | + owner node['jenkins-grid']['docker-compose']['jenkins_home']['owner'] | |
42 | + group 'root' | |
43 | + mode '0755' | |
44 | + recursive true | |
45 | +end | |
46 | + | |
47 | +=begin | |
48 | +if node['jenkins-grid']['with_ssl_cert_cookbook'] | |
49 | + ::Chef::Recipe.send(:include, SSLCert::Helper) | |
50 | + cn = node['jenkins-grid']['ssl_cert']['common_name'] | |
51 | + TODO: | |
52 | +end | |
53 | +=end | |
54 | + | |
55 | +[ | |
56 | + 'docker-compose.yml', | |
57 | +].each {|conf_file| | |
58 | + template "#{app_dir}/#{conf_file}" do | |
59 | + source "opt/docker-compose/app/jenkins/#{conf_file}" | |
60 | + owner 'root' | |
61 | + group 'root' | |
62 | + mode '0644' | |
63 | + end | |
64 | +} | |
65 | + | |
66 | +log <<-"EOM" | |
67 | +Note: You must execute the following command manually. | |
68 | + See #{doc_url} | |
69 | + - Start: | |
70 | + $ cd #{app_dir} | |
71 | + $ docker-compose up -d | |
72 | + - Stop | |
73 | + $ docker-compose down | |
74 | +EOM |
@@ -0,0 +1,9 @@ | ||
1 | +require_relative '../spec_helper' | |
2 | + | |
3 | +describe 'jenkins-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 |
@@ -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 |
@@ -0,0 +1,7 @@ | ||
1 | +<% | |
2 | +config = node['jenkins-grid']['docker-compose']['config'] | |
3 | + | |
4 | +require 'yaml' | |
5 | +yaml_str = config.to_hash.to_yaml | |
6 | +-%> | |
7 | +<%= yaml_str %> |
@@ -0,0 +1,49 @@ | ||
1 | +name 'jenkins' | |
2 | +description 'Jenkins' | |
3 | + | |
4 | +run_list( | |
5 | + 'role[docker]', | |
6 | + 'recipe[jenkins-grid::docker-compose]', | |
7 | +) | |
8 | + | |
9 | +#env_run_lists() | |
10 | + | |
11 | +#default_attributes() | |
12 | + | |
13 | +override_attributes( | |
14 | + 'jenkins-grid' => { | |
15 | + #'with_ssl_cert_cookbook' => false, | |
16 | + #'ssl_cert' => { | |
17 | + # 'common_name' => 'jenkins.io.example.com', | |
18 | + #}, | |
19 | + 'docker-compose' => { | |
20 | + 'config' => { | |
21 | + # Version 2 docker-compose format | |
22 | + 'version' => '2', | |
23 | + 'services' => { | |
24 | + 'jenkins' => { | |
25 | + 'restart' => 'always', | |
26 | + 'image' => 'jenkins:2.19.4', | |
27 | + 'ports' => [ | |
28 | + '8080:8080', | |
29 | + '50000:50000', | |
30 | + ], | |
31 | + #'environment' => { | |
32 | + #}, | |
33 | + #'volumes' => [ | |
34 | + # "#{node['jenkins-grid']['docker-compose']['jenkins_home']['path']}:/var/jenkins_home", | |
35 | + #], | |
36 | + }, | |
37 | + }, | |
38 | + }, | |
39 | + }, | |
40 | + }, | |
41 | + 'ssl_cert' => { | |
42 | + 'ca_names' => [ | |
43 | + 'grid_ca', | |
44 | + ], | |
45 | + 'common_names' => [ | |
46 | + 'jenkins.io.example.com', | |
47 | + ], | |
48 | + } | |
49 | +) |