Skip to content

Commit

Permalink
Merge pull request #32 from lsst-it/IT-5146/kafka
Browse files Browse the repository at this point in the history
Add option to use kafka instead of dds
  • Loading branch information
glennmorris authored Mar 6, 2024
2 parents 6c9d57b + 2da4bcd commit 4f89220
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 26 deletions.
64 changes: 64 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@ The following parameters are available in the `ccs_sal` class:

* [`rpms`](#-ccs_sal--rpms)
* [`ospl_home`](#-ccs_sal--ospl_home)
* [`dds`](#-ccs_sal--dds)
* [`dds_domain`](#-ccs_sal--dds_domain)
* [`dds_interface`](#-ccs_sal--dds_interface)
* [`instrument`](#-ccs_sal--instrument)
* [`kafka`](#-ccs_sal--kafka)
* [`kafka_broker_address`](#-ccs_sal--kafka_broker_address)
* [`kafka_registry_url`](#-ccs_sal--kafka_registry_url)
* [`kafka_sasl_username`](#-ccs_sal--kafka_sasl_username)
* [`kafka_sasl_password`](#-ccs_sal--kafka_sasl_password)
* [`kafka_templates_directory`](#-ccs_sal--kafka_templates_directory)
* [`prefix_service`](#-ccs_sal--prefix_service)
* [`rpm_repo`](#-ccs_sal--rpm_repo)
* [`rpms_private`](#-ccs_sal--rpms_private)
Expand All @@ -48,6 +55,14 @@ String giving OSPL_HOME.

Default value: `'/opt/OpenSpliceDDS/VX.Y.Z/example/example'`

##### <a name="-ccs_sal--dds"></a>`dds`

Data type: `Boolean`

Boolean; if true install DDS support

Default value: `true`

##### <a name="-ccs_sal--dds_domain"></a>`dds_domain`

Data type: `String`
Expand All @@ -72,6 +87,55 @@ String giving instrument (eg comcam).

Default value: `'comcam'`

##### <a name="-ccs_sal--kafka"></a>`kafka`

Data type: `Boolean`

Boolean; if true install Kafka support
kafka will be used.

Default value: `false`

##### <a name="-ccs_sal--kafka_broker_address"></a>`kafka_broker_address`

Data type: `String`

String giving broker address

Default value: `'sasquatch-tts-kafka-bootstrap.lsst.codes:9094'`

##### <a name="-ccs_sal--kafka_registry_url"></a>`kafka_registry_url`

Data type: `String`

String giving registry URL

Default value: `'https://tucson-teststand.lsst.codes/schema-registry'`

##### <a name="-ccs_sal--kafka_sasl_username"></a>`kafka_sasl_username`

Data type: `String`

String giving SASL username

Default value: `'username'`

##### <a name="-ccs_sal--kafka_sasl_password"></a>`kafka_sasl_password`

Data type: `String`

String giving SASL password

Default value: `'password'`

##### <a name="-ccs_sal--kafka_templates_directory"></a>`kafka_templates_directory`

Data type: `String`

String giving location of templates directory

Default value: `'/home/tonyj/avro-templates'`

##### <a name="-ccs_sal--prefix_service"></a>`prefix_service`

Data type: `Boolean`
Expand Down
7 changes: 7 additions & 0 deletions files/setup-sal
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- mode: sh; -*-
# This file is managed by Puppet; changes may be overwritten.
if [ -z "${LSST_USE_KAFKA}" ]; then
source /etc/ccs/setup-sal5
else
source /etc/ccs/setup-kafka
fi
88 changes: 64 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,55 @@
$ptitle = regsubst($title, '::.*', '', 'G')

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

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,
file { "${dir}/${prefile}":
ensure => file,
source => "puppet:///modules/${ptitle}/${prefile}",
* => $attributes,
}

['ospl-shmem.xml', 'QoS.xml'].each|$thing| {
$file = "${dir}/${thing}"
file { $file:
ensure => file,
source => "puppet:///modules/${ptitle}/${thing}",
* => $attributes,
if $kafka {
$implementation = 'system.property.org.lsst.sal.implementation=kafka'
} else {
$implementation = undef
}

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 +73,26 @@
$file = "${dir}/${instrument}-ocs-${thing}.app"
file { $file:
ensure => file,
content => "system.pre-execute=${salfile}\n",
content => epp("${ptitle}/ocs-app.epp", {
'prefile' => $prefile,
'extra' => $implementation,
},
),
* => $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',
}
}
}
26 changes: 25 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,27 @@
# "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
# kafka will be used.
# @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 +44,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 +65,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
5 changes: 5 additions & 0 deletions templates/ocs-app.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<%- | String $prefile, Optional[String] $extra = undef | -%>
system.pre-execute=<%= $prefile %>
<% unless $extra =~ Undef { -%>
<%= $extra %>
<% } -%>
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 4f89220

Please sign in to comment.