Defined Type: osm::planet_sync

Defined in:
modules/osm/manifests/planet_sync.pp

Overview

SPDX-License-Identifier: Apache-2.0

Definition: osm::planet_sync

This definition provides a way to sync planet_osm in a gis enabled db Important: it's required to select whitch replication tool will be used: imposm3 or osm2pgsql

Parameters:

$engine
    Engine to use for syncing - either osm2pgsql or imposm3
$use_proxy
    present or absent, just like for standard resources
$proxy_host
    present or absent, just like for standard resources
$proxy_port
    present or absent, just like for standard resources
$ensure
    present or absent, just like for standard resources
$expire_dir
    Directory for expiry files
$download_dir
    Directory for downloaded files
$period
    OSM replication interval: 'minute', 'hour' or 'day'
$hours
    Hour for cronjob, format is the same as for cron resource
$day
    Day for cronjob, format is the same as for cron resource
$minute
    Minute for cronjob, format is the same as for cron resource
$flat_nodes
   [osm2pgsql] Whether osm2pgsql --flat-nodes parameter should be used
$expire_levels
    For which levels should expiry files be generated.
    [imposm] corresponds to
    [osm2pgsql] Corresponds to osm2pgslq option -e and can be in format "<level>" or
    "<from level>-<to level>"
$memory_limit
    [osm2pgsql] Memory in megabytes osm2pgsql should occupy
$num_threads
    [osm2pgsql] Number of threads to use during sync
$postreplicate_command
    command to run after replication of OSM data
$input_reader_format
    [osm2pgsql] Format passed to osm2pgsql as --input-reader parameter. osm2pgsql < 0.90
    needs 'libxml2' (which is default) and osm2pgsql >= 0.90 needs 'xml'.
$disable_replication_cron
    [imposm] disable OSM replication only because for imposm tile generation
    and OSM replication are decoupled
    [osm2pgsql] disables cron that executes OSM replication and tile generation
$disable_tile_generation_cron
    [imposm] disable cron that only run tile generation

Actions:

sync with planet.osm

Requires:

Class['postgresql::postgis']
define['postgresql::spatialdb']

Sample Usage:

osm::planet_sync { 'mydb': }

Parameters:

  • engine (Enum['osm2pgsql', 'imposm3'])
  • use_proxy (Boolean)
  • proxy_host (String)
  • swift_key_id (String)
  • swift_password (String)
  • tegola_swift_container (String)
  • proxy_port (Stdlib::Port)
  • ensure (Wmflib::Ensure) (defaults to: present)
  • expire_dir (Stdlib::Unixpath) (defaults to: '/srv/osm_expire')
  • download_dir (Stdlib::Unixpath) (defaults to: '/srv/downloads')
  • period (String) (defaults to: 'minute')
  • hours (Variant[String,Integer]) (defaults to: '*')
  • day (Variant[String,Integer]) (defaults to: '*')
  • minute (Variant[String,Integer]) (defaults to: '*/30')
  • flat_nodes (Boolean) (defaults to: false)
  • expire_levels (Integer) (defaults to: 15)
  • memory_limit (Integer) (defaults to: /)
  • num_threads (Integer) (defaults to: $::processorcount)
  • postreplicate_command (Optional[String]) (defaults to: undef)
  • postreplicate_user (Optional[String]) (defaults to: 'osmupdater')
  • input_reader_format (String) (defaults to: 'xml')
  • disable_replication_cron (Boolean) (defaults to: false)
  • disable_tile_generation_cron (Boolean) (defaults to: false)
  • eventgate_endpoint (String) (defaults to: 'https://eventgate-main.discovery.wmnet:4492/v1/events')


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
# File 'modules/osm/manifests/planet_sync.pp', line 64

