aboutsummaryrefslogtreecommitdiffstats
path: root/modules/mga-treasurer/manifests/init.pp
blob: d41b518e23aadafa13e0e6d757e5899dd079bba9 (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
class mga-treasurer(
  $grisbi_git = "git://git.$::domain/org/accounts",
  $grisbi_filename = 'mageia-accounts.gsb',
  $vhost,
  $vhostdir
){
  $mgatres_login = 'mga-treasurer'
  $mgatres_homedir = "/var/lib/${mgatres_login}"
  $grisbi_dir = "${mgatres_homedir}/grisbi"
  $grisbi_path = "${grisbi_dir}/${grisbi_filename}"

  $update_script = '/usr/local/bin/update_mga-treasurer'

  group { $mgatres_login:
    ensure => present,
  }

  user { $mgatres_login:
    ensure     => present,
    comment    => 'mga-treasurer user',
    home       => $mgatres_homedir,
    managehome => true,
    gid        => $mgatres_login,
  }

  package { 'mga-treasurer':
    ensure => installed,
  }

  file {'/etc/mga-treasurer.conf':
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => '0644',
    content => template('mga-treasurer/mga-treasurer.conf'),
    require => Package['mga-treasurer'],
  }

  file { $vhostdir:
    ensure => directory,
    owner  => $mgatres_login,
    group  => $mgatres_login,
    mode   => '0755',
  }

  apache::vhost::base { $vhost:
    location => $vhostdir,
    aliases  => {
      "/${grisbi_filename}" => $grisbi_path,
      "/static"             => '/usr/share/mga-treasurer/static',
    },
    content  => template('mga-treasurer/vhost_mga-treasurer.conf'),
    require  => File[$vhostdir],
  }

  apache::vhost::base { "ssl_${vhost}":
    use_ssl  => true,
    vhost    => $vhost,
    location => $vhostdir,
    aliases  => {
      "/${grisbi_filename}" => $grisbi_path,
      "/static"             => '/usr/share/mga-treasurer/static',
    },
    content  => template('mga-treasurer/vhost_mga-treasurer.conf'),
    require  => File[$vhostdir],
  }

  file { $update_script:
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => '0755',
    content => template('mga-treasurer/update_script'),
  }

  git::snapshot { $grisbi_dir:
    source  => $grisbi_git,
    user    => $mgatres_login,
    refresh => '0',
    require => User[$mgatres_login],
  }

  cron { $update_script:
    command => $update_script,
    user    => $mgatres_login,
    hour    => '*/2',
    minute  => '10',
    require => Git::Snapshot[$grisbi_dir],
  }
}
# vim: sw=2