Grid環境構築用のChefリポジトリです。
Révision | 6041782b8fe0f1cce3b658fb8b72c5b616bf765b (tree) |
---|---|
l'heure | 2017-02-11 10:42:35 |
Auteur | whitestar <whitestar@gaea...> |
Commiter | whitestar |
Initial release of concourse-ci
@@ -0,0 +1,2 @@ | ||
1 | +~FC001 | |
2 | +~FC019 |
@@ -0,0 +1,47 @@ | ||
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 | +#Lint/ShadowingOuterLocalVariable: | |
33 | +# Enabled: false | |
34 | +#Metrics/MethodLength: | |
35 | +# Max: 10 | |
36 | +#Metrics/ModuleLength: | |
37 | +# Max: 100 | |
38 | +#Metrics/CyclomaticComplexity: | |
39 | +# Max: 6 | |
40 | +#Metrics/PerceivedComplexity: | |
41 | +# Max: 7 | |
42 | +#Style/AccessorMethodName: | |
43 | +# Enabled: false | |
44 | +#Style/MultilineOperationIndentation: | |
45 | +# Enabled: false | |
46 | +#Style/PerlBackrefs: | |
47 | +# Enabled: false |
@@ -0,0 +1,6 @@ | ||
1 | +concourse-ci CHANGELOG | |
2 | +====================== | |
3 | + | |
4 | +0.1.0 | |
5 | +----- | |
6 | +- Initial release of concourse-ci |
@@ -0,0 +1,3 @@ | ||
1 | +source 'https://rubygems.org' | |
2 | + | |
3 | +#gem 'foodcritic' |
@@ -0,0 +1,113 @@ | ||
1 | +concourse-ci Cookbook | |
2 | +===================== | |
3 | + | |
4 | +This cookbook sets up a Concourse CI service 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 | + - [concourse-ci::default](#concourse-cidefault) | |
16 | + - [concourse-ci::docker-compose](#concourse-cidocker-compose) | |
17 | + - [Role Examples](#role-examples) | |
18 | +- [License and Authors](#license-and-authors) | |
19 | + | |
20 | +## Requirements | |
21 | + | |
22 | +### platforms | |
23 | +- none. | |
24 | + | |
25 | +### packages | |
26 | +- none. | |
27 | + | |
28 | +### cookbooks | |
29 | +- `docker-grid` | |
30 | +- `ssl_cert` | |
31 | + | |
32 | +## Attributes | |
33 | + | |
34 | +|Key|Type|Description, example|Default| | |
35 | +|:--|:--|:--|:--| | |
36 | +|`['concourse-ci']['docker-compose']['app_dir']`|String||`"#{node['docker-grid']['compose']['app_dir']}/concourse"`| | |
37 | +|`['concourse-ci']['docker-compose']['pgdata_dir']`|String|Path string or nil (unset).|`"#{node['concourse-ci']['docker-compose']['app_dir']}/database"`| | |
38 | +|`['concourse-ci']['docker-compose']['web_keys_dir']`|String|Path string.|`"#{node['concourse-ci']['docker-compose']['app_dir']}/keys/web"`| | |
39 | +|`['concourse-ci']['docker-compose']['worker_keys_dir']`|String|Path string.|`"#{node['concourse-ci']['docker-compose']['app_dir']}/keys/worker"`| | |
40 | +|`['concourse-ci']['docker-compose']['pgdata_dir']`|String|Path string or nil (unset).|`"#{node['concourse-ci']['docker-compose']['app_dir']}/database"`| | |
41 | +|`['concourse-ci']['docker-compose']['config_format_version']`|String|Read only. `docker-compose.yml` format version. Only version 1 is supported now.|`'1'`| | |
42 | +|`['concourse-ci']['docker-compose']['config']`|Hash|`docker-compose.yml` configurations.|See `attributes/default.rb`| | |
43 | + | |
44 | +## Usage | |
45 | + | |
46 | +### Recipes | |
47 | + | |
48 | +#### concourse-ci::default | |
49 | + | |
50 | +This recipe does nothing. | |
51 | + | |
52 | +#### concourse-ci::docker-compose | |
53 | + | |
54 | +This recipe generates SSH keys of each node and a `docker-compose.yml` file for the Concourse CI service. | |
55 | + | |
56 | +### Role Examples | |
57 | + | |
58 | +- `roles/concourse.rb` | |
59 | + | |
60 | +```ruby | |
61 | +name 'concourse' | |
62 | +description 'Concourse' | |
63 | + | |
64 | +run_list( | |
65 | + 'role[docker]', | |
66 | + 'recipe[concourse-ci::docker-compose]', | |
67 | +) | |
68 | + | |
69 | +image = 'concourse/concourse:2.6.0' | |
70 | +port = '18080' | |
71 | + | |
72 | +override_attributes( | |
73 | + 'concourse-ci' => { | |
74 | + 'docker-compose' => { | |
75 | + 'config' => { | |
76 | + # Version 1 docker-compose format | |
77 | + 'concourse-web' => { | |
78 | + 'image' => image, | |
79 | + 'ports' => [ | |
80 | + "#{port}:8080", | |
81 | + ], | |
82 | + 'environment' => { | |
83 | + 'CONCOURSE_EXTERNAL_URL' => "http://192.168.1.3:#{port}", | |
84 | + }, | |
85 | + }, | |
86 | + 'concourse-worker' => { | |
87 | + 'image' => image, | |
88 | + }, | |
89 | + }, | |
90 | + }, | |
91 | + }, | |
92 | +) | |
93 | +``` | |
94 | + | |
95 | +## License and Authors | |
96 | + | |
97 | +- Author:: whitestar at osdn.jp | |
98 | + | |
99 | +```text | |
100 | +Copyright 2017, whitestar | |
101 | + | |
102 | +Licensed under the Apache License, Version 2.0 (the "License"); | |
103 | +you may not use this file except in compliance with the License. | |
104 | +You may obtain a copy of the License at | |
105 | + | |
106 | + http://www.apache.org/licenses/LICENSE-2.0 | |
107 | + | |
108 | +Unless required by applicable law or agreed to in writing, software | |
109 | +distributed under the License is distributed on an "AS IS" BASIS, | |
110 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
111 | +See the License for the specific language governing permissions and | |
112 | +limitations under the License. | |
113 | +``` |
@@ -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,148 @@ | ||
1 | +# | |
2 | +# Cookbook Name:: concourse-ci | |
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 | +# TODO: support with_ssl_cert_cookbook | |
21 | +force_override['concourse-ci']['with_ssl_cert_cookbook'] = false | |
22 | +# If ['concourse-ci']['with_ssl_cert_cookbook'] is true, | |
23 | +# node['concourse-ci']['docker-compose']['config'] | |
24 | +# are overridden by the following 'common_name' attributes. | |
25 | +default['concourse-ci']['ssl_cert']['common_name'] = node['fqdn'] | |
26 | +default['concourse-ci']['docker-compose']['app_dir'] = "#{node['docker-grid']['compose']['app_dir']}/concourse" | |
27 | +default['concourse-ci']['docker-compose']['pgdata_dir'] = "#{node['concourse-ci']['docker-compose']['app_dir']}/database" | |
28 | +default['concourse-ci']['docker-compose']['web_keys_dir'] = "#{node['concourse-ci']['docker-compose']['app_dir']}/keys/web" | |
29 | +default['concourse-ci']['docker-compose']['worker_keys_dir'] = "#{node['concourse-ci']['docker-compose']['app_dir']}/keys/worker" | |
30 | + | |
31 | +# TODO: support version 2 format, and use `default` instead of `force_override` | |
32 | +force_override['concourse-ci']['docker-compose']['config_format_version'] = '1' | |
33 | +version_1_config = { | |
34 | + 'concourse-db' => { | |
35 | + 'restart' => 'always', | |
36 | + 'image' => 'postgres:9.5', | |
37 | + 'volumes' => [ | |
38 | + #"#{node['concourse-ci']['docker-compose']['pgdata_dir']}:/database", | |
39 | + ], | |
40 | + 'environment' => { | |
41 | + 'POSTGRES_DB' => 'concourse', | |
42 | + 'POSTGRES_USER' => 'concourse', | |
43 | + 'POSTGRES_PASSWORD' => nil, | |
44 | + 'PGDATA' => '/database', | |
45 | + }, | |
46 | + }, | |
47 | + 'concourse-web' => { | |
48 | + 'restart' => 'always', | |
49 | + 'image' => 'concourse/concourse', # latest, 2.6.0,... | |
50 | + 'links' => [ | |
51 | + 'concourse-db', | |
52 | + ], | |
53 | + 'command' => 'web', | |
54 | + 'ports' => [ | |
55 | + #'8080:8080', # If you sepecify no value, Chef will sets '8080:8080'. | |
56 | + ], | |
57 | + 'volumes' => [ | |
58 | + "#{node['concourse-ci']['docker-compose']['web_keys_dir']}:/concourse-keys", | |
59 | + ], | |
60 | + 'environment' => { | |
61 | + 'CONCOURSE_BASIC_AUTH_USERNAME' => 'concourse', | |
62 | + 'CONCOURSE_BASIC_AUTH_PASSWORD' => nil, | |
63 | + # If you sepecify no value, Chef will sets "http://#{node['ipaddress']}:8080". | |
64 | + 'CONCOURSE_EXTERNAL_URL' => nil, | |
65 | + # `<POSTGRES_PASSWORD>` is a placeholder of password string. | |
66 | + 'CONCOURSE_POSTGRES_DATA_SOURCE' => \ | |
67 | + 'postgres://concourse:<POSTGRES_PASSWORD>@concourse-db:5432/concourse?sslmode=disable', | |
68 | + }, | |
69 | + }, | |
70 | + 'concourse-worker' => { | |
71 | + 'restart' => 'always', | |
72 | + 'image' => 'concourse/concourse', | |
73 | + 'privileged' => true, | |
74 | + 'links' => [ | |
75 | + 'concourse-web', | |
76 | + ], | |
77 | + 'command' => 'worker', | |
78 | + 'volumes' => [ | |
79 | + "#{node['concourse-ci']['docker-compose']['worker_keys_dir']}:/concourse-keys", | |
80 | + ], | |
81 | + 'environment' => { | |
82 | + 'CONCOURSE_TSA_HOST' => 'concourse-web', | |
83 | + }, | |
84 | + }, | |
85 | +} | |
86 | + | |
87 | +# Not supported yet. | |
88 | +new_config = Marshal.load(Marshal.dump(version_1_config)) # deep copy | |
89 | +new_config['concourse-web'].delete('links') | |
90 | +new_config['concourse-worker'].delete('links') | |
91 | +version_2_config = { | |
92 | + # Version 2 docker-compose format | |
93 | + 'version' => '2', | |
94 | + 'services' => new_config, | |
95 | +} | |
96 | +=begin | |
97 | +version_2_config = { | |
98 | + # Version 2 docker-compose format | |
99 | + 'version' => '2', | |
100 | + 'services' => { | |
101 | + 'concourse-db' => { | |
102 | + 'restart' => 'always', | |
103 | + 'image' => 'postgres:9.5', | |
104 | + 'volumes' => [ | |
105 | + #"#{node['concourse-ci']['docker-compose']['pgdata_dir']}:/database", | |
106 | + ], | |
107 | + 'environment' => { | |
108 | + 'POSTGRES_DB' => 'concourse', | |
109 | + 'POSTGRES_USER' => 'concourse', | |
110 | + 'POSTGRES_PASSWORD' => nil, | |
111 | + 'PGDATA' => '/database', | |
112 | + }, | |
113 | + }, | |
114 | + 'concourse-web' => { | |
115 | + 'restart' => 'always', | |
116 | + 'image' => 'concourse/concourse', # latest, 2.6.0,... | |
117 | + 'command' => 'web', | |
118 | + 'ports' => [ | |
119 | + #'8080:8080', | |
120 | + ], | |
121 | + 'volumes' => [ | |
122 | + "#{node['concourse-ci']['docker-compose']['web_keys_dir']}:/concourse-keys", | |
123 | + ], | |
124 | + 'environment' => { | |
125 | + 'CONCOURSE_BASIC_AUTH_USERNAME' => 'concourse', | |
126 | + 'CONCOURSE_BASIC_AUTH_PASSWORD' => nil, | |
127 | + 'CONCOURSE_EXTERNAL_URL' => nil, | |
128 | + 'CONCOURSE_POSTGRES_DATA_SOURCE' => \ | |
129 | + 'postgres://concourse:<POSTGRES_PASSWORD>@concourse-db:5432/concourse?sslmode=disable', | |
130 | + }, | |
131 | + }, | |
132 | + 'concourse-worker' => { | |
133 | + 'restart' => 'always', | |
134 | + 'image' => 'concourse/concourse', | |
135 | + 'privileged' => true, | |
136 | + 'command' => 'worker', | |
137 | + 'volumes' => [ | |
138 | + "#{node['concourse-ci']['docker-compose']['worker_keys_dir']}:/concourse-keys", | |
139 | + ], | |
140 | + 'environment' => { | |
141 | + 'CONCOURSE_TSA_HOST' => 'concourse-web', | |
142 | + }, | |
143 | + }, | |
144 | + }, | |
145 | +} | |
146 | +=end | |
147 | +default['concourse-ci']['docker-compose']['config'] = \ | |
148 | + node['concourse-ci']['docker-compose']['config_format_version'] == '1' ? version_1_config : version_2_config |
@@ -0,0 +1,13 @@ | ||
1 | +# $ knife supermarket share concourse-ci "Applications" | |
2 | +name 'concourse-ci' | |
3 | +maintainer 'whitestar' | |
4 | +maintainer_email '' | |
5 | +license 'Apache 2.0' | |
6 | +description 'Installs/Configures Concourse CI by Docker Compose' | |
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:: concourse-ci | |
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 | +# |
@@ -0,0 +1,148 @@ | ||
1 | +# | |
2 | +# Cookbook Name:: concourse-ci | |
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 | +require 'securerandom' | |
21 | + | |
22 | +doc_url = 'https://concourse.ci/docker-repository.html' | |
23 | + | |
24 | +include_recipe 'docker-grid::compose' | |
25 | + | |
26 | +app_dir = node['concourse-ci']['docker-compose']['app_dir'] | |
27 | +pgdata_dir = node['concourse-ci']['docker-compose']['pgdata_dir'] | |
28 | +web_keys_dir = node['concourse-ci']['docker-compose']['web_keys_dir'] | |
29 | +worker_keys_dir = node['concourse-ci']['docker-compose']['worker_keys_dir'] | |
30 | +#certs_dir = "#{app_dir}/certs" | |
31 | + | |
32 | +[ | |
33 | + app_dir, | |
34 | + pgdata_dir, | |
35 | + web_keys_dir, | |
36 | + worker_keys_dir, | |
37 | + #certs_dir, | |
38 | +].each {|dir| | |
39 | + resources(directory: dir) rescue directory dir do | |
40 | + owner 'root' | |
41 | + group 'root' | |
42 | + mode '0755' | |
43 | + recursive true | |
44 | + end if !dir.nil? && !dir.empty? | |
45 | +} | |
46 | + | |
47 | +bash 'ssh-keygen_keys' do | |
48 | + code <<-"EOH" | |
49 | + script commands | |
50 | + ssh-keygen -t rsa -f #{web_keys_dir}/tsa_host_key -N '' | |
51 | + ssh-keygen -t rsa -f #{web_keys_dir}/session_signing_key -N '' | |
52 | + ssh-keygen -t rsa -f #{worker_keys_dir}/worker_key -N '' | |
53 | + cp #{worker_keys_dir}/worker_key.pub #{web_keys_dir}/authorized_worker_keys | |
54 | + cp #{web_keys_dir}/tsa_host_key.pub #{worker_keys_dir} | |
55 | + EOH | |
56 | + action :run | |
57 | + not_if { File.exist?("#{web_keys_dir}/tsa_host_key") } | |
58 | + not_if { File.exist?("#{web_keys_dir}/session_signing_key") } | |
59 | + not_if { File.exist?("#{worker_keys_dir}/worker_key") } | |
60 | +end | |
61 | + | |
62 | +config_format_version = node['concourse-ci']['docker-compose']['config_format_version'] | |
63 | + | |
64 | +# if config_format_version == '1' | |
65 | +config_srvs = node['concourse-ci']['docker-compose']['config'] | |
66 | +override_config_srvs = node.override['concourse-ci']['docker-compose']['config'] | |
67 | +force_override_config_srvs = node.force_override['concourse-ci']['docker-compose']['config'] | |
68 | +if config_format_version == '2' | |
69 | + config_srvs = config_srvs['services'] | |
70 | + override_config_srvs = override_config_srvs['services'] | |
71 | + force_override_config_srvs = force_override_config_srvs['services'] | |
72 | +end | |
73 | + | |
74 | +# Database | |
75 | +db_envs_org = config_srvs['concourse-db']['environment'] | |
76 | +db_envs = {} | |
77 | +db_vols = [] | |
78 | + | |
79 | +db_passwd = db_envs_org['POSTGRES_PASSWORD'] | |
80 | +if db_passwd.nil? || db_passwd.empty? | |
81 | + db_passwd = SecureRandom.hex # or urlsafe_base64 | |
82 | + db_envs['POSTGRES_PASSWORD'] = db_passwd | |
83 | +end | |
84 | + | |
85 | +db_vols.push("#{pgdata_dir}:#{db_envs_org['PGDATA']}") if !pgdata_dir.nil? && !pgdata_dir.empty? | |
86 | + | |
87 | +force_override_config_srvs['concourse-db']['environment'] = db_envs unless db_envs.empty? | |
88 | +override_config_srvs['concourse-db']['volumes'] = db_vols unless db_vols.empty? | |
89 | + | |
90 | +# Web | |
91 | +web_envs_org = config_srvs['concourse-web']['environment'] | |
92 | +web_envs = {} | |
93 | + | |
94 | +web_ports = config_srvs['concourse-web']['ports'] | |
95 | +override_config_srvs['concourse-web']['ports'] = ['8080:8080'] if web_ports.empty? | |
96 | + | |
97 | +basic_auth_passwd = web_envs_org['CONCOURSE_BASIC_AUTH_PASSWORD'] | |
98 | +if basic_auth_passwd.nil? || basic_auth_passwd.empty? | |
99 | + basic_auth_passwd = SecureRandom.hex # or urlsafe_base64 | |
100 | + web_envs['CONCOURSE_BASIC_AUTH_PASSWORD'] = basic_auth_passwd | |
101 | +end | |
102 | + | |
103 | +external_url = web_envs_org['CONCOURSE_EXTERNAL_URL'] | |
104 | +web_envs['CONCOURSE_EXTERNAL_URL'] = "http://#{node['ipaddress']}:8080" if external_url.nil? | |
105 | + | |
106 | +data_source = web_envs_org['CONCOURSE_POSTGRES_DATA_SOURCE'] | |
107 | +data_source.gsub!(/<POSTGRES_PASSWORD>/, db_passwd) | |
108 | +web_envs['CONCOURSE_POSTGRES_DATA_SOURCE'] = data_source | |
109 | + | |
110 | +force_override_config_srvs['concourse-web']['environment'] = web_envs unless web_envs.empty? | |
111 | + | |
112 | +=begin | |
113 | +if node['concourse-ci']['with_ssl_cert_cookbook'] | |
114 | + ::Chef::Recipe.send(:include, SSLCert::Helper) | |
115 | + cn = node['concourse-ci']['ssl_cert']['common_name'] | |
116 | + key_path = server_key_path(cn) | |
117 | + | |
118 | + bash 'copy_ssl_server_key' do | |
119 | + code <<-EOH | |
120 | + cp #{key_path} #{certs_dir}/server.key | |
121 | + chmod 600 #{certs_dir}/server.key | |
122 | + EOH | |
123 | + sensitive true | |
124 | + action :nothing | |
125 | + subscribes :run, "file[#{key_path}]" | |
126 | + end | |
127 | + | |
128 | + # TODO: key path setup. | |
129 | +end | |
130 | +=end | |
131 | + | |
132 | +template "#{app_dir}/docker-compose.yml" do | |
133 | + source 'opt/docker-compose/app/concourse/docker-compose.yml' | |
134 | + owner 'root' | |
135 | + group 'root' | |
136 | + mode '0600' | |
137 | + sensitive true | |
138 | +end | |
139 | + | |
140 | +log <<-"EOM" | |
141 | +Note: You must execute the following command manually. | |
142 | + See #{doc_url} | |
143 | + - Start: | |
144 | + $ cd #{app_dir} | |
145 | + $ sudo docker-compose up -d | |
146 | + - Stop | |
147 | + $ sudo docker-compose down | |
148 | +EOM |
@@ -0,0 +1,9 @@ | ||
1 | +require_relative '../spec_helper' | |
2 | + | |
3 | +describe 'concourse-ci::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['concourse-ci']['docker-compose']['config'] | |
3 | + | |
4 | +require 'yaml' | |
5 | +yaml_str = config.to_hash.to_yaml | |
6 | +-%> | |
7 | +<%= yaml_str %> |
@@ -0,0 +1,5 @@ | ||
1 | +{ | |
2 | + "run_list": [ | |
3 | + "role[concourse]" | |
4 | + ] | |
5 | +} |
@@ -0,0 +1,49 @@ | ||
1 | +name 'concourse' | |
2 | +description 'Concourse' | |
3 | + | |
4 | +run_list( | |
5 | + #'recipe[ssl_cert::server_key_pairs]', | |
6 | + 'role[docker]', | |
7 | + 'recipe[concourse-ci::docker-compose]', | |
8 | +) | |
9 | + | |
10 | +#env_run_lists() | |
11 | + | |
12 | +#default_attributes() | |
13 | + | |
14 | +image = 'concourse/concourse' # of 'concourse/concourse:2.6.0',... | |
15 | +port = '8080' | |
16 | +concourse_cn = 'concourse.io.example.com' | |
17 | + | |
18 | +override_attributes( | |
19 | + 'concourse-ci' => { | |
20 | + # Not supported yet. | |
21 | + 'with_ssl_cert_cookbook' => false, | |
22 | + 'ssl_cert' => { | |
23 | + 'common_name' => concourse_cn, | |
24 | + }, | |
25 | + 'docker-compose' => { | |
26 | + 'config' => { | |
27 | + # Version 1 docker-compose format | |
28 | + 'concourse-web' => { | |
29 | + 'image' => image, | |
30 | + 'ports' => [ | |
31 | + #"#{port}:8080", # If you sepecify no value, Chef will sets '8080:8080'. | |
32 | + ], | |
33 | + 'environment' => { | |
34 | + # If you sepecify no value, Chef will sets "http://#{node['ipaddress']}:8080". | |
35 | + #'CONCOURSE_EXTERNAL_URL' => "http://192.168.1.3:#{port}", | |
36 | + }, | |
37 | + }, | |
38 | + 'concourse-worker' => { | |
39 | + 'image' => image, | |
40 | + }, | |
41 | + }, | |
42 | + }, | |
43 | + }, | |
44 | + 'ssl_cert' => { | |
45 | + 'common_names' => [ | |
46 | + concourse_cn, | |
47 | + ], | |
48 | + }, | |
49 | +) |