feat: add lidarr module
This commit is contained in:
parent
d98b12bf81
commit
bbf9944ef5
27
modules/lidarr/manifests/config.pp
Normal file
27
modules/lidarr/manifests/config.pp
Normal file
@ -0,0 +1,27 @@
|
||||
class lidarr::config (
|
||||
$user = $lidarr::params::user,
|
||||
$group = $lidarr::params::group,
|
||||
$base_path = $lidarr::params::base_path,
|
||||
$bind_address = $lidarr::bind_address,
|
||||
$port = $lidarr::port,
|
||||
$ssl_port = $lidarr::ssl_port,
|
||||
$enable_ssl = $lidarr::enable_ssl,
|
||||
$launch_browser = $lidarr::launch_browser,
|
||||
$api_key = $lidarr::api_key,
|
||||
$authentication_method = $lidarr::authentication_method,
|
||||
$authentication_required = $lidarr::authentication_required,
|
||||
$branch = $lidarr::branch,
|
||||
$log_level = $lidarr::log_level,
|
||||
$ssl_cert_path = $lidarr::ssl_cert_path,
|
||||
$ssl_cert_password = $lidarr::ssl_cert_password,
|
||||
$url_base = $lidarr::url_base,
|
||||
$instance_name = $lidarr::instance_name,
|
||||
) {
|
||||
file { "${base_path}/config.xml":
|
||||
ensure => file,
|
||||
content => template('lidarr/lidarr_config.xml.erb'),
|
||||
owner => $user,
|
||||
group => $group,
|
||||
mode => '0644',
|
||||
}
|
||||
}
|
||||
36
modules/lidarr/manifests/init.pp
Normal file
36
modules/lidarr/manifests/init.pp
Normal file
@ -0,0 +1,36 @@
|
||||
# manage lidarr
|
||||
class lidarr (
|
||||
$packages = $lidarr::params::packages,
|
||||
$user = $lidarr::params::user,
|
||||
$group = $lidarr::params::group,
|
||||
$base_path = $lidarr::params::base_path,
|
||||
$install_path = $lidarr::params::install_path,
|
||||
$config_folder = $lidarr::params::config_folder,
|
||||
$app_folder = $lidarr::params::app_folder,
|
||||
$archive_name = $lidarr::params::archive_name,
|
||||
$archive_url = $lidarr::params::archive_url,
|
||||
$executable = $lidarr::params::executable,
|
||||
$service_enable = $lidarr::params::service_enable,
|
||||
$service_name = $lidarr::params::service_name,
|
||||
$bind_address = $lidarr::params::bind_address,
|
||||
$port = $lidarr::params::port,
|
||||
$ssl_port = $lidarr::params::ssl_port,
|
||||
$enable_ssl = $lidarr::params::enable_ssl,
|
||||
$launch_browser = $lidarr::params::launch_browser,
|
||||
$api_key = $lidarr::params::api_key,
|
||||
$authentication_method = $lidarr::params::authentication_method,
|
||||
$authentication_required = $lidarr::params::authentication_required,
|
||||
$branch = $lidarr::params::branch,
|
||||
$log_level = $lidarr::params::log_level,
|
||||
$ssl_cert_path = $lidarr::params::ssl_cert_path,
|
||||
$ssl_cert_password = $lidarr::params::ssl_cert_password,
|
||||
$url_base = $lidarr::params::url_base,
|
||||
$instance_name = $lidarr::params::instance_name,
|
||||
) inherits lidarr::params {
|
||||
|
||||
include lidarr::install
|
||||
include lidarr::config
|
||||
include lidarr::service
|
||||
|
||||
Class['lidarr::install'] -> Class['lidarr::config'] -> Class['lidarr::service']
|
||||
}
|
||||
58
modules/lidarr/manifests/install.pp
Normal file
58
modules/lidarr/manifests/install.pp
Normal file
@ -0,0 +1,58 @@
|
||||
# instsall lidarr
|
||||
class lidarr::install (
|
||||
$packages = $lidarr::packages,
|
||||
$user = $lidarr::user,
|
||||
$group = $lidarr::group,
|
||||
$base_path = $lidarr::base_path,
|
||||
$install_path = $lidarr::install_path,
|
||||
$config_folder = $lidarr::config_folder,
|
||||
$app_folder = $lidarr::app_folder,
|
||||
$archive_name = $lidarr::archive_name,
|
||||
$archive_url = $lidarr::archive_url,
|
||||
$executable = $lidarr::executable,
|
||||
) {
|
||||
|
||||
$_packages = $packages ? {
|
||||
Array => true,
|
||||
default => false,
|
||||
}
|
||||
|
||||
if $_packages {
|
||||
ensure_packages($packages, {ensure => 'installed'})
|
||||
}
|
||||
|
||||
group { $group:
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
user { $user:
|
||||
ensure => present,
|
||||
shell => '/sbin/nologin',
|
||||
groups => $group,
|
||||
managehome => true,
|
||||
}
|
||||
|
||||
file { [ $base_path, $install_path, $config_folder, $app_folder ]:
|
||||
ensure => directory,
|
||||
owner => $user,
|
||||
group => $group,
|
||||
}
|
||||
|
||||
archive { $archive_name:
|
||||
path => "/tmp/${archive_name}",
|
||||
source => "${archive_url}${archive_name}",
|
||||
extract => true,
|
||||
extract_path => $install_path,
|
||||
creates => "${install_path}/${executable}",
|
||||
cleanup => true,
|
||||
require => File[$install_path],
|
||||
user => $user,
|
||||
group => $group,
|
||||
notify => Exec['move_lidarr_files'],
|
||||
}
|
||||
|
||||
exec { 'move_lidarr_files':
|
||||
command => "/usr/bin/mv ${install_path}/Lidarr/* ${install_path}",
|
||||
creates => "${install_path}/${executable}",
|
||||
}
|
||||
}
|
||||
49
modules/lidarr/manifests/params.pp
Normal file
49
modules/lidarr/manifests/params.pp
Normal file
@ -0,0 +1,49 @@
|
||||
# lidarr params
|
||||
class lidarr::params (
|
||||
Array[String] $packages = [
|
||||
'mediainfo',
|
||||
'libzen',
|
||||
'libmediainfo',
|
||||
'gettext',
|
||||
'sqlite.x86_64',
|
||||
'par2cmdline',
|
||||
'python3-feedparser',
|
||||
'python3-configobj',
|
||||
'python3-cheetah',
|
||||
'python3-dbus',
|
||||
'libxslt-devel',
|
||||
'libchromaprint',
|
||||
],
|
||||
String $user = 'lidarr',
|
||||
String $group = 'lidarr',
|
||||
Stdlib::Absolutepath $base_path = '/opt/lidarr',
|
||||
Stdlib::Absolutepath $install_path = '/opt/lidarr/bin',
|
||||
Stdlib::Absolutepath $config_folder = '/home/lidarr/.config',
|
||||
Stdlib::Absolutepath $app_folder = '/home/lidarr/.config/Lidarr',
|
||||
String $archive_version = '2.3.3',
|
||||
String $archive_name = 'Lidarr.master.linux-core-x64.tar.gz',
|
||||
Stdlib::HTTPUrl $archive_url = "https://git.query.consul/api/packages/unkinben/generic/lidarr/${archive_version}/",
|
||||
String $executable = 'Lidarr/Lidarr',
|
||||
String $service_name = 'lidarr',
|
||||
Boolean $service_enable = true,
|
||||
|
||||
# params for the configuration file
|
||||
Stdlib::Host $bind_address = '127.0.0.1',
|
||||
Stdlib::Port $port = 8686,
|
||||
Stdlib::Port $ssl_port = 9696,
|
||||
Boolean $enable_ssl = false,
|
||||
Boolean $launch_browser = true,
|
||||
String $api_key = '32-digit-random-string-goes-here',
|
||||
Enum[
|
||||
'Forms',
|
||||
'Basic',
|
||||
'External'
|
||||
] $authentication_method = 'External',
|
||||
Enum['Enabled', 'Disabled'] $authentication_required = 'Enabled',
|
||||
String $branch = 'main',
|
||||
Enum['debug', 'info', 'warn', 'error', 'fatal'] $log_level = 'info',
|
||||
Optional[String] $ssl_cert_path = undef,
|
||||
Optional[String] $ssl_cert_password = undef,
|
||||
Optional[String] $url_base = undef,
|
||||
String $instance_name = 'lidarr',
|
||||
) { }
|
||||
21
modules/lidarr/manifests/service.pp
Normal file
21
modules/lidarr/manifests/service.pp
Normal file
@ -0,0 +1,21 @@
|
||||
# manage lidarr service
|
||||
class lidarr::service (
|
||||
$service_enable = $lidarr::service_enable,
|
||||
$service_name = $lidarr::service_name,
|
||||
$user = $lidarr::user,
|
||||
$group = $lidarr::user,
|
||||
$install_path = $lidarr::install_path,
|
||||
$executable = $lidarr::executable,
|
||||
$base_path = $lidarr::base_path,
|
||||
) {
|
||||
if $service_enable {
|
||||
include ::systemd
|
||||
|
||||
systemd::unit_file { "${service_name}.service":
|
||||
content => template('lidarr/lidarr.service.erb'),
|
||||
enable => true,
|
||||
active => true,
|
||||
subscribe => File["${base_path}/config.xml"],
|
||||
}
|
||||
}
|
||||
}
|
||||
14
modules/lidarr/templates/lidarr.service.erb
Normal file
14
modules/lidarr/templates/lidarr.service.erb
Normal file
@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=<%= @service_name %> Daemon
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
User=<%= @user %>
|
||||
Group=<%= @group %>
|
||||
Type=simple
|
||||
ExecStart=<%= @install_path %>/<%= @executable %> -nobrowser -data=<%= @base_path %>
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
TimeoutStopSec=20
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
16
modules/lidarr/templates/lidarr_config.xml.erb
Normal file
16
modules/lidarr/templates/lidarr_config.xml.erb
Normal file
@ -0,0 +1,16 @@
|
||||
<Config>
|
||||
<BindAddress><%= @bind_address %></BindAddress>
|
||||
<Port><%= @port %></Port>
|
||||
<SslPort><%= @ssl_port %></SslPort>
|
||||
<EnableSsl><%= @enable_ssl.to_s.capitalize %></EnableSsl>
|
||||
<LaunchBrowser><%= @launch_browser.to_s.capitalize %></LaunchBrowser>
|
||||
<ApiKey><%= @api_key %></ApiKey>
|
||||
<AuthenticationMethod><%= @authentication_method %></AuthenticationMethod>
|
||||
<AuthenticationRequired><%= @authentication_required %></AuthenticationRequired>
|
||||
<Branch><%= @branch %></Branch>
|
||||
<LogLevel><%= @log_level %></LogLevel>
|
||||
<SslCertPath><%= @ssl_cert_path || '' %></SslCertPath>
|
||||
<SslCertPassword><%= @ssl_cert_password || '' %></SslCertPassword>
|
||||
<UrlBase><%= @url_base || '' %></UrlBase>
|
||||
<InstanceName><%= @instance_name %></InstanceName>
|
||||
</Config><%- # No newline at the end of the file -%>
|
||||
Loading…
Reference in New Issue
Block a user