Puppet Class: profile::maps::osm_master

Defined in:
modules/profile/manifests/maps/osm_master.pp

Overview

Parameters:

  • planet_sync_period (Any) (defaults to: hiera('profile::maps::osm_master::planet_sync_period', 'day'))
  • planet_sync_day (Any) (defaults to: hiera('profile::maps::osm_master::planet_sync_day', '*/2'))
  • planet_sync_hour (Any) (defaults to: hiera('profile::maps::osm_master::planet_sync_hour', '1'))
  • planet_sync_minute (Any) (defaults to: hiera('profile::maps::osm_master::planet_sync_minute', '27'))
  • maps_hosts (Any) (defaults to: hiera('profile::maps::hosts'))
  • kartotherian_pass (Any) (defaults to: hiera('profile::maps::osm_master::kartotherian_pass'))
  • tilerator_pass (Any) (defaults to: hiera('profile::maps::osm_master::tilerator_pass'))
  • tileratorui_pass (Any) (defaults to: hiera('profile::maps::osm_master::tileratorui_pass'))
  • replication_pass (Any) (defaults to: hiera('profile::maps::osm_master::replication_pass'))
  • postgres_slaves (Any) (defaults to: hiera('profile::maps::osm_master::slaves', undef))
  • cleartables (Any) (defaults to: hiera('profile::maps::osm_master::cleartables', false))
  • disable_replication_cron (Any) (defaults to: hiera('profile::maps::osm_master::disable_replication_cron', false))
  • disable_admin_cron (Any) (defaults to: hiera('profile::maps::osm_master::disable_admin_cron', false))
  • tilerator_storage_id (Any) (defaults to: hiera('profile::maps::apps::tilerator_storage_id'))
  • use_proxy (Any) (defaults to: hiera('profile::maps::apps::use_proxy'))


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
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'modules/profile/manifests/maps/osm_master.pp', line 1

