OTWO-1213 Works around lost encoding in Ruby/C binding layer
[ohcount] / test / src_dir / puppet1.pp
1 class bob_openldap {
2
3         define server (
4                 $argsfile = undef,
5                 $bdb_cachesize = '',
6                 $bdb_checkpoint = '',
7                 $bdb_directory = undef,
8                 $bdb_idlcachesize = '',
9                 $bdb_rootdn,
10                 $bdb_rootpw,
11                 $bdb_shm_key = '',
12                 $bdb_suffix,
13                 $conf_path = undef,
14                 $conf_dir = undef,
15                 $enable = false,
16                 $include = [],
17                 $includepath = undef,
18                 $modulepath = '',
19                 $modules = [], 
20                 $package = undef,
21                 $pidfile = undef,
22                 $sysconf_path = undef
23                 ) {
24         
25                 $resource_name = "bob_openldap_server"
26         
27                 if($name != "params") {
28                         fail("${resource_name}: This function is a singleton. Make sure the resource name is 'params'.")
29                 }
30         
31                 case $operatingsystem {
32                         Fedora: {
33                                 case $operatingsystemrelease {
34                                         /^(12|13)$/: {
35                                                 if(!$argsfile) { $_argsfile = "/var/run/openldap/slapd.args" }
36                                                 if(!$bdb_directory) { $_bdb_directory = "/var/lib/ldap" }
37                                                 if(!$conf_path) { $_conf_path = "/etc/openldap/slapd.conf" }
38                                                 if(!$conf_dir) { $_conf_dir = "/etc/openldap/slapd.d" }
39                                                 if(!$package) { $_package = ["openldap-servers"] }
40                                                 if(!$pidfile) { $_pidfile = "/var/run/openldap/slapd.pid" }
41                                                 if(!$service) { $_service = "slapd" }
42                                                 if(!$sysconf_path) { $_sysconf_path = "/etc/sysconfig/ldap" }
43                                         }
44                                 }
45                         }
46                 }
47         
48                 # Presume the OS did not match and because these args are necessary, just 
49                 # bail with an error.
50                 if(!($_argsfile and $_bdb_directory and $_pidfile and $_conf_path and 
51                                  $_package and $_service and $_sysconf_path and $_conf_dir)) { 
52                         fail("${resource_name}: Unsupported operating system: ${operatingsystem} version ${operatingsystemrelease} and you have not setup the args for: argsfile, bdb_directory, conf_dir, conf_path, package, pidfile, sysconf_path and service.")
53                 }
54         
55                 # Fix paths - add forward slashes at the end of strings without them
56                 $_includepath = regsubst($includepath, '([^/])$', '\1/')
57                 $_dbconf_path = "${_bdb_directory}/DB_CONFIG"
58         
59                 # ...
60                 file {
61                         $_conf_path:
62                                 content => template("bob_openldap/slapd.conf"),
63                                 require => Package[$_package],
64                                 owner => "ldap",
65                                 group => "root",
66                                 mode => "0440",
67                                 notify => Service[$_service];
68                         $_sysconf_path:
69                                 content => template("bob_openldap/ldap.sysconf"),
70                                 require => Package[$_package],
71                                 owner => "root",
72                                 group => "root",
73                                 mode => "0644";
74                         $_conf_dir:
75                                 force => true,
76                                 ensure => absent,
77                                 before => Service[$_service];
78                         $_dbconf_path:
79                                 content => "",
80                                 notify => Service[$_service];
81                 }
82                 package {
83                         $_package:
84                                 ensure => installed;
85                 }
86                 service {
87                         $_service:
88                                 ensure => $enable ? {
89                                         true => "running",
90                                         false => "stopped"
91                                 },
92                                 enable => $enable,
93                                 hasstatus => true,
94                                 require => [ Package[$_package], File[$_conf_path] ];
95                 }
96         }
97         
98         define client (
99                 $base,
100                 $network_timeout = '',
101                 $path = undef,
102                 $timeout = '',
103                 $binddn = '',
104                 $tls_cacertdir = undef,
105                 $uri
106                 ) {
107         
108                 $resource_name = "bob_openldap_client"
109         
110                 if($name != "params") {
111                         fail("${resource_name}: This function is a singleton. Make sure the resource name is 'params'.")
112                 }
113         
114                 case $operatingsystem {
115                         Fedora: {
116                                 case $operatingsystemrelease {
117                                         /^(12|13)$/: {
118                                                 if(!$tls_cacertdir) { $_tls_cacertdir = "/etc/openldap/cacerts" }
119                                                 if(!$path) { $_path = "/etc/openldap/ldap.conf" }
120                                         }
121                                 }
122                         }
123                 }
124         
125                 # Presume the OS did not match and because these args are necessary, just 
126                 # bail with an error.
127                 if(!($_tls_cacertdir and $_path)) { 
128                         fail("${resource_name}: Unsupported operating system: ${operatingsystem} version ${operatingsystemrelease} and you have not setup the args for: tls_cacertdir, path.")
129                 }
130         
131                 # Fix some vars, ready for templating
132                 $_base = $base
133                 $_binddn = $binddn
134                 $_network_timeout = $network_timeout
135                 $_timeout = $timeout
136                 $_uri = $uri
137         
138                 file {
139                         $_path:
140                                 content => template("bob_openldap/ldap.conf")
141                 }
142         
143         }
144
145 }