Puppet Class: role::globalblocking

Defined in:
puppet/modules/role/manifests/globalblocking.pp

Overview

Class: role::globalblocking

Configures a MediaWiki instance with GlobalBlocking

Parameters

db_host

Database host used to connect to GlobalBlocking database

db_user

Database user used for GlobalBlocking database

db_pass

Database password used for GlobalBlocking database

db_name

Database password used for GlobalBlocking database

Parameters:

  • db_host (Any)
  • db_user (Any)
  • db_pass (Any)
  • db_name (Any)


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
# File 'puppet/modules/role/manifests/globalblocking.pp', line 19

class role::globalblocking(
    $db_host,
    $db_user,
    $db_pass,
    $db_name,
) {
    require ::role::mediawiki

    mysql::db { $db_name:
        ensure  => present,
        options => 'DEFAULT CHARACTER SET binary',
    }

    mysql::sql { "GRANT ALL PRIVILEGES ON ${db_name}.* TO ${db_user}@${db_host}":
        unless  => "SELECT 1 FROM INFORMATION_SCHEMA.SCHEMA_PRIVILEGES WHERE TABLE_SCHEMA = '${db_name}' AND GRANTEE = \"'${db_user}'@'${db_host}'\" LIMIT 1",
        require => Mysql::User[$db_user],
    }

    mysql::sql { 'Create global_block_whitelist table':
        sql     => "USE ${db_name}; SOURCE ${::mediawiki::dir}/extensions/GlobalBlocking/sql/mysql/tables-generated-global_block_whitelist.sql;",
        unless  => "SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '${db_name}' AND table_name = 'global_block_whitelist';",
        require => [
            Mysql::Db[$db_name],
            Mediawiki::Extension['GlobalBlocking']
        ],
        before  => Exec['update_all_databases'],
    }

    mysql::sql { 'Create globalblocks table':
        sql     => "USE ${db_name}; SOURCE ${::mediawiki::dir}/extensions/GlobalBlocking/sql/mysql/tables-generated-globalblocks.sql;",
        unless  => "SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '${db_name}' AND table_name = 'globalblocks';",
        require => [
            Mysql::Db[$db_name],
            Mediawiki::Extension['GlobalBlocking']
        ],
        before  => Exec['update_all_databases'],
    }

    mediawiki::extension { 'GlobalBlocking':
        needs_update => true,
        settings     => {
            # We're not changing it, but this causes them all to get
            # the name from the same place.
            wgGlobalBlockingDatabase => $db_name,
        }
    }
}