OSDN Git Service

fix service control.
[metasearch/grid-chef-repo.git] / roles / docker-registry.rb
1 #
2 # Copyright 2016-2017, 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 name 'docker-registry'
18 description 'Docker Registry'
19
20 run_list(
21   'recipe[ssl_cert::ca_certs]',
22   'recipe[ssl_cert::server_key_pairs]',
23   'role[docker]',
24   'recipe[docker-grid::registry]',
25 )
26
27 #env_run_lists()
28
29 #default_attributes()
30
31 ca_name = 'grid_ca'
32 registry_cn = 'registry.docker.example.com'
33
34 override_attributes(
35   'ssl_cert' => {
36     'ca_names' => [
37       ca_name,
38     ],
39     'common_names' => [
40       registry_cn,
41     ],
42   },
43   'docker-grid' => {
44     'engine' => {
45       'skip_setup' => false,
46     },
47     'compose' => {
48       'skip_setup' => false,
49     },
50     'registry' => {
51       'with_ssl_cert_cookbook' => true,
52       'ssl_cert' => {
53         'common_name' => registry_cn,
54       },
55       'docker-compose' => {
56         'config' => {
57           'registry' => {
58             'restart' => 'always',
59             'image' => 'registry:2',
60             'ports' => [
61               '5000:5000',
62             ],
63             'environment' => {
64               # These environment variables will be set by the docker-grid::registry recipe automatically.
65               #'REGISTRY_HTTP_TLS_CERTIFICATE' => '/certs/domain.crt',
66               #'REGISTRY_HTTP_TLS_KEY' =>         '/certs/domain.key',
67               'REGISTRY_AUTH' =>                'htpasswd',
68               'REGISTRY_AUTH_HTPASSWD_PATH' =>  '/auth/.htpasswd',
69               'REGISTRY_AUTH_HTPASSWD_REALM' => 'Registry Realm',
70             },
71             'volumes' => [
72               # These volumes will be set by the docker-grid::registry recipe automatically.
73               #"#{server_cert_path(node['docker-grid']['registry']['ssl_cert']['common_name'])}:/certs/domain.crt:ro",
74               #"#{server_key_path(node['docker-grid']['registry']['ssl_cert']['common_name'])}:/certs/domain.key:ro",
75               './auth:/auth',
76             ],
77           },
78         },
79       },
80     },
81   },
82 )
83