Skip to content

Commit

Permalink
Add option to use kafka instead of dds
Browse files Browse the repository at this point in the history
New class parameters:
dds, kafka (boolean switches)
kafka_broker_address, kafka_registry_url, kafka_sasl_password,
kafka_sasl_username, kafka_templates_directory (strings with kafka values)

(rpms) nothing to install when not using dds.
(services) no opensplice when not using dds.
(etc) add kafka setup file when relevant, skip dds when not.
Add kafka lines to .app files when relevant.
  • Loading branch information
glennmorris committed Mar 6, 2024
1 parent 6c9d57b commit 8f46c31
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 26 deletions.
79 changes: 55 additions & 24 deletions manifests/etc.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Configure /etc for CCS/SAL
#
class ccs_sal::etc {
$dds = $ccs_sal::dds
$kafka = $ccs_sal::kafka

$dir = '/etc/ccs'

$attributes = {
Expand All @@ -13,24 +16,50 @@
$ptitle = regsubst($title, '::.*', '', 'G')

$salfile = 'setup-sal5'
$kafka_salfile = 'setup-sal-kafka'

file { "${dir}/${salfile}":
ensure => file,
content => epp("${ptitle}/${salfile}.epp", {
'domain' => $ccs_sal::dds_domain,
'interface' => $ccs_sal::dds_interface,
'home' => $ccs_sal::ospl_home,
},
),
* => $attributes,
if $kafka {
$prefile = $kafka_salfile
$implementation = 'system.property.org.lsst.sal.implementation=kafka\n'
} else {
$prefile = $salfile
$implementation = ''
}

['ospl-shmem.xml', 'QoS.xml'].each|$thing| {
$file = "${dir}/${thing}"
file { $file:
ensure => file,
source => "puppet:///modules/${ptitle}/${thing}",
* => $attributes,
if $kafka {
file { "${dir}/${kafka_salfile}":
ensure => file,
content => epp("${ptitle}/${kafka_salfile}.epp", {
'templates_directory' => $ccs_sal::kafka_templates_directory,
'broker_address' => $ccs_sal::kafka_broker_address,
'sasl_username' => $ccs_sal::kafka_sasl_username,
'sasl_password' => $ccs_sal::kafka_sasl_password,
'registry_url' => $ccs_sal::kafka_registry_url,
},
),
* => $attributes,
}
}

if $dds {
file { "${dir}/${salfile}":
ensure => file,
content => epp("${ptitle}/${salfile}.epp", {
'domain' => $ccs_sal::dds_domain,
'interface' => $ccs_sal::dds_interface,
'home' => $ccs_sal::ospl_home,
},
),
* => $attributes,
}

['ospl-shmem.xml', 'QoS.xml'].each|$thing| {
$file = "${dir}/${thing}"
file { $file:
ensure => file,
source => "puppet:///modules/${ptitle}/${thing}",
* => $attributes,
}
}
}

Expand All @@ -39,20 +68,22 @@
$file = "${dir}/${instrument}-ocs-${thing}.app"
file { $file:
ensure => file,
content => "system.pre-execute=${salfile}\n",
content => "${implementation}system.pre-execute=${prefile}\n",
* => $attributes,
}
}
# lint:endignore

## Stop tmpfiles.d removing opensplice sockets.
$tmpfiles_conf = 'ccs-ospl.conf'
if $dds {
## Stop tmpfiles.d removing opensplice sockets.
$tmpfiles_conf = 'ccs-ospl.conf'

file { "/etc/tmpfiles.d/${tmpfiles_conf}":
ensure => file,
source => "puppet:///modules/${ptitle}/${tmpfiles_conf}",
owner => 'root',
group => 'root',
mode => '0644',
file { "/etc/tmpfiles.d/${tmpfiles_conf}":
ensure => file,
source => "puppet:///modules/${ptitle}/${tmpfiles_conf}",
owner => 'root',
group => 'root',
mode => '0644',
}
}
}
25 changes: 24 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,26 @@
# "ts_sal_utils" => "ts_sal_utils-4.0.0-1.x86_64.rpm"
# @param ospl_home
# String giving OSPL_HOME.
# @param dds
# Boolean; if true install DDS support
# @param dds_domain
# String giving LSST_DDS_DOMAIN (eg base)
# @param dds_interface
# String giving name of SAL interface (eg somehost-dds)
# @param instrument
# String giving instrument (eg comcam).
# @param kafka
# Boolean; if true install Kafka support
# @param kafka_broker_address
# String giving broker address
# @param kafka_registry_url
# String giving registry URL
# @param kafka_sasl_username
# String giving SASL username
# @param kafka_sasl_password
# String giving SASL password
# @param kafka_templates_directory
# String giving location of templates directory
# @param prefix_service
# Boolean; if false do not prefix systemctl services with the instrument.
# @param rpm_repo
Expand All @@ -29,9 +43,16 @@
Hash[String,String,1] $rpms,
## Change the following in hiera, not here.
String $ospl_home = '/opt/OpenSpliceDDS/VX.Y.Z/example/example',
Boolean $dds = true,
String $dds_domain = 'summit',
String $dds_interface = 'localhost-dds',
String $instrument = 'comcam',
Boolean $kafka = false,
String $kafka_broker_address = 'sasquatch-tts-kafka-bootstrap.lsst.codes:9094',
String $kafka_registry_url = 'https://tucson-teststand.lsst.codes/schema-registry',
String $kafka_sasl_password = 'password',
String $kafka_sasl_username = 'username',
String $kafka_templates_directory = '/home/tonyj/avro-templates', # FIXME
Boolean $prefix_service = true,
## Old: http://www.slac.stanford.edu/~gmorris/lsst/pkgarchive
String $rpm_repo = 'https://repo-nexus.lsst.org/nexus/repository/ts_yum/releases',
Expand All @@ -43,7 +64,9 @@
Optional[String] $rpm_user = undef,
Optional[String] $rpm_pass = undef,
) {
include ccs_sal::rpms
if $dds {
include ccs_sal::rpms
}
include ccs_sal::etc
include ccs_sal::service
}
8 changes: 7 additions & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Manage systemd service files for CCS/SAL
#
class ccs_sal::service {
$dds = $ccs_sal::dds

$common_vars = {
user => 'ccs',
group => 'ccs',
Expand Down Expand Up @@ -49,7 +51,11 @@
}

## FIXME ccs_software module can also manage basic services.
$services = [$opensplice, $ocs_bridge, $mcm]
if $dds {
$services = [$opensplice, $ocs_bridge, $mcm]
} else {
$services = [$ocs_bridge, $mcm]
}

$services.each | $hash | {
$service = $hash['service']
Expand Down
14 changes: 14 additions & 0 deletions templates/setup-sal-kafka.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%- | String $templates_directory,
String $broker_address,
String $sasl_username,
String $sasl_password,
String $registry_url,
| -%>
# This file is managed by Puppet; changes may be overwritten.
export LSST_AVRO_TEMPLATES=<%= $templates_directory %>
export LSST_KAFKA_BROKER_ADDR=<%= $broker_address %>
export LSST_SECURITY_PROTOCOL=SASL_SSL
export LSST_SASL_USERNAME=<%= $sasl_username %>
export LSST_SASL_PASSWORD="<%= $sasl_password %>"
export LSST_TOPIC_SUBNAME=sal
export LSST_SCHEMA_REGISTRY_URL=<%= $registry_url %>

0 comments on commit 8f46c31

Please sign in to comment.