Working version
This commit contains a working version of this Puppet implementation of Sonarr.
This commit is contained in:
parent
1986730af1
commit
b9a617cf25
@ -1,73 +1,28 @@
|
||||
# Class: sonarr
|
||||
# ===========================
|
||||
#
|
||||
# Full description of class sonarr here.
|
||||
#
|
||||
# Parameters
|
||||
# ----------
|
||||
#
|
||||
# Document parameters here.
|
||||
#
|
||||
# * `sample parameter`
|
||||
# Explanation of what this parameter affects and what it defaults to.
|
||||
# e.g. "Specify one or more upstream ntp servers as an array."
|
||||
#
|
||||
# Variables
|
||||
# ----------
|
||||
#
|
||||
# Here you should define a list of variables that this module would require.
|
||||
#
|
||||
# * `sample variable`
|
||||
# Explanation of how this variable affects the function of this class and if
|
||||
# it has a default. e.g. "The parameter enc_ntp_servers must be set by the
|
||||
# External Node Classifier as a comma separated list of hostnames." (Note,
|
||||
# global variables should be avoided in favor of class parameters as
|
||||
# of Puppet 2.6.)
|
||||
#
|
||||
# Examples
|
||||
# --------
|
||||
#
|
||||
# @example
|
||||
# class { 'sonarr':
|
||||
# servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
|
||||
# }
|
||||
#
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# Ruben Bosch <ruben@rubuen.me>
|
||||
#
|
||||
# Copyright
|
||||
# ---------
|
||||
#
|
||||
# Copyright 2019 Ruben Bosch.
|
||||
# == Class: sonarr
|
||||
#
|
||||
class sonarr (
|
||||
$manage_epel = false,
|
||||
$mono = true,
|
||||
) {
|
||||
if $manage_epel {
|
||||
package { 'epel-release':
|
||||
ensure => 'installed',
|
||||
}
|
||||
}
|
||||
if $mono {
|
||||
yumrepo { 'mono':
|
||||
ensure => present,
|
||||
baseurl => 'http://download.mono-project.com/repo/centos/',
|
||||
gpgkey => "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF",
|
||||
} ->
|
||||
package {
|
||||
[
|
||||
'wget', 'mediainfo', 'libzen', 'libmediainfo',
|
||||
'curl', 'gettext', 'mono-core', 'mono-devel',
|
||||
'sqlite.x86_64', 'git', 'par2cmdline', 'p7zip',
|
||||
'unar.x86_64', 'unzip', 'tar', 'gcc',
|
||||
'python-feedparser', 'python-configobj',
|
||||
'python-cheetah', 'python-dbus', 'python-devel',
|
||||
'libxslt-devel'
|
||||
]:
|
||||
ensure => installed,
|
||||
}
|
||||
}
|
||||
$manage_epel = $sonarr::params::manage_epel,
|
||||
$install_mono = $sonarr::params::install_mono,
|
||||
$mono_baseurl = $sonarr::params::mono_baseurl,
|
||||
$mono_gpgkey = $sonarr::params::mono_gpgkey,
|
||||
$mono_packages = $sonarr::params::mono_packages,
|
||||
$additional_packages = $sonarr::params::additional_packages,
|
||||
$user = $sonarr::params::user,
|
||||
$group = $sonarr::params::user,
|
||||
$base_path = $sonarr::params::base_path,
|
||||
$install_path = $sonarr::params::install_path,
|
||||
$config_folder = $sonarr::params::config_folder,
|
||||
$app_folder = $sonarr::params::app_folder,
|
||||
$archive_name = $sonarr::params::archive_name,
|
||||
$archive_url = $sonarr::params::archive_url,
|
||||
$executable = $sonarr::params::executable,
|
||||
$service_enable = $sonarr::params::service_enable,
|
||||
$service_name = $sonarr::params::service_name,
|
||||
) inherits sonarr::params {
|
||||
|
||||
contain sonarr::install
|
||||
contain sonarr::service
|
||||
|
||||
Class['sonarr::install'] ~>
|
||||
Class['sonarr::service']
|
||||
}
|
||||
|
||||
84
manifests/install.pp
Normal file
84
manifests/install.pp
Normal file
@ -0,0 +1,84 @@
|
||||
# == Class: sonarr::install
|
||||
#
|
||||
class sonarr::install (
|
||||
$manage_epel = $sonarr::manage_epel,
|
||||
$install_mono = $sonarr::install_mono,
|
||||
$mono_baseurl = $sonarr::mono_baseurl,
|
||||
$mono_gpgkey = $sonarr::mono_gpgkey,
|
||||
$mono_packages = $sonarr::mono_packages,
|
||||
$additional_packages = $sonarr::additional_packages,
|
||||
$user = $sonarr::user,
|
||||
$group = $sonarr::user,
|
||||
$base_path = $sonarr::base_path,
|
||||
$install_path = $sonarr::install_path,
|
||||
$config_folder = $sonarr::config_folder,
|
||||
$app_folder = $sonarr::app_folder,
|
||||
$archive_name = $sonarr::archive_name,
|
||||
$archive_url = $sonarr::archive_url,
|
||||
$executable = $sonarr::executable,
|
||||
) {
|
||||
|
||||
if $manage_epel {
|
||||
package { 'epel-release':
|
||||
ensure => 'installed',
|
||||
}
|
||||
}
|
||||
|
||||
if $install_mono {
|
||||
yumrepo { 'mono':
|
||||
ensure => present,
|
||||
baseurl => $mono_baseurl,
|
||||
gpgkey => $mono_gpgkey,
|
||||
gpgcheck => true,
|
||||
} ->
|
||||
|
||||
package { $mono_packages:
|
||||
ensure => installed,
|
||||
}
|
||||
}
|
||||
|
||||
$_additional_packages = $additional_packages ? {
|
||||
Array => true,
|
||||
default => false,
|
||||
}
|
||||
|
||||
if $_additional_packages {
|
||||
package { $additional_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,
|
||||
} ->
|
||||
|
||||
exec { 'move files to correct folder':
|
||||
command => "/usr/bin/mv ${install_path}/NzbDrone/* ${install_path}",
|
||||
creates => "${install_path}/${executable}",
|
||||
}
|
||||
}
|
||||
23
manifests/params.pp
Normal file
23
manifests/params.pp
Normal file
@ -0,0 +1,23 @@
|
||||
class sonarr::params {
|
||||
$manage_epel = true
|
||||
$install_mono = true
|
||||
$mono_baseurl = 'http://download.mono-project.com/repo/centos/'
|
||||
$mono_gpgkey = 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF'
|
||||
$mono_packages = ['mono-core', 'mono-devel']
|
||||
$additional_packages = ['wget', 'mediainfo', 'libzen', 'libmediainfo', 'curl',
|
||||
'gettext', 'sqlite.x86_64', 'git', 'par2cmdline',
|
||||
'p7zip', 'unar.x86_64', 'unzip', 'tar', 'gcc',
|
||||
'python-feedparser', 'python-configobj',
|
||||
'python-cheetah', 'python-dbus', 'python-devel',
|
||||
'libxslt-devel']
|
||||
$user = 'sonarr'
|
||||
$base_path = '/opt/sonarr'
|
||||
$install_path = '/opt/sonarr/bin'
|
||||
$config_folder = "/home/${user}/.config"
|
||||
$app_folder = "/home/${user}/.config/NzbDrone"
|
||||
$archive_name = 'NzbDrone.master.tar.gz'
|
||||
$archive_url = 'http://update.sonarr.tv/v2/master/mono/'
|
||||
$executable = 'NzbDrone.exe'
|
||||
$service_enable = true
|
||||
$service_name = 'sonarr'
|
||||
}
|
||||
21
manifests/service.pp
Normal file
21
manifests/service.pp
Normal file
@ -0,0 +1,21 @@
|
||||
# == Class: sonarr::service
|
||||
#
|
||||
class sonarr::service (
|
||||
$service_enable = $sonarr::service_enable,
|
||||
$service_name = $sonarr::service_name,
|
||||
$user = $sonarr::user,
|
||||
$group = $sonarr::user,
|
||||
$install_path = $sonarr::install_path,
|
||||
$executable = $sonarr::executable,
|
||||
$base_path = $sonarr::base_path,
|
||||
) {
|
||||
if $service_enable {
|
||||
include ::systemd
|
||||
|
||||
systemd::unit_file { "${service_name}.service":
|
||||
content => template('sonarr/systemd.erb'),
|
||||
enable => true,
|
||||
active => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
13
templates/systemd.erb
Normal file
13
templates/systemd.erb
Normal file
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=<%= @service_name %> Daemon
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
User=<%= @user %>
|
||||
Group=<%= @group %>
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/mono <%= @install_path %>/<%= @executable %> -nobrowser -data <%= @base_path %>
|
||||
|
||||
TimeoutStopSec=20
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Loading…
Reference in New Issue
Block a user