summaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: 927be2dc46bc6dab27718f3bca17612b46c97489 (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
class etherpad {
  case $etherpad_db_password {
    '': { fail("You need to define etherpad database password! Please set \$etherpad_db_password in your site.pp or host config") }
  }

  mysql_database { 'etherpad':
    ensure => present,
  }

  mysql_user { "etherpad@%":
    ensure        => present,
    password_hash => mysql_password($etherpad_db_password),
    require       => Mysql_database['etherpad'],
  }

  mysql_grant { "etherpad@%/etherpad":
    privileges => 'all',
    require    => Mysql_user["etherpad@%"],
  }

  user { "etherpad-lite":
    ensure    => present,
    allowdupe => false,
  }

  group { "etherpad-lite":
    ensure    => present,
    allowdupe => false,
  }

  package { 'npm':
    ensure => present,
  }

  vcsrepo { "/var/lib/etherpad-lite":
    ensure   => present,
    provider => git,
    source   => 'git://github.com/Pita/etherpad-lite.git',
    revision => 'ddf1cd345c8516a77c1440b53ddc05279551db7b',
    owner    => 'etherpad-lite',
    group    => 'etherpad-lite',
    require  => [ User['etherpad-lite'], Group['etherpad-lite'] ],
    notify   => Service['etherpad-lite'],
  }

  file { '/etc/init.d/etherpad-lite':
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => 0755,
    source  => 'puppet:///modules/etherpad/init.d/etherpad-lite.sh',
    require => Vcsrepo['/var/lib/etherpad-lite'],
  }

  file { '/var/log/etherpad-lite':
    ensure  => directory,
    owner   => 'etherpad-lite',
    group   => 'etherpad-lite',
    mode    => 0755,
    require => [ User['etherpad-lite'], Group['etherpad-lite'] ],
  }

  file { '/etc/logrotate.d/etherpad-lite':
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => 0644,
    source  => 'puppet:///modules/etherpad/logrotate.d/etherpad-lite',
    require => File['/var/log/etherpad-lite'],
  }

  file { '/var/lib/etherpad-lite/settings.json':
    ensure  => present,
    owner   => 'etherpad-lite',
    group   => 'etherpad-lite',
    mode    => 0640,
    content => template('etherpad/settings.json.erb'),
    require => Vcsrepo['/var/lib/etherpad-lite'],
    notify  => Service['etherpad-lite'],
  }

  service { 'etherpad-lite':
    enable     => true,
    ensure     => running,
    hasrestart => true,
    hasstatus  => true,
    require    => [ File['/etc/init.d/etherpad-lite', '/var/lib/etherpad-lite/settings.json'],
                    Mysql_grant['etherpad@%/etherpad'], Package['npm'] ],
  }
}