feat: add exportarr (#365)

- add exporters::exportarr
- deploy for radarr, sonarr and prowlarr

Reviewed-on: #365
This commit was merged in pull request #365.
This commit is contained in:
2025-07-27 19:47:26 +10:00
parent fd902c1437
commit 7fbb87b4b6
6 changed files with 120 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
class exporters::exportarr (
String $app,
String $api_key,
Boolean $backfill = false, # only for prowlarr
Boolean $extra_metrics = false,
Boolean $enable = false,
String $user = 'exportarr',
String $group = 'exportarr',
Boolean $manage_user = true,
Boolean $manage_service = true,
Stdlib::Port $port = 9707,
Stdlib::HTTPUrl $url = 'http://127.0.0.1:8000',
Stdlib::Absolutepath $exec_path = '/usr/bin/exportarr',
Stdlib::Absolutepath $config_file = "/opt/${app}/config.xml",
){
if $enable {
# install required package
package {'exportarr':
ensure => installed,
}
# manage the user/group
if $manage_user {
group { $group:
ensure => present,
}
user { $user:
ensure => present,
shell => '/usr/sbin/nologin',
groups => $group,
managehome => true,
}
}
# manage the systemd service
if $manage_service {
# Use these in notifications or file resources
systemd::unit_file { 'exportarr.service':
content => template('exporters/exportarr.service.erb'),
enable => true,
active => true,
subscribe => Package['exportarr'],
}
}
# manage consul service
consul::service { 'exportarr':
service_name => 'exportarr',
address => $facts['networking']['ip'],
port => $port,
tags => [
'metrics',
'metrics_scheme=http',
'metrics_job=exportarr',
],
checks => [
{
id => 'exportarr_http_check',
name => 'exportarr HTTP Check',
http => "http://${facts['networking']['fqdn']}:${port}",
method => 'GET',
tls_skip_verify => true,
interval => '10s',
timeout => '1s',
},
],
}
}
}
@@ -0,0 +1,16 @@
[Unit]
Description=Prometheus exportarr
Wants=network-online.target
After=network-online.target
[Service]
User=<%= @user %>
Group=<%= @group %>
EnvironmentFile=<%= @vars_file %>
ExecStart=<%= @exec_path %> <%= @app %> --port <%= @port %> --url <%= @url %> --api-key <%= @api_key %> --config <%= @config_file %> --enable-additional-metrics <%= @extra_metrics %><% if @app == 'prowlarr' %> --backfill <%= @backfill %><% end %>
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,4 @@
# THIS FILE IS MANAGED BY PUPPET
<% @options.each do |key, value| -%>
<%= key %>=<%= value %>
<% end -%>