Defined Type: osm::planet_sync

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

Overview

Definition: osm::planet_sync

This definition provides a way to sync planet_osm in a gis enabled db

Parameters:

$pg_password
   PostgreSQL password
$ensure
   present or absent, just like for standard resources
$osmosis_dir
   Directory that stores osmosis data, including replication state
$expire_dir
   Directory for expiry files
$period
   OSM replication interval: 'minute', 'hour' or 'day'
$hour
   Hour for cronjob, format is the same as for cron resource
$minute
   Minute for cronjob, format is the same as for cron resource
$proxy
   Web proxy for accessing the outside of the cluster
$flat_nodes
   Whether osm2pgsql --flat-nodes parameter should be used
$expire_levels
   For which levels should expiry files be generated. Corresponds to
   osm2pgslq option -e and can be in format "<level>" or
   "<from level>-<to level>"
$memory_limit
   Memory in megabytes osm2pgsql should occupy
$num_threads
   Number of threads to use during sync
$input_reader_format
   Format passed to osm2pgsql as --input-reader parameter. osm2pgsql < 0.90
   needs 'libxml2' (which is default) and osm2pgsql >= 0.90 needs 'xml'.
   osm2pgsql == 0.90 is used on jessie only at this point.
$postreplicate_command
   command to run after replication of OSM data
$disable_replication_cron
   usefull to disable replication, for example during a full tile regeneration

Actions:

sync with planet.osm

Requires:

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

Sample Usage:

osm::planet_sync { 'mydb': }

Parameters:

  • use_proxy (Boolean)
  • proxy_host (String)
  • proxy_port (Stdlib::Port)
  • ensure (Wmflib::Ensure) (defaults to: present)
  • osmosis_dir (String) (defaults to: '/srv/osmosis')
  • expire_dir (String) (defaults to: '/srv/osm_expire')
  • period (String) (defaults to: 'minute')
  • hours (Variant[String, Array[Integer]]) (defaults to: [])
  • day (String) (defaults to: '*')
  • minute (String) (defaults to: '*/30')
  • flat_nodes (Boolean) (defaults to: false)
  • expire_levels (String) (defaults to: '15')
  • memory_limit (Integer) (defaults to: /)
  • num_threads (Integer) (defaults to: $::processorcount)
  • input_reader_format (String) (defaults to: 'xml')
  • postreplicate_command (Optional[String]) (defaults to: undef)
  • disable_replication_cron (Boolean) (defaults to: false)


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

define osm::planet_sync (
    Boolean $use_proxy,
    String $proxy_host,
    Stdlib::Port $proxy_port,
    Wmflib::Ensure $ensure                  = present,
    String $osmosis_dir                     = '/srv/osmosis',
    String $expire_dir                      = '/srv/osm_expire',
    String $period                          = 'minute',
    Variant[String, Array[Integer]] $hours  = [],
    String $day                             = '*',
    String $minute                          = '*/30',
    Boolean $flat_nodes                     = false,
    String $expire_levels                   = '15',
    Integer $memory_limit                   = floor($::memorysize_mb) / 12,
    Integer $num_threads                    = $::processorcount,
    String $input_reader_format             = 'xml',
    Optional[String] $postreplicate_command = undef,
    Boolean $disable_replication_cron       = false,
) {
    include ::osm::users

    $osm_log_dir = '/var/log/osmosis'

    file { '/srv/downloads':
        ensure => 'directory',
        owner  => 'osmupdater',
        group  => 'osm',
        mode   => '0775',
    }

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

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

    file { '/usr/local/bin/replicate-osm':
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0555',
        content => template('osm/replicate-osm.erb'),
    }

    file { "${osmosis_dir}/configuration.txt":
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => template('osm/osmosis_configuration.txt.erb'),
    }

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

    logrotate::conf { 'planetsync':
        ensure  => present,
        content => template('osm/planetsync-logrotate.conf.erb'),
    }

    file { "${osmosis_dir}/nodes.bin":
        ensure => present,
        owner  => 'osmupdater',
        group  => 'osm',
        mode   => '0775',
    }

    $ensure_cron = $disable_replication_cron ? {
        true    => absent,
        default => $ensure,
    }

    cron { "planet_sync-${name}":
        ensure   => $ensure_cron,
        command  => "/usr/local/bin/replicate-osm >> ${osm_log_dir}/osm2pgsql.log 2>&1",
        user     => 'osmupdater',
        monthday => $day,
        hour     => $hours,
        minute   => $minute,
    }

    cron { "expire_old_planet_syncs-${name}":
        ensure  => $ensure,
        command => "/usr/bin/find ${expire_dir} -mtime +30 -type f -exec rm {} \\;",
        user    => 'osmupdater',
        hour    => $hours,
        minute  => $minute,
    }
}