summaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: b62d9a4595d45a3a54bdfe841c60dc62aa11a6c3 (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
# https://wiki.koumbit.net/ObbyServer
# http://gobby.0x539.de/trac/wiki/Infinote/Infinoted
# http://www.webupd8.org/2011/04/how-to-set-up-and-use-gedit.html
class infinoted(
  $password = hiera('infinoted::password', '')
) {
  include avahi

  case $password {
    '': { fail("You need to define infinoted password! Please set infinoted::password in your config") }
  }

  package { 'infinoted':
    ensure => installed,
  }

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

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

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

  file { [ '/var/lib/infinoted/.config', '/var/lib/infinoted/.infinoted',
           '/var/lib/infinoted/.certs',  '/var/lib/infinoted/data',
           '/var/lib/infinoted/export' ]:
    ensure  => directory,
    owner   => 'infinoted',
    group   => 'infinoted',
    mode    => '0750',
    require => File['/var/lib/infinoted'],
  }

  file { '/var/lib/infinoted/.config/infinoted.conf':
    ensure  => present,
    owner   => 'infinoted',
    group   => 'infinoted',
    mode    => '0640',
    content => template('infinoted/infinoted.conf.erb'),
    require => File['/var/lib/infinoted/.config'],
  }

  # Generate keys
  # This exec will launch the server but not daemonize, so we fork it to the background
  exec { 'infinoted-gen-keys':
    command => '/usr/bin/infinoted --create-key --create-certificate -k /var/lib/infinoted/.certs/infinoted.key -c /var/lib/infinoted/.certs/infinoted.cert &',
    creates => '/var/lib/infinoted/.certs/infinoted.key',
    require => File['/var/lib/infinoted/.config/infinoted.conf'],
  }

  supervisor::app { 'infinoted':
    source  => [ 'puppet:///modules/site_infinoted/infinoted.conf',
                 'puppet:///modules/infinoted/infinoted.conf' ],
    require => [ File['/var/lib/infinoted/.config/infinoted.conf'], Exec['infinoted-gen-keys'] ],
  }

  file { '/etc/avahi/services/infinoted.service':
    ensure => present,
    owner  => root,
    group  => root,
    mode   => '0644',
    source => 'puppet:///modules/infinoted/infinoted.service',
    notify => Service['avahi-daemon'],
  }
}