Puppet Class: barman
- Defined in:
- manifests/init.pp
Overview
Authors
-
Giuseppe Broccolo <giuseppe.broccolo@2ndQuadrant.it>
-
Giulio Calacoci <giulio.calacoci@2ndQuadrant.it>
-
Francesco Canovai <francesco.canovai@2ndQuadrant.it>
-
Marco Nenciarini <marco.nenciarini@2ndQuadrant.it>
-
Gabriele Bartolini <gabriele.bartolini@2ndQuadrant.it>
-
Alessandro Grassi <alessandro.grassi@2ndQuadrant.it>
Many thanks to Alessandro Franceschi <al@lab42.it>
Copyright
Copyright 2012-2017 2ndQuadrant Italia
This option allows you to enable data compression for network transfers. Defaults to false. One or more absolute paths, separated by colon, where Barman
looks for executable files.
Hook script launched after a WAL file is
archived by maintenance. Being this a retry hook
script, Barman will retry the execution of the
script until this either returns a SUCCESS (0),
an ABORT_CONTINUE (62) or an ABORT_STOP (63)
code. In a post archive scenario, ABORT_STOP has
currently the same effects as ABORT_CONTINUE.
Hook script launched after a WAL file is archived by
maintenance, after 'post_archive_retry_script'.
Hook script launched after a base backup. Being
this a retry hook script, Barman will retry the
execution of the script until this either returns
a SUCCESS (0), an ABORT_CONTINUE (62) or an
ABORT_STOP (63) code. In a post backup scenario,
ABORT_STOP has currently the same effects as
ABORT_CONTINUE.
Hook script launched after a base backup, after
'post_backup_retry_script'.
Hook script launched before a WAL file is
archived by maintenance, after
'pre_archive_script'. Being this a retry hook
script, Barman will retry the execution of the
script until this either returns a SUCCESS (0),
an ABORT_CONTINUE (62) or an ABORT_STOP (63)
code. Returning ABORT_STOP will propagate the
failure at a higher level and interrupt the WAL
archiving operation.
Hook script launched before a WAL file is archived by maintenance. Hook script launched before a base backup, after
'pre_backup_script'. Being this a retry hook
script, Barman will retry the execution of the
script until this either returns a SUCCESS (0), an
ABORT_CONTINUE (62) or an ABORT_STOP (63) code.
Returning ABORT_STOP will propagate the failure at
a higher level and interrupt the backup operation.
Hook script launched before a base backup. Base backup retention policy, based on redundancy or
recovery window. Default empty (no retention enforced).
Value must be greater than or equal to the server
minimum redundancy level (if not is is assigned to
that value and a warning is generated).
WAL archive logs retention policy. Currently, the
only allowed value for wal_retention_policy is the
special value main, that maps the retention policy
of archive logs to that of base backups.
Can only be set to auto (retention policies are
automatically enforced by the barman cron command)
Incremental backup is a kind of full periodic backup which
saves only data changes from the latest full backup
available in the catalogue for a specific PostgreSQL
server. Disabled if false. Default false.
Physical replication slot to be used by the receive-wal
command when streaming_archiver is set to on. Requires
postgreSQL >= 9.4. Default: undef (disabled).
This option allows you to use the PostgreSQL’s
streaming protocol to receive transaction logs from a
server. This activates connection checks as well as
management (including compression) of WAL files. If
set to off (default) barman will rely only on
continuous archiving for a server WAL archive
operations, eventually terminating any running
pg_receivexlog for the server.
This option allows you to activate batch
processing of WAL files for the
streaming_archiver process, by setting it to
a value > 0. Otherwise, the traditional
unlimited processing of the WAL queue is
enabled.
Identifier to be used as application_name by the
receive-wal command. Only available with
pg_receivexlog >= 9.3. By default it is set to
barman_receive_wal.
Identifier to be used as application_name by the
pg_basebackup command. Only available with
pg_basebackup >= 9.3. By default it is set to
barman_streaming_backup.
Directory where WAL files are streamed from the
PostgreSQL server to Barman.
This option allows you to specify a maximum
transfer rate in kilobytes per second, by
specifying a comma separated list of
tablespaces (pairs TBNAME:BWLIMIT). A value of
zero specifies no limit (default).
DEPRECATED. Custom configuration directives (e.g. for
custom compression). Defaults to empty.
The fqdn of the Barman server. It will be exported in
several resources in the PostgreSQL server. Puppet
automatically set this.
This is the main parameter to enable the
autoconfiguration of the backup of a given PostgreSQL
server. Defaults to false.
The ipaddress exported to the PostgreSQL server
during atutoconfiguration. Defaults to
"${::ipaddress}/32".
Configure PGDG repository. It is implemented
internally by declaring the `postgresql::globals`
class. If you need to customize the
`postgresql::globals` class declaration, keep the
`manage_package_repo` parameter disabled in `barman`
module and enable it directly in
`postgresql::globals` class.
When using autoconfigure, ensure the hosts contain
each other ssh host key. Must also be set on
'barman::postgres' class. Defaults to false.
Whether or not barman conf files not included in
puppetdb will be removed by puppet.
hiera hash to support the server define.
Defaults to undef.
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
# File 'manifests/init.pp', line 279
class barman (
String $user,
String $group,
String $ensure,
Boolean $archiver,
Boolean $autoconfigure,
Variant[String,Boolean] $compression,
String $dbuser,
Stdlib::Absolutepath $home,
String $home_mode,
String $host_group,
String $dbname,
Boolean $immediate_checkpoint,
Stdlib::Absolutepath $logfile,
Barman::LogLevel $log_level,
Boolean $manage_package_repo,
Boolean $manage_ssh_host_keys,
Integer $minimum_redundancy,
Boolean $purge_unknown_conf,
Boolean $streaming_archiver,
String $archive_cmd_type,
Integer $hba_entry_order,
String $conf_file_path = $barman::conf_file_path,
String $conf_template = 'barman/barman.conf.erb',
String $logrotate_template = 'barman/logrotate.conf.erb',
String $barman_fqdn = $facts['networking']['fqdn'],
Optional[Integer] $archiver_batch_size = undef,
Barman::BackupMethod $backup_method = undef,
Barman::BackupOptions $backup_options = undef,
Optional[Integer] $bandwidth_limit = undef,
Optional[String] $barman_lock_directory = undef,
Optional[Integer] $basebackup_retry_sleep = undef,
Optional[Integer] $basebackup_retry_times = undef,
Optional[Integer] $check_timeout = undef,
Barman::CreateSlot $create_slot = undef,
Optional[String] $custom_compression_filter = undef,
Optional[String] $custom_decompression_filter = undef,
Stdlib::IP::Address $exported_ipaddress = "${facts['networking']['ip']}/32",
Barman::BackupAge $last_backup_maximum_age = undef,
Barman::BackupAge $last_wal_maximum_age = undef,
Barman::BackupSize $last_backup_minimum_size = undef,
Optional[Boolean] $network_compression = undef,
Optional[Integer] $parallel_jobs = undef,
Optional[Stdlib::Absolutepath] $path_prefix = undef,
Optional[String] $post_archive_retry_script = undef,
Optional[String] $post_archive_script = undef,
Optional[String] $post_backup_retry_script = undef,
Optional[String] $post_backup_script = undef,
Optional[String] $pre_archive_retry_script = undef,
Optional[String] $pre_archive_script = undef,
Optional[String] $pre_backup_retry_script = undef,
Optional[String] $pre_backup_script = undef,
Barman::RecoveryOptions $recovery_options = undef,
Barman::RetentionPolicy $retention_policy = undef,
Barman::RetentionPolicyMode $retention_policy_mode = undef,
Barman::ReuseBackup $reuse_backup = undef,
Optional[String] $slot_name = undef,
Optional[Integer] $streaming_archiver_batch_size = undef,
Optional[String] $streaming_archiver_name = undef,
Optional[String] $streaming_backup_name = undef,
Optional[String] $tablespace_bandwidth_limit = undef,
Barman::WalRetention $wal_retention_policy = undef,
Optional[String] $custom_lines = undef,
Optional[Hash] $servers = undef,
Optional[Stdlib::Absolutepath] $streaming_wals_directory = undef,
) {
# when hash data is in servers, then fire-off barman::server define with that hash data
if ($servers) {
create_resources('barman::server', deep_merge(hiera_hash('barman::servers', {}), $servers))
}
# Ensure creation (or removal) of Barman files and directories
$ensure_file = $ensure ? {
'absent' => 'absent',
default => 'present',
}
$ensure_directory = $ensure ? {
'absent' => 'absent',
default => 'directory',
}
if $manage_package_repo {
if defined(Class['postgresql::globals']) {
fail('Class postgresql::globals is already defined. Set barman class manage_package_repo parameter to false (preferred) or remove the other definition.')
} else {
class { 'postgresql::globals':
manage_package_repo => true,
}
}
}
package { 'barman':
ensure => $ensure,
tag => 'postgresql',
}
file { '/etc/barman.d':
ensure => $ensure_directory,
purge => $purge_unknown_conf,
recurse => true,
owner => 'root',
group => $group,
mode => '0750',
require => Package['barman'],
}
if $conf_file_path == '/etc/barman/barman.conf' {
file { '/etc/barman':
ensure => $ensure_directory,
purge => $purge_unknown_conf,
recurse => true,
owner => 'root',
group => $group,
mode => '0750',
require => Package['barman'],
}
file { $conf_file_path:
ensure => $ensure_file,
owner => 'root',
group => $group,
mode => '0640',
content => template($conf_template),
require => File['/etc/barman'],
}
} else {
file { $conf_file_path:
ensure => $ensure_file,
owner => 'root',
group => $group,
mode => '0640',
content => template($conf_template),
}
}
file { $home:
ensure => $ensure_directory,
owner => $user,
group => $group,
mode => $home_mode,
require => Package['barman'],
}
if $manage_ssh_host_keys {
file { "${home}/.ssh":
ensure => directory,
owner => $user,
group => $group,
mode => '0700',
require => File[$home],
}
file { "${home}/.ssh/known_hosts":
ensure => file,
owner => $user,
group => $group,
mode => '0600',
}
}
# Run 'barman check all' to create Barman backup directories
exec { 'barman-check-all':
command => '/usr/bin/barman check all',
subscribe => File[$home],
refreshonly => true,
}
file { '/etc/logrotate.d/barman':
ensure => $ensure_file,
owner => 'root',
group => 0,
mode => '0644',
content => template($logrotate_template),
require => Package['barman'],
}
# Set the autoconfiguration
if $autoconfigure {
class { 'barman::autoconfigure':
exported_ipaddress => $exported_ipaddress,
host_group => $host_group,
archive_cmd_type => $archive_cmd_type,
}
}
}
|