Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ For more details on configuration, please refer to the [ProSA configuration guid
class { 'prosa':
bin_repo => 'https://user:password@binary.repo.com/repository/prosa-1.0.0.bin',
telemetry_level => 'info',
telemetry_attributes => {
'service.name' => "prosa-servicename",
},
observability => {
'metrics' => {
'otlp' => {
Expand Down
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The following parameters are available in the `prosa` class:
* [`service_name`](#-prosa--service_name)
* [`bin_repo`](#-prosa--bin_repo)
* [`bin_path`](#-prosa--bin_path)
* [`monitor_path`](#-prosa--monitor_path)
* [`log_dir`](#-prosa--log_dir)
* [`conf_dir`](#-prosa--conf_dir)
* [`service_enable`](#-prosa--service_enable)
Expand Down Expand Up @@ -130,6 +131,14 @@ Sets the path where the ProSA binary will be located.

Default value: `$prosa::params::bin_path`

##### <a name="-prosa--monitor_path"></a>`monitor_path`

Data type: `Stdlib::Absolutepath`

Sets the path where the ProSA monitoring script will be located.

Default value: `$prosa::params::monitor_path`

##### <a name="-prosa--log_dir"></a>`log_dir`

Data type: `Stdlib::Absolutepath`
Expand Down
33 changes: 33 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
# @param bin_path
# Sets the path where the ProSA binary will be located.
#
# @param monitor_path
# Sets the path where the ProSA monitoring script will be located.
#
# @param log_dir
# Sets the directory where the ProSA logs files are located.
#
Expand Down Expand Up @@ -112,6 +115,7 @@
String $service_name = $prosa::params::service_name,
Optional[String] $bin_repo = undef,
Stdlib::Absolutepath $bin_path = $prosa::params::bin_path,
Stdlib::Absolutepath $monitor_path = $prosa::params::monitor_path,
Stdlib::Absolutepath $log_dir = '/var/log',
Stdlib::Absolutepath $conf_dir = $prosa::params::conf_dir,
Boolean $service_enable = true,
Expand Down Expand Up @@ -164,6 +168,35 @@
notify => Class['prosa::service'],
}

# Create a ProSA monitoring script only if Prometheus is locally configure
if (
'metrics' in $observability
and 'prometheus' in $observability['metrics']
and 'endpoint' in $observability['metrics']['prometheus']
) {
$prometheus_endpoint = $observability['metrics']['prometheus']['endpoint']
$prometheus_port_string = $prometheus_endpoint ? {
/^[0-9]+$/ => $prometheus_endpoint,
/:([0-9]+)$/ => regsubst($prometheus_endpoint, '^.*:([0-9]+)$', '\1'),
default => fail("Invalid ProSA Prometheus endpoint '${prometheus_endpoint}': expected a port or address ending with :port"),
}
$prometheus_port = Integer($prometheus_port_string)

if $prometheus_port < 1 or $prometheus_port > 65535 {
fail("Invalid ProSA Prometheus port '${prometheus_port}' extracted from endpoint '${prometheus_endpoint}'")
}

file { $monitor_path:
ensure => file,
owner => 'root',
group => $prosa::params::root_group,
mode => '0755',
content => epp('prosa/prosa-monitor.py.epp', {
'metrics_url' => "http://127.0.0.1:${prometheus_port}/metrics",
}),
}
}

# Download ProSA binary from an external binary repository
if $bin_repo {
file { $bin_path:
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$prosa_name = regsubst("prosa-${servername}", '[ \t.:/]+', '_', 'G')
$service_name = 'prosa'
$bin_path = '/usr/local/bin/prosa'
$monitor_path = '/usr/local/bin/prosa-monitor'
$conf_dir = '/etc/prosa'
$user = 'prosa'
$group = 'prosa'
Expand Down
8 changes: 5 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "worldline-prosa",
"version": "0.1.5",
"version": "0.1.6",
"author": "Worldline",
"summary": "Installs, configures, and manages ProSA.",
"license": "LGPL-3.0",
Expand All @@ -18,7 +18,8 @@
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"8",
"9"
"9",
"10"
]
},
{
Expand All @@ -33,7 +34,8 @@
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"22.04",
"24.04"
"24.04",
"26.04"
]
}
],
Expand Down
73 changes: 73 additions & 0 deletions spec/classes/prosa_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,79 @@
let(:facts) { os_facts }

it { is_expected.to compile.with_all_deps }

it { is_expected.not_to contain_file('/usr/local/bin/prosa-monitor') }

context 'with Prometheus metrics enabled' do
let(:params) do
{
observability: {
'metrics' => {
'prometheus' => {
'endpoint' => '0.0.0.0:19090',
},
},
'traces' => {
'stdout' => {
'level' => 'info',
},
},
'logs' => {
'stdout' => {
'level' => 'info',
},
},
},
}
end

it do
is_expected.to contain_file('/usr/local/bin/prosa-monitor')
.with(
ensure: 'file',
owner: 'root',
group: 'root',
mode: '0755',
)
.with_content(%r{DEFAULT_METRICS_URL = "http://127\.0\.0\.1:19090/metrics"})
end
end

context 'with Prometheus metrics enabled and a custom monitor path' do
let(:params) do
{
monitor_path: '/usr/local/bin/prosa-monitor-instance-a',
observability: {
'metrics' => {
'prometheus' => {
'endpoint' => '19091',
},
},
'traces' => {
'stdout' => {
'level' => 'info',
},
},
'logs' => {
'stdout' => {
'level' => 'info',
},
},
},
}
end

it do
is_expected.to contain_file('/usr/local/bin/prosa-monitor-instance-a')
.with(
ensure: 'file',
owner: 'root',
group: 'root',
mode: '0755',
)
.with_content(%r{DEFAULT_METRICS_URL = "http://127\.0\.0\.1:19091/metrics"})
end
end
end
end
end
Loading
Loading