Allow to pass a list of LDAP servers

Change-Id: Ie4fcd0e20132dd040d465199e77668d4b983b3bc
Closes-Bug: #1624002
This commit is contained in:
Guillaume Thouvenin 2016-09-26 15:29:14 +02:00
parent 58ebfac2a4
commit f2a441bf82
2 changed files with 43 additions and 11 deletions

View File

@ -54,6 +54,9 @@ class nagios::cgi (
if empty($ldap_servers) {
fail('ldap_servers list parameter is empty')
}
if ! is_array($ldap_servers) {
fail('ldap_servers list parameter must be an array')
}
if ! $ldap_port { fail('Missing ldap_port parameter')}
if ! $ldap_protocol { fail('Missing ldap_protocol parameter')}
if ! $ldap_bind_dn { fail('Missing ldap_bind_dn parameter')}
@ -68,9 +71,8 @@ class nagios::cgi (
}
$ldap_apache_modules = ['ldap', 'authnz_ldap']
# LDAP url is used in apache::custom_config
$ldap_urls = suffix($ldap_servers, ":${ldap_port}/${ldap_user_search_base_dns}?${ldap_user_attribute}?sub?${ldap_user_search_filter}")
$ldap_url = join($ldap_urls, ' ')
$ldap_servers_url = join(suffix($ldap_servers, ":${ldap_port}"), ' ')
$ldap_url = "${ldap_servers_url}/${ldap_user_search_base_dns}?${ldap_user_attribute}?sub?${ldap_user_search_filter}"
} else {
$ldap_apache_modules = []
}

View File

@ -27,22 +27,52 @@ describe 'nagios::cgi' do
:user => 'nagiosuser',
}
end
it { should contain_class('apache') }
it { should contain_file('/tmp/htpass') }
it { should contain_htpasswd('nagiosuser') }
it { should contain_apache__custom_config('nagios-ui') }
it {
should contain_class('apache')
should contain_file('/tmp/htpass')
should contain_htpasswd('nagiosuser')
should contain_apache__custom_config('nagios-ui')
}
end
describe 'with default' do
let(:params) do
{:vhost_listen_ip => '1.1.1.1',
:wsgi_vhost_listen_ip => '2.2.2.2',
}
end
it { should contain_class('apache') }
it { should contain_apache__custom_config('nagios-ui') }
it { should contain_apache__custom_config('nagios-wsgi') }
it { should contain_file('wsgi_process_service_checks_script') }
it {
should contain_class('apache')
should contain_apache__custom_config('nagios-ui')
should contain_apache__custom_config('nagios-wsgi')
should contain_file('wsgi_process_service_checks_script')
}
end
describe 'with serveral ldap servers' do
let(:params) do
{:vhost_listen_ip => '1.1.1.1',
:wsgi_vhost_listen_ip => '2.2.2.2',
:ldap_enabled => true,
:ldap_protocol => 'ldap',
:ldap_servers => ['ldap.foo1.fr', 'ldap.foo2.fr'],
:ldap_port => 389,
:ldap_bind_dn => 'cn=admin,dc=example,dc=com',
:ldap_bind_password => 'foopass',
:ldap_user_search_base_dns => 'ou=groups,dc=example,dc=com',
:ldap_user_search_filter => '(&(objectClass=posixGroup)(memberUid=%s))',
:ldap_user_attribute => 'uid',
}
end
it {
should contain_class('apache')
should contain_apache__custom_config('nagios-ui').
with_content(/ldap:\/\/ldap.foo1.fr:389 ldap.foo2.fr:389/)
should contain_apache__custom_config('nagios-wsgi')
should contain_file('wsgi_process_service_checks_script')
}
end
describe 'with default httpd_dir' do
let(:params) do
{:vhost_listen_ip => '1.1.1.1',