2 # Copyright 2017, whitestar
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 name 'devops-suite-with-ssl-on-docker'
18 description 'DevOps Suite with SSL on Docker'
24 # chef-solo or chef-client local mode
25 if $0.split.include?('chef-solo') || ($0.split.include?('chef-client') && ARGV.include?('-z'))
27 node = Ohai::System.new
30 host_cn = node['fqdn'] if host_cn.nil?
32 host_cn = 'devops.io.example.com' if host_cn.nil?
33 aptly_cn = host_cn # e.g. 'aptly.io.example.com'
34 concourse_cn = host_cn # e.g. 'concourse.io.example.com'
35 concourse_port = '8443'
36 docker_reg_cn = host_cn # e.g. 'registry.docker.example.com'
37 docker_reg_port = '5000'
38 docker_reg_data_vol = '/opt/docker-compose/app/registry/data'
39 gitlab_cn = host_cn # e.g. 'gitlab.io.example.com'
40 gitlab_https_port = '443'
41 gitlab_reg_port = '5050'
42 jenkins_cn = host_cn # e.g. 'jenkins.io.example.com'
44 nexus_cn = host_cn # e.g. 'nexus.io.example.com'
45 dockerd_extra_opts = [
47 '--bip=192.168.100.1/24 --fixed-cidr=192.168.100.0/24',
48 #"--registry-mirror=https://#{docker_reg_cn}:#{docker_reg_port}",
65 ldap_servers = <<-'EOS'
66 main: # 'main' is the GitLab 'provider ID' of this LDAP server
68 host: 'ldap.grid.example.com'
70 uid: 'uid' # 'sAMAccountName'
71 method: 'tls' # "tls" or "ssl" or "plain"
72 #bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
73 #password: '_the_password_of_the_bind_user'
74 active_directory: false
75 allow_username_or_email_login: false
76 block_auto_created_users: false
77 base: 'ou=Users,dc=grid,dc=example,dc=com'
80 username: ['uid', 'userid', 'sAMAccountName']
81 email: ['mail', 'email', 'userPrincipalName']
83 first_name: 'givenName'
90 #secondary: # 'secondary' is the GitLab 'provider ID' of second LDAP server
92 # host: '_your_ldap_server'
94 # uid: 'sAMAccountName'
95 # method: 'plain' # "tls" or "ssl" or "plain"
96 # bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
97 # password: '_the_password_of_the_bind_user'
98 # active_directory: true
99 # allow_username_or_email_login: false
100 # block_auto_created_users: false
104 # username: ['uid', 'userid', 'sAMAccountName']
105 # email: ['mail', 'email', 'userPrincipalName']
107 # first_name: 'givenName'
112 # sync_ssh_keys: false
116 'role[devops-suite-on-docker]',
117 'recipe[docker-grid::registry]',
122 #default_attributes()
129 'common_names' => common_names,
133 'skip_setup' => false,
134 'daemon_extra_options' => dockerd_extra_opts,
137 'skip_setup' => false,
140 'with_ssl_cert_cookbook' => with_ssl,
142 'common_name' => docker_reg_cn,
144 'docker-compose' => {
145 'host_data_volume' => docker_reg_data_vol,
149 "#{docker_reg_port}:5000",
152 #'REGISTRY_AUTH' => 'htpasswd',
153 #'REGISTRY_AUTH_HTPASSWD_PATH' => '/auth/.htpasswd',
154 #'REGISTRY_AUTH_HTPASSWD_REALM' => 'Registry Realm',
156 'REGISTRY_PROXY_REMOTEURL' => 'https://registry-1.docker.io',
167 'with_ssl_cert_cookbook' => with_ssl,
169 'common_name' => aptly_cn,
171 'docker-compose' => {
186 'with_ssl_cert_cookbook' => with_ssl,
191 'common_name' => concourse_cn,
193 'docker-compose' => {
194 'import_ca' => import_ca,
195 # 'web_encryption_key_vault_item' => {
196 # 'vault' => 'concourse',
197 # 'name' => 'web_encryption_key',
198 # 'env_context' => false,
199 # 'key' => 'ekey', # real hash path: "/ekey"
201 # 'web_oauth_client_id_vault_item' => {
202 # 'vault' => 'concourse',
203 # 'name' => 'web_oauth_client_id',
204 # 'env_context' => false,
205 # 'key' => 'cid', # real hash path: "/cid"
207 # 'web_oauth_client_secret_vault_item' => {
208 # 'vault' => 'concourse',
209 # 'name' => 'web_oauth_client_secret',
210 # 'env_context' => false,
211 # 'key' => 'secret', # real hash path: "/secret"
214 # Version 1 docker-compose format
219 "#{concourse_port}:8443",
222 'CONCOURSE_TLS_BIND_PORT' => '8443',
223 'CONCOURSE_EXTERNAL_URL' => "https://#{concourse_cn}:#{concourse_port}",
224 # OAuth for the default `main`` team
225 #'CONCOURSE_GENERIC_OAUTH_DISPLAY_NAME' => 'GitLab',
226 #'CONCOURSE_GENERIC_OAUTH_AUTH_URL' => "https://#{gitlab_cn}/oauth/authorize",
227 #'CONCOURSE_GENERIC_OAUTH_TOKEN_URL' => "https://#{gitlab_cn}/oauth/token",
230 'concourse-worker' => {
238 'with_ssl_cert_cookbook' => with_ssl,
240 'ca_name' => ca_name,
241 'common_name' => gitlab_cn,
243 'reuse_gitlab_common_name' => true,
245 #'reuse_gitlab_common_name' => false,
246 #'common_name' => registry_gitlab_cn,
250 'external_url' => "https://#{gitlab_cn}:#{gitlab_https_port}",
251 'registry_external_url' => "https://#{gitlab_cn}:#{gitlab_reg_port}", # not 5000 if same domain (common name)
253 #'ldap_enabled' => true,
254 #'ldap_servers' => YAML.load(ldap_servers),
257 'redirect_http_to_https' => true,
259 'registry_nginx' => {
260 'redirect_http_to_https' => true,
263 'docker-compose' => {
267 'hostname' => gitlab_cn,
269 "#{gitlab_https_port}:#{gitlab_https_port}",
270 "#{gitlab_reg_port}:#{gitlab_reg_port}",
276 'runner-docker-compose' => {
277 'import_ca' => import_ca,
281 'with_ssl_cert_cookbook' => with_ssl,
283 'common_name' => jenkins_cn,
285 'docker-compose' => {
290 "#{jenkins_port}:8083",
294 '--httpPort=-1 --httpsPort=8083',
295 # These options will be set by the jenkins-grid::docker-compose recipe automatically.
296 #'--httpsCertificate=/var/lib/jenkins/server.crt',
297 #'--httpsPrivateKey=/var/lib/jenkins/server.key',
306 'with_ssl_cert_cookbook' => with_ssl,
308 'common_name' => nexus_cn,
310 'docker-compose' => {