OSDN Git Service

9264b88cf44258001f830efccbebaadb2e448d93
[metasearch/grid-chef-repo.git] / cookbooks / openldap-grid / recipes / client.rb
1 #
2 # Cookbook Name:: openldap-grid
3 # Recipe:: client
4 #
5 # Copyright 2013-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 ldap_conf_keys = [
21   'URI',
22   'BASE',
23   'BINDDN',
24   'DEREF',
25   'HOST',
26   'NETWORK_TIMEOUT',
27   'PORT',
28   'REFERRALS',
29   'SIZELIMIT',
30   'TIMELIMIT',
31   'TIMEOUT',
32   'SASL_MECH',
33   'SASL_REALM',
34   'SASL_AUTHCID',
35   'SASL_AUTHZID',
36   'SASL_SECPROPS',
37   'GSSAPI_SIGN',
38   'GSSAPI_ENCRYPT',
39   'GSSAPI_ALLOW_REMOTE_PRINCIPAL',
40   'TLS_CACERT',
41   'TLS_CACERTDIR',
42   'TLS_CERT',
43   'TLS_CHECKPEER',
44   'TLS_KEY',
45   'TLS_CIPHER_SUITE',
46   'TLS_RANDFILE',
47   'TLS_REQCERT',
48   'TLS_CRLCHECK',
49   'TLS_CRLFILE',
50 ]
51
52 if node['openldap']['with_ssl_cert_cookbook']
53   ::Chef::Recipe.send(:include, SSLCert::Helper)
54   node.override['openldap']['client']['TLS_CACERT'] \
55     = ca_cert_path(node['openldap']['ssl_cert']['ca_name'])
56 end
57
58 case node['platform_family']
59 when 'debian'
60   pkg = 'ldap-utils'
61   resources(package: pkg) rescue package pkg do
62     action :install
63   end
64
65   template '/etc/ldap/ldap.conf' do
66     source 'etc/ldap/ldap.conf'
67     owner 'root'
68     group 'root'
69     mode '0644'
70     variables ldap_conf_keys: ldap_conf_keys
71   end
72 when 'rhel'
73   pkg = 'openldap-clients'
74   resources(package: pkg) rescue package pkg do
75     action :install
76   end
77
78   template '/etc/openldap/ldap.conf' do
79     source 'etc/openldap/ldap.conf'
80     owner 'root'
81     group 'root'
82     mode '0644'
83     variables ldap_conf_keys: ldap_conf_keys
84   end
85 end