aboutsummaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: f0d695bd74f245636e905ae0385366664bf0bd4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# See https://airsonic.github.io/docs/install/war-standalone/
class airsonic {
  package { [
   'default-jre',
  ]:
    ensure => present,
  }

  group { "airsonic":
    ensure    => present,
    allowdupe => false,
  }

  user { "airsonic":
    ensure    => present,
    allowdupe => false,
    shell     => '/bin/false',
    gid       => 'airsonic',
    home      => '/var/lib/airsonic',
    require   => Group['airsonic'],
  }

  file { [
    '/var/lib/airsonic',
    '/var/lib/airsonic/transcode',
  ]:
    ensure   => directory,
    owner    => 'airsonic',
    group    => 'airsonic',
    mode     => '0750',
    require  => User['airsonic'],
  }

  file { '/usr/local/sbin/airsonic-download':
    ensure => present,
    owner  => root,
    group  => root,
    mode   => '0755',
    source => 'puppet:///modules/airsonic/airsonic-download',
  }

  exec { 'airsonic-download':
    #command => '/usr/bin/wget https://github.com/airsonic/airsonic/releases/download/v10.1.2/airsonic.war --output-document=/var/lib/airsonic/airsonic.war',
    command  => '/usr/local/sbin/airsonic-download',
    creates  => '/var/lib/airsonic/airsonic.war',
    user     => root,
    require  => File['/var/lib/airsonic', '/usr/local/sbin/airsonic-download'],
  }

  file { '/etc/systemd/system/airsonic.service':
    ensure => present,
    owner  => root,
    group  => root,
    mode   => '0644',
    source => 'puppet:///modules/airsonic/airsonic.service',
    notify => Exec['systemctl-enable-airsonic'],
  }

  exec { 'systemctl-enable-airsonic':
    command     => '/bin/systemctl daemon-reload && /bin/systemctl enable airsonic',
    require     => File['/etc/systemd/system/airsonic.service'],
    user        => root,
    refreshonly => true,
  }

  service { 'airsonic':
    ensure  => running,
    enable  => true,
    require => [
      File['/var/lib/airsonic', '/etc/systemd/system/airsonic.service', ],
      Exec['airsonic-download', 'systemctl-enable-airsonic'],
      Package['default-jre'],
    ],
  }

  # https://airsonic.github.io/docs/transcode/
  file { '/var/lib/airsonic/transcode/ffmpeg':
    ensure  => '/usr/bin/ffmpeg',
    owner   => 'airsonic',
    group   => 'airsonic',
    require => File['/var/lib/airsonic/transcode'],
  }
}