OSDN Git Service

00109a4cddbde6009f5f373825c93a0845357ac0
[metasearch/grid-chef-repo.git] / cookbooks / openldap / recipes / server.rb
1 #
2 # Cookbook Name:: openldap
3 # Recipe:: server
4 #
5 # Copyright 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 case node[:platform_family]
21   when 'debian'
22     [
23       'slapd',
24       'ldap-utils',
25       'ssl-cert',
26     ].each {|pkg|
27       resources(:package => pkg) rescue package pkg do
28         action :install
29       end
30     }
31     
32     # for SSL server key access
33     group 'ssl-cert' do
34       action :modify
35       members 'openldap'
36       append true
37     end
38   when 'rhel'
39     [
40       'openldap-servers',
41       'openldap-clients',
42     ].each {|pkg|
43       resources(:package => pkg) rescue package pkg do
44         action :install
45       end
46     }
47
48     # for SSL server key access
49     if node['openldap']['with_ssl_cert_cookbook'] \
50       && node['ssl_cert']['rhel']['key_access_group'] != 'root' then
51       group node['ssl_cert']['rhel']['key_access_group'] do
52         action :modify
53         members 'ldap'
54         append true
55       end
56     end
57 end
58
59 # deploy ldif file for TLS settings.
60 if node['openldap']['with_ssl_cert_cookbook'] then
61   [
62     '00_olc-add-ldaps.ldif',
63     '00_olc-mod-ldaps.ldif',
64   ].each {|ldif|
65     template "/etc/ldap/#{ldif}" do
66       source  "etc/ldap/#{ldif}"
67       owner 'root'
68       group 'root'
69       mode '0644'
70     end
71   }
72 end
73
74 service 'slapd' do
75   #action [:enable, :start]
76   action [:enable]
77   supports :status => true, :restart => true, :reload => false
78 end
79
80 log <<-EOM
81 Note:
82 You must setup OpenLDAP configurations in the first installation:
83   [Debian]
84     $ sudo sudo dpkg-reconfigure -plow slapd
85   [CentOS]
86     edit /etc/openldap/slap.d configurations
87     $ sudo service slapd restart
88 EOM
89