class profile::maps::osm_master (
    $planet_sync_period       = hiera('profile::maps::osm_master::planet_sync_period', 'day'),
    $planet_sync_day          = hiera('profile::maps::osm_master::planet_sync_day', '*/2'),
    $planet_sync_hour         = hiera('profile::maps::osm_master::planet_sync_hour', '1'),
    $planet_sync_minute       = hiera('profile::maps::osm_master::planet_sync_minute', '27'),
    $maps_hosts               = hiera('profile::maps::hosts'),
    $kartotherian_pass        = hiera('profile::maps::osm_master::kartotherian_pass'),
    $tilerator_pass           = hiera('profile::maps::osm_master::tilerator_pass'),
    $tileratorui_pass         = hiera('profile::maps::osm_master::tileratorui_pass'),
    $replication_pass         = hiera('profile::maps::osm_master::replication_pass'),
    $postgres_slaves          = hiera('profile::maps::osm_master::slaves', undef),
    $cleartables              = hiera('profile::maps::osm_master::cleartables', false),
    $disable_replication_cron = hiera('profile::maps::osm_master::disable_replication_cron', false),
    $disable_admin_cron       = hiera('profile::maps::osm_master::disable_admin_cron', false),
    $tilerator_storage_id     = hiera('profile::maps::apps::tilerator_storage_id'),
    $use_proxy                = hiera('profile::maps::apps::use_proxy'),
) {

    require ::profile::maps::postgresql_common

    $maps_hosts_ferm = join($maps_hosts, ' ')

    $db_name = $cleartables ? {
        true    => 'ct',
        default => 'gis',
    }

    $pgversion = $::lsbdistcodename ? {
        'stretch' => '9.6',
        'jessie'  => '9.4',
    }

    class { '::postgresql::master':
        root_dir            => '/srv/postgresql',
        includes            => [ 'tuning.conf', 'logging.conf' ],
        checkpoint_segments => 768,
        wal_keep_segments   => 768,
    }

    class { '::osm': }
    class { '::osm::import_waterlines':
        use_proxy  => $use_proxy,
        proxy_host => "webproxy.${::site}.wmnet",
        proxy_port => 8080,
    }

    # Users
    postgresql::user { 'kartotherian':
        user     => 'kartotherian',
        password => $kartotherian_pass,
        database => $db_name,
    }
    postgresql::user { 'tileratorui':
        user     => 'tileratorui',
        password => $tileratorui_pass,
        database => $db_name,
    }
    postgresql::user { 'osmimporter@localhost':
        user     => 'osmimporter',
        database => $db_name,
        type     => 'local',
        method   => 'peer'
    }
    postgresql::user { 'osmupdater@localhost':
        user     => 'osmupdater',
        database => $db_name,
        type     => 'local',
        method   => 'peer'
    }
    postgresql::user { 'prometheus@localhost':
        user     => 'prometheus',
        database => 'postgres',
        type     => 'local',
        method   => 'peer',
    }

    profile::maps::tilerator_user { 'localhost':
        ip_address => '127.0.0.1',
        password   => $tilerator_pass,
    }

    if $postgres_slaves {
        create_resources(
            profile::maps::tilerator_user,
            $postgres_slaves,
            { password => $tilerator_pass }
        )
    }

    # Grants
    file { "/usr/local/bin/maps-grants-${db_name}.sql":
        owner   => 'root',
        group   => 'root',
        mode    => '0400',
        content => template('profile/maps/grants-db.sql.erb'),
    }
    file { '/usr/local/bin/maps-grants-tiles.sql':
        owner   => 'root',
        group   => 'root',
        mode    => '0400',
        content => template('profile/maps/grants-tiles.sql.erb'),
    }
    file { '/usr/local/bin/grants-populate-admin.sql':
        owner  => 'postgres',
        group  => 'postgres',
        mode   => '0400',
        source => 'puppet:///modules/profile/maps/grants-populate-admin.sql',
    }

    # DB setup
    postgresql::spatialdb { $db_name: }
    if $cleartables {
        postgresql::db::extension { "${db_name}-fuzzystrmatch":
          database => $db_name,
          extname  => 'fuzzystrmatch',
          require  => Postgresql::Db[$db_name],
        }
        postgresql::db::extension { "${db_name}-unaccent":
          database => $db_name,
          extname  => 'unaccent',
          require  => Postgresql::Db[$db_name],
        }
    }

    # some additional logging for the postgres master to help diagnose import
    # performance issues
    file { "/etc/postgresql/${pgversion}/main/logging.conf":
        ensure => 'present',
        owner  => 'root',
        group  => 'root',
        mode   => '0444',
        source => 'puppet:///modules/profile/maps/logging.conf',
    }

    file { '/usr/local/bin/osm-initial-import':
        ensure => 'present',
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
        source => 'puppet:///modules/profile/maps/osm-initial-import',
    }

    if $postgres_slaves {
        $postgres_slaves_defaults = {
            replication_pass => $replication_pass,
        }
        create_resources(postgresql::slave_users, $postgres_slaves, $postgres_slaves_defaults)
    }

    sudo::user { 'tilerator-notification':
        user       => 'osmupdater',
        privileges => [
            'ALL = (tileratorui) NOPASSWD: /usr/local/bin/notify-tilerator',
        ],
    }

    if $cleartables {
        osm::cleartables_sync { $db_name:
            ensure                   => present,
            use_proxy                => $use_proxy,
            proxy_host               => "webproxy.${::site}.wmnet",
            proxy_port               => 8080,
            postreplicate_command    => 'sudo -u tileratorui /usr/local/bin/notify-tilerator',
            disable_replication_cron => $disable_replication_cron,
        }
    } else {
        osm::planet_sync { $db_name:
            ensure                   => present,
            flat_nodes               => true,
            expire_levels            => '15',
            num_threads              => 4,
            use_proxy                => $use_proxy,
            proxy_host               => "webproxy.${::site}.wmnet",
            proxy_port               => 8080,
            period                   => $planet_sync_period,
            day                      => $planet_sync_day,
            hour                     => $planet_sync_hour,
            minute                   => $planet_sync_minute,
            postreplicate_command    => 'sudo -u tileratorui /usr/local/bin/notify-tilerator',
            disable_replication_cron => $disable_replication_cron,
        }
        osm::populate_admin { $db_name:
            ensure             => present,
            disable_admin_cron => $disable_admin_cron,
        }
    }

    class { 'tilerator::regen':
        storage_id => $tilerator_storage_id,
    }

    class { 'osm::prometheus':
        state_path      => '/srv/osmosis/state.txt',
        prometheus_path => '/var/lib/prometheus/node.d/osm_sync_lag.prom',
    }

    # Access to postgres master from postgres slaves
    ferm::service { 'postgres_maps':
        proto  => 'tcp',
        port   => '5432',
        srange => "@resolve((${maps_hosts_ferm}))",
    }

}