Puppet Class: community_civicrm

Defined in:
modules/community_civicrm/manifests/init.pp

Overview

Parameters:

  • config_nonce (String)
  • hash_salt (String)
  • site_name (Stdlib::Fqdn)
  • db_host (Stdlib::Host) (defaults to: 'localhost')
  • db_user (String) (defaults to: 'civi_admin')
  • db_pass (String) (defaults to: 'FAKEFAKEFAKE')
  • db_name (String) (defaults to: 'drupal')
  • file_root (Stdlib::Unixpath) (defaults to: '/var/www/community_civicrm')
  • web_root (Stdlib::Unixpath) (defaults to: "${file_root}/web")


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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'modules/community_civicrm/manifests/init.pp', line 24

class community_civicrm (
    String $config_nonce,
    String $hash_salt,
    Stdlib::Fqdn $site_name,
    Stdlib::Host $db_host = 'localhost',
    String $db_user = 'civi_admin',
    String $db_pass = 'FAKEFAKEFAKE',
    String $db_name = 'drupal',
    Stdlib::Unixpath $file_root = '/var/www/community_civicrm',
    Stdlib::Unixpath $web_root = "${file_root}/web",
){

    ensure_packages([
        'libapache2-mod-php',
        'php-bcmath',
        'php-curl',
        'php-gd',
        'php-intl',
        'php-mbstring',
        'php-mysql',
        'php-soap',
        'php-xml',
        'php-zip',
    ])

    $php_version = wmflib::debian_php_version()

    systemd::sysuser { 'civiadmin':
        additional_groups => [ 'www-data' ],
        home_dir          => '/usr/lib/community_civicrm',
    }

    file { '/srv/community_civicrm':
        ensure => directory,
        owner  => 'civiadmin',
        group  => 'civiadmin',
    }

    $civi_www_dirs = [
        '/var/www/community_civicrm/web/',
        '/var/www/community_civicrm/web/sites',
        '/var/www/community_civicrm/web/sites/default',
    ]

    file { $civi_www_dirs:
        ensure => 'directory',
        owner  => 'civiadmin',
        group  => 'www-data',
    }

    $www_admin_dirs = [
        '/var/www/community_civicrm/web/sites/default/files',
        "/var/www/community_civicrm/web/sites/default/files/config_${config_nonce}",
        "/var/www/community_civicrm/web/sites/default/files/config_${config_nonce}/sync",
        '/var/www/community_civicrm/web/sites/default/files/civicrm',
        '/var/www/community_civicrm/web/sites/default/files/civicrm/templates_c',
        '/var/www/community_civicrm/web/sites/default/files/css',
        '/var/www/community_civicrm/web/sites/default/files/js',
    ]

    file { $www_admin_dirs:
        ensure => 'directory',
        owner  => 'www-data',
        group  => 'www-data',
    }

    # add cv and drush bin dirs to PATH for all users
    file { '/etc/profile.d/community_civicrm_path.sh':
        ensure  => present,
        mode    => '0644',
        content => template('community_civicrm/civicrm/community_civicrm_path.sh.erb'),
    }

    # add civicrm settings file
    file { '/var/www/community_civicrm/web/sites/default/civicrm.settings.php':
        ensure  => present,
        owner   => 'civiadmin',
        group   => 'www-data',
        mode    => '0640',
        content => template('community_civicrm/civicrm/civicrm.settings.php.erb'),
    }

    # add drupal settings file
    file { '/var/www/community_civicrm/web/sites/default/settings.php':
        ensure  => present,
        owner   => 'civiadmin',
        group   => 'www-data',
        mode    => '0640',
        content => template('community_civicrm/civicrm/settings.php.erb'),
    }

    # add php settings specific for civicrm
    file { "/etc/php/${php_version}/apache2/conf.d/50-community_civicrm.ini":
        ensure  => file,
        content => wmflib::php_ini({
            # CiviCRM suggested php.ini values
            'memory_limit'        => '256M',
            'max_execution_time'  => '240',
            'max_input_time'      => '120',
            'post_max_size'       => '50M',
            'upload_max_filesize' => '50M',
            # Also don't show notice errors
            'error_reporting'     => 'E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE',
        }),
        owner   => 'root',
        group   => 'root',
        mode    => '0644',
        notify  => Service['apache2'],
    }

    # directory used by deploy-script to store backups
    file { '/usr/lib/community_civicrm/backup':
        ensure  => directory,
        owner   => 'civiadmin',
        group   => 'civiadmin',
        require => User['civiadmin'],
    }

    # deployment script that copies files in place after puppet git clones to /srv/
    file { '/usr/local/bin/community_civicrm-deploy':
        ensure => present,
        mode   => '0544',
        source => 'puppet:///modules/community_civicrm/deploy-community_civicrm.sh',
    }

    git::clone { 'repos/fundraising-tech/community-civicrm':
        ensure    => latest,
        directory => '/srv/community_civicrm',
        branch    => 'main',
        owner     => 'civiadmin',
        group     => 'www-data',
        source    => 'gitlab',
    }

    # install a db on localhost
    class { 'community_civicrm::db':
        db_host     => $db_host,
        db_user     => $db_user,
        db_pass     => $db_pass,
        db_name     => $db_name,
        php_version => $php_version,
    }

    # run the regularly scheduled civi jobs
    # https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/
    systemd::timer::job { 'community_civicrm-cv-job-run':
        ensure          => present,
        user            => 'www-data',
        description     => 'Run the jobs scheduled for civicrm',
        command         => "${file_root}/vendor/civicrm/cv/bin/cv api job.execute --user=civi_admin --cwd=${file_root}",
        logging_enabled => true,
        logfile_basedir => '/var/log/community_civicrm/',
        logfile_name    => 'cv-job-run.log',
        interval        => {'start' => 'OnCalendar', 'interval' => '*:0/5'},
    }


}