2 # Cookbook Name:: openldap-grid
5 # Copyright 2013-2016, whitestar
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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.
43 'reconnect_sleeptime',
44 'reconnect_retrytime',
54 'nss_initgroups_ignoreusers',
58 tls_cacertfile = node['openldap']['nss-ldapd']['tls_cacertfile']
59 if node['openldap']['with_ssl_cert_cookbook'] \
60 && (tls_cacertfile.nil? || tls_cacertfile.empty?)
61 ::Chef::Recipe.send(:include, SSLCert::Helper)
62 node.force_override['openldap']['nss-ldapd']['tls_cacertfile'] \
63 = ca_cert_path(node['openldap']['ssl_cert']['ca_name'])
66 case node['platform_family']
79 supports status: true, restart: true, reload: false
82 resources(service: 'nscd') rescue service 'nscd' do
84 supports status: true, restart: true, reload: false
87 template '/etc/nslcd.conf' do
88 source 'etc/nslcd.conf'
92 variables nslcd_conf_keys: nslcd_conf_keys
93 notifies :restart, 'service[nslcd]'
94 notifies :restart, 'service[nscd]'
97 package 'nss-pam-ldapd' do
103 supports status: true, restart: true, reload: true
106 resources(service: 'nscd') rescue service 'nscd' do
108 supports status: true, restart: true, reload: true
111 template '/etc/nslcd.conf' do
112 source 'etc/nslcd.conf'
116 variables nslcd_conf_keys: nslcd_conf_keys
117 notifies :restart, 'service[nslcd]'
118 notifies :restart, 'service[nscd]'
122 ruby_block 'configuring_nameservices' do
124 conf_file = '/etc/nsswitch.conf'
125 nameservices = node['openldap']['ldap_lookup_nameservices']
126 if !nameservices.nil? && !nameservices.empty?
127 open(conf_file, 'r+') {|file|
128 file.flock(File::LOCK_EX)
132 if line =~ /^(\w+):\s+(.*)$/ \
133 && nameservices.include?($1) && !$2.include?('ldap')
134 line.chomp! << " ldap\n"
140 print "\nnew #{conf_file}: [#{buf}]"
143 file.truncate(file.tell)
149 notifies :restart, 'service[nscd]'