summaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: f26da35685e53a3f86d65858462482cbaef7fed5 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
class cherrymusic {
  package { [
   'python3-cherrypy3',
   'lame',
  ]:
    ensure => present,
  }

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

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

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

  file { '/var/lib/cherrymusic/.config/cherrymusic/cherrymusic.conf':
    ensure  => present,
    owner   => 'cherrymusic',
    group   => 'cherrymusic',
    mode    => '0644',
    source  => [ 
      'puppet:///modules/site_cherrymusic/cherrymusic.conf',
      'puppet:///modules/cherrymusic/cherrymusic.conf',
    ],
    require => File['/var/lib/cherrymusic/.config/cherrymusic'],
  }

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

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

  #file { '/usr/local/bin/cherrymusic':
  #  ensure  => present,
  #  owner   => root,
  #  group   => root,
  #  mode    => '0755',
  #  content => "/usr/bin/python3 /usr/local/share/cherrymusic/cherrymusic\n"
  #}

  vcsrepo { '/usr/local/share/cherrymusic':
    ensure   => present,
    owner    => root,
    group    => root,
    user     => root,
    provider => git,
    source   => 'https://github.com/devsnd/cherrymusic',
    revision => '911b757b6e3a59d3be5fded9e7ab08b0807959fa',
  }

  service { 'cherrymusic@cherrymusic':
    ensure  => running,
    enable  => true,
    require => [
      File['/var/lib/cherrymusic/.config/cherrymusic/cherrymusic.conf', '/etc/systemd/system/cherrymusic@.service', ], # '/usr/local/bin/cherrymusic'],
      Vcsrepo['/usr/local/share/cherrymusic'],
      Exec['systemctl-enable-cherrymusic'],
    ],
  }

  cron { "cherrymusic-update":
    command     => "/usr/local/share/cherrymusic/cherrymusic --update",
    user        => cherrymusic,
    hour        => "3",
    minute      => "30",
    ensure      => present,
    environment => [ 'SHELL=/bin/bash' ],
    require     => Service['cherrymusic@cherrymusic'],
  }
}