define osm::planet_sync (
    Enum['osm2pgsql', 'imposm3'] $engine,
    Boolean $use_proxy,
    String $proxy_host,
    String $swift_key_id,
    String $swift_password,
    String $tegola_swift_container,
    Stdlib::Port $proxy_port,
    Wmflib::Ensure $ensure                  = present,
    Stdlib::Unixpath $expire_dir            = '/srv/osm_expire',
    Stdlib::Unixpath $download_dir          = '/srv/downloads',
    String $period                          = 'minute',
    Variant[String,Integer] $hours          = '*',
    Variant[String,Integer] $day            = '*',
    Variant[String,Integer] $minute         = '*/30',
    Boolean $flat_nodes                     = false,
    Integer $expire_levels                  = 15,
    Integer $memory_limit                   = floor($::memorysize_mb) / 12,
    Integer $num_threads                    = $::processorcount,
    Optional[String] $postreplicate_command = undef,
    Optional[String] $postreplicate_user    = 'osmupdater',
    String $input_reader_format             = 'xml',
    Boolean $disable_replication_cron       = false,
    Boolean $disable_tile_generation_cron   = false,
    String $eventgate_endpoint              = 'https://eventgate-main.discovery.wmnet:4492/v1/events',
) {
    include ::osm::users

    file { $download_dir:
        ensure => 'directory',
        owner  => 'osmupdater',
        group  => 'osm',
        mode   => '0775',
    }

    file { $expire_dir:
        ensure => directory,
        owner  => 'osmupdater',
        group  => 'osm',
        mode   => '0775',
    }

    $osm_log_dir = $engine ? {
        'imposm3' => '/var/log/imposm',
        'osm2pgsql' => '/var/log/osmosis'
    }

    $osm_log_file = $engine ? {
        'imposm3' => 'imposm.log',
        'osm2pgsql' => 'osm2pgsql.log'
    }

    $tile_generation_command = $engine ? {
        'imposm3' => $postreplicate_command,
        'osm2pgsql' => '/usr/local/bin/replicate-osm'
    }

    case $engine {
        'imposm3': {
            class { 'osm::imposm3':
                ensure                   => $ensure,
                proxy_host               => $proxy_host,
                proxy_port               => $proxy_port,
                osm_log_dir              => $osm_log_dir,
                expire_dir               => $expire_dir,
                expire_levels            => $expire_levels,
                disable_replication_cron => $disable_replication_cron,
                eventgate_endpoint       => $eventgate_endpoint,
                swift_key_id             => $swift_key_id,
                swift_password           => $swift_password,
                tegola_swift_container   => $tegola_swift_container
            }
        }
        'osm2pgsql': {
            class { 'osm::osm2pgsql':
                use_proxy           => $use_proxy,
                proxy_host          => $proxy_host,
                proxy_port          => $proxy_port,
                osm_log_dir         => $osm_log_dir,
                flat_nodes          => $flat_nodes,
                period              => $period,
                expire_dir          => $expire_dir,
                expire_levels       => $expire_levels,
                memory_limit        => $memory_limit,
                num_threads         => $num_threads,
                input_reader_format => $input_reader_format,
            }
        }
        default: {
            fail("Unsupported sync engine ${engine}")
        }
    }

    file { $osm_log_dir:
        ensure => directory,
        owner  => 'osmupdater',
        group  => 'osmupdater',
        mode   => '0755',
    }

    if $tile_generation_command {
        $ensure_timer = $disable_tile_generation_cron ? {
            true    => absent,
            default => $ensure,
        }

        systemd::timer::job { "planet_sync_tile_generation-${name}":
            ensure          => $ensure_timer,
            description     => "Run plant sync tile generation for ${name}",
            user            => $postreplicate_user,
            command         => $tile_generation_command,
            logfile_basedir => $osm_log_dir,
            logfile_name    => $osm_log_file,
            interval        => {'start' => 'OnCalendar', 'interval' => "*-*-${day} ${hours}:${minute}:00"},
        }
    }

    systemd::timer::job { "expire_old_planet_syncs-${name}":
        ensure      => $ensure,
        description => "Expire old planet syncs for ${name}",
        user        => 'osmupdater',
        command     => "/usr/bin/find ${expire_dir} -mtime +30 -type f -delete",
        interval    => {'start' => 'OnCalendar', 'interval' => "*-*-* ${hours}:${minute}:00"}
    }
}