aboutsummaryrefslogtreecommitdiffstats
path: root/modules/mirrorbrain/manifests/init.pp
blob: 5b9aa03f4b912621d81289dddd7cee33266fc412 (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
101
102
103
104
105
106
class mirrorbrain {

    $mb_user  = 'mirrorbrain'
    $mb_home  = "/var/lib/${mb_user}"
    $mb_repo  = "${mb_home}/mirror"
    $mb_vhost = "dl.${::domain}"

    $mb_pgsql_pw = extlookup('mirrorbrain_pgsql','x')

    group { $mb_user:
      ensure => present
    }

    user { $mb_user:
      ensure => present,
      home   => $mb_home
    }

    file { $mb_home:
      ensure => directory,
      owner  => $mb_user,
      group  => $mb_user,
      mode   => '0750'
    }

    file { $mb_repo:
      ensure => directory,
      owner  => $mb_user,
      group  => $mb_user,
      mode   => '0755'
    }

    package {['mirrorbrain',
              'mirrorbrain-scanner',
              'mirrorbrain-tools',
              'apache-mod_mirrorbrain']: }


    postgresql::remote_db_and_user { 'mirrorbrain':
        description => 'Mirrorbrain database',
        password    => $mb_pgsql_password,
    }

    file { '/etc/httpd/conf/geoip.conf':
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      content => template('mirrorbrain/geoip.conf')
    }

    file { '/etc/mirrorbrain.conf':
      owner   => 'root',
      group   => 'apache',
      mode    => '0640',
      content => template('mirrorbrain/mirrorbrain.conf')
    }

    apache::vhost::base { "${mb_vhost}":
        vhost    => "${mb_vhost}",
        location => "${mb_repo}"
    }

    apache::vhost::base { "ssl_${mb_vhost}":
        vhost    => "${mb_vhost}",
        use_ssl  => true,
        location => "${mb_repo}"
    }

    apache::webapp_other { 'mirrorbrain':
        webapp_file => 'mirrorbrain/webapp.conf',
    }

    cron { 'GeoIP update':
        command => 'sleep $(($RANDOM/1024)); /usr/bin/geoip-lite-update',
        user    => 'root',
        minute  => 30,
        hour    => 3,
        weekday => 0
    }

    cron { 'fake mirror update':
        command => "/usr/bin/null-rsync rsync.mageia.org::mageia ${mb_repo}/",
        user    => "$mb_user",
        minute  => 5
    }

    cron { 'mirror online status check':
        command => '/usr/bin/mirrorprobe',
        user    => "$mb_user",
        minute  => 5
    }

    cron { 'mirror scanning':
        command => '/usr/bint/mb scan --quiet --jobs 4 --all',
        user    => "$mb_user",
        minute  => 30
    }

    cron { 'mirror database cleanup':
        command => '/usr/bint/mb db vacuum',
        user    => "$mb_user",
        minute  => 30,
        hour    => 2,
        weekday => 1
    }
}