145 lines
3.3 KiB
Puppet
145 lines
3.3 KiB
Puppet
#
|
|
# apacheds
|
|
#
|
|
class plnxtools::apacheds(
|
|
$ads_shutdown_port = 0,
|
|
$appname = "apacheds",
|
|
$ads_instances = "/var/apacheds",
|
|
$ads_logdir = "/var/log/$appname",
|
|
|
|
$java_home = $plnxtools::java_home
|
|
)
|
|
inherits ::plnxtools
|
|
{
|
|
$ads_home = "$opt_dir/$appname"
|
|
|
|
file {"opt_plnx_ads":
|
|
path => "$opt_dir/plnxtools/ads",
|
|
ensure => directory
|
|
}
|
|
|
|
package {"openldap-client":
|
|
ensure => installed
|
|
}
|
|
|
|
plnxtools::install{$appname:
|
|
sourcedir => "https://downloads.apache.org/directory/apacheds/dist/2.0.0.AM26",
|
|
distfile => "apacheds-2.0.0.AM26.tar.gz",
|
|
dirname => "apacheds-2.0.0.AM26",
|
|
require => Class['::plnxtools'],
|
|
}->
|
|
file {"$opt_dir/$appname/bin/setenv.sh":
|
|
ensure => file,
|
|
content => template("plnxtools/apacheds/setenv.sh.erb"),
|
|
}->
|
|
file {"$ads_instances":
|
|
ensure => directory
|
|
}
|
|
file {"$ads_logdir":
|
|
ensure => directory
|
|
}
|
|
}
|
|
|
|
class plnxtools::apacheds::del(
|
|
$ensure = stopped
|
|
)
|
|
inherits plnxtools::apacheds
|
|
{
|
|
$in = $facts['ads_instances']
|
|
$in.each |$x| {
|
|
|
|
if !defined(Plnxtools::Apacheds::Instance[$x]) {
|
|
plnxtools::apacheds::instance{$x:
|
|
partitionid => "$x",
|
|
partitionsuffix => "dc=$x,dc=org",
|
|
ensure => $ensure,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
define plnxtools::apacheds::instance(
|
|
$ensure = running,
|
|
$ldap_port = 10389,
|
|
$ldaps_port = 10638,
|
|
$partitionsuffix,
|
|
$partitionid
|
|
|
|
) {
|
|
$ads_instances = $plnxtools::apacheds::ads_instances
|
|
if $ensure != purged {
|
|
$log_file = "$plnxtools::apacheds::ads_logdir/$title.log"
|
|
|
|
#
|
|
# Create a base 64 encoded ads-contextentry
|
|
# see: https://directory.apache.org/apacheds/basic-ug/1.4.3-adding-partition.html
|
|
#
|
|
$ads_contextentry0 = base64('encode',"dn: $partitionsuffix\ndc: $title\nobjectclass: domain\nobjectclass: top\n\n")
|
|
$ads_contextentry = strip(regsubst($ads_contextentry0, '\n', "\n "))
|
|
|
|
|
|
file{"$ads_instances/$title":
|
|
ensure => directory
|
|
} ->
|
|
file{"$ads_instances/$title/conf":
|
|
ensure => directory
|
|
} ->
|
|
file{"$ads_instances/$title/log":
|
|
ensure => directory
|
|
} ->
|
|
file{"$ads_instances/$title/run":
|
|
ensure => directory
|
|
} ->
|
|
file{"$ads_instances/$title/conf/log4j.properties":
|
|
ensure => file,
|
|
content => template ("plnxtools/apacheds/log4j.properties.erb"),
|
|
}->
|
|
file{"/tmp/ads-$title-config.ldif":
|
|
ensure => file,
|
|
content => template ("plnxtools/apacheds/config.ldif.erb"),
|
|
}->
|
|
exec {"/bin/cp /tmp/ads-$title-config.ldif $ads_instances/$title/conf/config.ldif":
|
|
creates => "$ads_instances/$title/conf/config.ldif_migrated"
|
|
}
|
|
|
|
|
|
$bin_dir = "${plnxtools::apacheds::opt_dir}/${plnxtools::apacheds::appname}/bin"
|
|
|
|
file {"/opt/plnxtools/ads/$title":
|
|
ensure => file
|
|
}->
|
|
service {"apacheds_${title}":
|
|
start => "$bin_dir/apacheds.sh $title start",
|
|
stop => "$bin_dir/apacheds.sh $title stop",
|
|
status => "$bin_dir/apacheds.sh $title status | grep 'is running'",
|
|
ensure => $ensure,
|
|
}
|
|
}
|
|
else{
|
|
service {"apacheds_${title}":
|
|
start => "$bin_dir/apacheds.sh $title start",
|
|
stop => "$bin_dir/apacheds.sh $title stop",
|
|
status => "$bin_dir/apacheds.sh $title status | grep 'is running'",
|
|
ensure => stopped,
|
|
} ->
|
|
file {"/opt/plnxtools/ads/$title":
|
|
ensure => absent
|
|
} ->
|
|
file{"$ads_instances/$title":
|
|
ensure => absent,
|
|
force => true
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
define plnxtools::apacheds::syncrepl(
|
|
$parition,
|
|
$consumer_id,
|
|
)
|
|
{
|
|
|
|
}
|
|
|