OSDN Git Service

adds the port number to the TSA host setting of the worker service.
[metasearch/grid-chef-repo.git] / cookbooks / concourse-ci / attributes / default.rb
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 default['concourse-ci']['fly']['version'] = '3.3.4'
21 default['concourse-ci']['fly']['release_url'] = "https://github.com/concourse/concourse/releases/download/v#{node['concourse-ci']['fly']['version']}/fly_linux_amd64"
22 default['concourse-ci']['fly']['release_checksum'] = nil
23 default['concourse-ci']['fly']['auto_upgrade'] = false
24 default['concourse-ci']['fly']['install_path'] = '/usr/local/bin/fly'
25
26 default['concourse-ci']['with_ssl_cert_cookbook'] = false
27 # If ['concourse-ci']['with_ssl_cert_cookbook'] is true,
28 # node['concourse-ci']['docker-compose']['config']
29 # are overridden by the following 'common_name' attributes.
30 default['concourse-ci']['ssl_cert']['ca_names'] = []
31 default['concourse-ci']['ssl_cert']['common_name'] = node['fqdn']
32 default['concourse-ci']['docker-image']['entrypoint'] = '/usr/local/bin/dumb-init /usr/local/bin/concourse'
33 default['concourse-ci']['docker-compose']['import_ca'] = false
34 default['concourse-ci']['docker-compose']['app_dir'] = "#{node['docker-grid']['compose']['app_dir']}/concourse"
35 default['concourse-ci']['docker-compose']['pgdata_dir'] = "#{node['concourse-ci']['docker-compose']['app_dir']}/database"
36 default['concourse-ci']['docker-compose']['web_keys_dir'] = "#{node['concourse-ci']['docker-compose']['app_dir']}/keys/web"
37 default['concourse-ci']['docker-compose']['worker_keys_dir'] = "#{node['concourse-ci']['docker-compose']['app_dir']}/keys/worker"
38 default['concourse-ci']['docker-compose']['db_password_reset'] = false
39 default['concourse-ci']['docker-compose']['db_password_vault_item'] = {
40 =begin
41   'vault' => 'concourse',
42   'name' => 'db_password',
43   # single password or nested hash password path delimited by slash
44   'env_context' => false,
45   'key' => 'password',  # real hash path: "/password"
46   # or nested hash password path delimited by slash
47   #'env_context' => true,
48   #'key' => 'hash/path/to/password',  # real hash path: "/#{node.chef_environment}/hash/path/to/password"
49 =end
50 }
51 default['concourse-ci']['docker-compose']['web_encryption_key_vault_item'] = {
52 =begin
53   'vault' => 'concourse',
54   'name' => 'encryption_key',
55   # single password or nested hash password path delimited by slash
56   'env_context' => false,
57   'key' => 'ekey',  # real hash path: "/ekey"
58   # or nested hash password path delimited by slash
59   #'env_context' => true,
60   #'key' => 'hash/path/to/ekey',  # real hash path: "/#{node.chef_environment}/hash/path/to/ekey"
61 =end
62 }
63 default['concourse-ci']['docker-compose']['web_password_reset'] = false
64 default['concourse-ci']['docker-compose']['web_password_vault_item'] = {
65 =begin
66   'vault' => 'concourse',
67   'name' => 'web_password',
68   # single password or nested hash password path delimited by slash
69   'env_context' => false,
70   'key' => 'password',  # real hash path: "/password"
71   # or nested hash password path delimited by slash
72   #'env_context' => true,
73   #'key' => 'hash/path/to/password',  # real hash path: "/#{node.chef_environment}/hash/path/to/password"
74 =end
75 }
76 default['concourse-ci']['docker-compose']['web_oauth_client_id_vault_item'] = {
77 =begin
78   'vault' => 'concourse',
79   'name' => 'web_oauth_client_id',
80   # single cid or nested hash cid path delimited by slash
81   'env_context' => false,
82   'key' => 'cid',  # real hash path: "/cid", Note: do not use `id`, which is preserved by Chef Vault.
83   # or nested hash id path delimited by slash
84   #'env_context' => true,
85   #'key' => 'hash/path/to/cid',  # real hash path: "/#{node.chef_environment}/hash/path/to/cid"
86 =end
87 }
88 default['concourse-ci']['docker-compose']['web_oauth_client_secret_vault_item'] = {
89 =begin
90   'vault' => 'concourse',
91   'name' => 'web_oauth_client_secret',
92   # single secret or nested hash secret path delimited by slash
93   'env_context' => false,
94   'key' => 'secret',  # real hash path: "/secret"
95   # or nested hash secret path delimited by slash
96   #'env_context' => true,
97   #'key' => 'hash/path/to/secret',  # real hash path: "/#{node.chef_environment}/hash/path/to/secret"
98 =end
99 }
100 default['concourse-ci']['docker-compose']['ssh_keys_reset'] = false
101
102 # TODO: support version 2 format, and use `default` instead of `force_override`
103 force_override['concourse-ci']['docker-compose']['config_format_version'] = '1'
104 version_1_config = {
105   'concourse-db' => {
106     'restart' => 'always',
107     'image' => 'postgres:9.5',
108     'volumes' => [
109       #"#{node['concourse-ci']['docker-compose']['pgdata_dir']}:/database",
110     ],
111     'environment' => {
112       'POSTGRES_DB' => 'concourse',
113       'POSTGRES_USER' => 'concourse',
114       # Note: You should use the `['concourse-ci']['docker-compose']['db_password_vault_item']` attribute.
115       'POSTGRES_PASSWORD' => nil,
116       'PGDATA' => '/database',
117     },
118   },
119   'concourse-web' => {
120     'restart' => 'unless-stopped',
121     'image' => 'concourse/concourse',  # latest, 2.6.0,...
122     'links' => [
123       'concourse-db',
124     ],
125     'command' => 'web',
126     'ports' => [
127       #'8080:8080',  # If you sepecify no value, Chef will sets '8080:8080'.
128       #'8443:8443',  # https
129     ],
130     'volumes' => [
131       # These volumes will be set by the concourse-ci::docker-compose recipe automatically.
132       #"#{node['concourse-ci']['docker-compose']['web_keys_dir']}:/concourse-keys",
133     ],
134     'environment' => {
135       #'CONCOURSE_TLS_BIND_PORT' => '8443',  # activate HTTPS
136       # If the ['concourse-ci']['docker-compose']['web_encryption_key_vault_item'] attributes are specified.
137       # the following variable is set automatically,
138       #'CONCOURSE_ENCRYPTION_KEY' => '${CONCOURSE_ENCRYPTION_KEY}',
139       'CONCOURSE_BASIC_AUTH_USERNAME' => 'concourse',
140       # Note: You should use the `['concourse-ci']['docker-compose']['web_password_vault_item']` attribute.
141       'CONCOURSE_BASIC_AUTH_PASSWORD' => nil,
142       # OAuth for the default `main`` team
143       #'CONCOURSE_GENERIC_OAUTH_DISPLAY_NAME' => 'GitLab',
144       # If the ['concourse-ci']['docker-compose']['web_oauth_client_(id|secret)_vault_item'] attributes are specified.
145       # the following 2 variables are set automatically,
146       #'CONCOURSE_GENERIC_OAUTH_CLIENT_ID' => '${CONCOURSE_GENERIC_OAUTH_CLIENT_ID}',
147       #'CONCOURSE_GENERIC_OAUTH_CLIENT_SECRET' => '${CONCOURSE_GENERIC_OAUTH_CLIENT_SECRET}',
148       #'CONCOURSE_GENERIC_OAUTH_AUTH_URL' => 'https://gitlab.io.example.com/oauth/authorize',
149       #'CONCOURSE_GENERIC_OAUTH_TOKEN_URL' => 'https://gitlab.io.example.com/oauth/token',
150       # If you sepecify no value, Chef will sets "http://#{node['ipaddress']}:8080".
151       'CONCOURSE_EXTERNAL_URL' => nil,
152       # `${POSTGRES_PASSWORD}` is a placeholder of password string.
153       'CONCOURSE_POSTGRES_DATA_SOURCE' => \
154         'postgres://concourse:${POSTGRES_PASSWORD}@concourse-db:5432/concourse?sslmode=disable',
155       #'CONCOURSE_RESOURCE_CHECKING_INTERVAL' => '1m',  # default
156     },
157   },
158   'concourse-worker' => {
159     'image' => 'concourse/concourse',
160     'privileged' => true,
161     'links' => [
162       'concourse-web',
163     ],
164     'command' => 'worker',
165     'volumes' => [
166       # These volumes will be set by the concourse-ci::docker-compose recipe automatically.
167       #"#{node['concourse-ci']['docker-compose']['worker_keys_dir']}:/concourse-keys",
168     ],
169     'environment' => {
170       'CONCOURSE_TSA_HOST' => 'concourse-web:2222',
171     },
172   },
173 }
174
175 # Not supported yet.
176 new_config = Marshal.load(Marshal.dump(version_1_config))  # deep copy
177 new_config['concourse-web'].delete('links')
178 new_config['concourse-worker'].delete('links')
179 version_2_config = {
180   # Version 2 docker-compose format
181   'version' => '2',
182   'services' => new_config,
183 }
184 =begin
185 version_2_config = {
186   # Version 2 docker-compose format
187   'version' => '2',
188   'services' => {
189     'concourse-db' => {
190       'restart' => 'always',
191       'image' => 'postgres:9.5',
192       'volumes' => [
193         #"#{node['concourse-ci']['docker-compose']['pgdata_dir']}:/database",
194       ],
195       'environment' => {
196         'POSTGRES_DB' => 'concourse',
197         'POSTGRES_USER' => 'concourse',
198         'POSTGRES_PASSWORD' => nil,
199         'PGDATA' => '/database',
200       },
201     },
202     'concourse-web' => {
203       'restart' => 'always',
204       'image' => 'concourse/concourse',  # latest, 2.6.0,...
205       'command' => 'web',
206       'ports' => [
207         #'8080:8080',
208       ],
209       'volumes' => [
210         "#{node['concourse-ci']['docker-compose']['web_keys_dir']}:/concourse-keys",
211       ],
212       'environment' => {
213         'CONCOURSE_BASIC_AUTH_USERNAME' => 'concourse',
214         'CONCOURSE_BASIC_AUTH_PASSWORD' => nil,
215         'CONCOURSE_EXTERNAL_URL' => nil,
216         'CONCOURSE_POSTGRES_DATA_SOURCE' => \
217           'postgres://concourse:<POSTGRES_PASSWORD>@concourse-db:5432/concourse?sslmode=disable',
218       },
219     },
220     'concourse-worker' => {
221       'restart' => 'always',
222       'image' => 'concourse/concourse',
223       'privileged' => true,
224       'command' => 'worker',
225       'volumes' => [
226         "#{node['concourse-ci']['docker-compose']['worker_keys_dir']}:/concourse-keys",
227       ],
228       'environment' => {
229         'CONCOURSE_TSA_HOST' => 'concourse-web',
230       },
231     },
232   },
233 }
234 =end
235 default['concourse-ci']['docker-compose']['config'] = \
236   node['concourse-ci']['docker-compose']['config_format_version'] == '1' ? version_1_config : version_2_config