Puppet Class: smashpig

Defined in:
puppet/modules/smashpig/manifests/init.pp

Overview

Class: smashpig

Provision a site to listen for realtime payment notifications.

Parameters:

  • vhost_name (Any)
  • dir (Any)
  • db_name (Any)
  • db_pass (Any)


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
# File 'puppet/modules/smashpig/manifests/init.pp', line 5

class smashpig(
    $vhost_name,
    $dir,
    $db_name,
    $db_pass,
) {
    include ::php
    include ::apache
    include ::git

    # This is needed for the SmashPig Adyen payment listener
    package { 'php7.4-soap': }

    git::clone { 'wikimedia/fundraising/SmashPig':
        directory => $dir,
    }

    service::gitupdate { 'smashpig':
        dir    => $dir,
        type   => 'php',
        update => true,
    }

    file { ['/etc/smashpig', '/etc/smashpig/adyen', '/etc/smashpig/paypal']:
        ensure => directory
    }

    file { '/etc/smashpig/main.yaml':
        content => template('smashpig/smashpig/main.yaml.erb'),
        require => [
            Git::Clone['wikimedia/fundraising/SmashPig'],
            File['/etc/smashpig'],
        ],
    }

    file { '/etc/smashpig/adyen/main.yaml':
        content => template('smashpig/smashpig/adyen/main.yaml.erb'),
        require => [
            Git::Clone['wikimedia/fundraising/SmashPig'],
            File['/etc/smashpig/adyen'],
        ],
    }

    file { '/etc/smashpig/paypal/main.yaml':
        content => template('smashpig/smashpig/paypal/main.yaml.erb'),
        require => [
            Git::Clone['wikimedia/fundraising/SmashPig'],
            File['/etc/smashpig/paypal'],
        ],
    }

    file { "${dir}/PublicHttp/.htaccess":
        source  => "${dir}/PublicHttp/.htaccess.sample",
        require => Git::Clone['wikimedia/fundraising/SmashPig'],
    }

    php::composer::install { $dir:
        prefer  => 'source',
        require => Git::Clone['wikimedia/fundraising/SmashPig'],
    }

    apache::site { 'payments-listener':
        ensure  => present,
        content => template('smashpig/apache-site.erb'),
        require => [
            File['/etc/smashpig/main.yaml'],
            File["${dir}/PublicHttp/.htaccess"],
            Class['::apache::mod::rewrite'],
        ],
    }

    mysql::user { $db_name :
      ensure   => present,
      grant    => 'ALL ON *.*',
      password => $db_pass,
      require  => Mysql::Db['smashpig'],
    }

    mysql::db { 'smashpig': }

    exec { 'smashpig_schema':
        command => "cat ${dir}/Schema/mysql/*.sql | /usr/bin/mysql smashpig -qfsA",
        require => [
            Git::Clone['wikimedia/fundraising/SmashPig'],
            Mysql::Db['smashpig'],
        ],
    }

    file { '/etc/cron.d/SmashPig':
        content => template('smashpig/SmashPig.cron.d.erb'),
        owner   => 'root',
        group   => 'root',
        mode    => '0644'
    }

}