Puppet Class: elasticsearch
- Defined in:
- manifests/init.pp
Summary
Manages the installation of Elasticsearch and related options.Overview
Top-level Elasticsearch class which may manage installation of the Elasticsearch package, package repository, and other global options and parameters.
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 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
# File 'manifests/init.pp', line 350
class elasticsearch (
Enum['absent', 'present'] $ensure,
Optional[String] $api_basic_auth_password,
Optional[String] $api_basic_auth_username,
Optional[String] $api_ca_file,
Optional[String] $api_ca_path,
String $api_host,
Integer[0, 65535] $api_port,
Enum['http', 'https'] $api_protocol,
Integer $api_timeout,
Boolean $autoupgrade,
Hash $config,
Stdlib::Absolutepath $configdir,
Integer $configdir_recurselimit,
String $daily_rolling_date_pattern,
Elasticsearch::Multipath $datadir,
Optional[Stdlib::Absolutepath] $defaults_location,
Boolean $deprecation_logging,
String $deprecation_logging_level,
Optional[String] $download_tool,
Optional[String] $download_tool_insecure,
Boolean $download_tool_verify_certificates,
String $elasticsearch_group,
String $elasticsearch_user,
Enum['dailyRollingFile', 'rollingFile', 'file'] $file_rolling_type,
Stdlib::Absolutepath $homedir,
Hash $indices,
Hash $init_defaults,
Optional[String] $init_defaults_file,
String $init_template,
Array[String] $jvm_options,
Optional[Variant[String, Hash]] $license,
Stdlib::Absolutepath $logdir,
Hash $logging_config,
Optional[String] $logging_file,
String $logging_level,
Optional[String] $logging_template,
Boolean $manage_datadir,
Boolean $manage_logdir,
Boolean $manage_repo,
Boolean $oss,
Stdlib::Absolutepath $package_dir,
Integer $package_dl_timeout,
String $package_name,
Enum['package'] $package_provider,
Optional[String] $package_url,
Optional[Stdlib::Absolutepath] $pid_dir,
Hash $pipelines,
Optional[Stdlib::Absolutepath] $plugindir,
Hash $plugins,
Optional[Stdlib::HTTPUrl] $proxy_url,
Boolean $purge_configdir,
Boolean $purge_package_dir,
Boolean $purge_secrets,
Variant[Boolean, String] $repo_stage,
Boolean $restart_on_change,
Hash $roles,
Integer $rolling_file_max_backup_index,
String $rolling_file_max_file_size,
Hash $scripts,
Optional[Hash] $secrets,
Optional[String] $security_logging_content,
Optional[String] $security_logging_source,
String $service_name,
Enum['init', 'openbsd', 'openrc', 'systemd'] $service_provider,
Hash $snapshot_repositories,
Boolean $ssl,
Elasticsearch::Status $status,
Optional[String] $system_key,
Stdlib::Absolutepath $systemd_service_path,
Hash $templates,
Hash $users,
Boolean $validate_tls,
Variant[String, Boolean] $version,
Hash $index_templates = {},
Hash $component_templates = {},
Hash $ilm_policies = {},
Hash $slm_policies = {},
Optional[Stdlib::Absolutepath] $ca_certificate = undef,
Optional[Stdlib::Absolutepath] $certificate = undef,
String $default_logging_level = $logging_level,
Optional[String] $keystore_password = undef,
Optional[Stdlib::Absolutepath] $keystore_path = undef,
Optional[Stdlib::Absolutepath] $private_key = undef,
Enum['rsa','dsa','ec'] $private_key_type = 'rsa',
Boolean $restart_config_change = $restart_on_change,
Boolean $restart_package_change = $restart_on_change,
Boolean $restart_plugin_change = $restart_on_change,
Stdlib::Filemode $logdir_mode = '2750',
) {
#### Validate parameters
if ($package_url != undef and $version != false) {
fail('Unable to set the version number when using package_url option.')
}
if ($version != false) {
case $facts['os']['family'] {
'RedHat', 'Linux', 'Suse': {
if ($version =~ /.+-\d/) {
$pkg_version = $version
} else {
$pkg_version = "${version}-1"
}
}
default: {
$pkg_version = $version
}
}
}
# This value serves as an unchanging default for platforms as a default for
# init scripts to fallback on.
$_datadir_default = $facts['kernel'] ? {
'Linux' => '/var/lib/elasticsearch',
'OpenBSD' => '/var/elasticsearch/data',
default => undef,
}
# The OSS package distribution's package appends `-oss` to the end of the
# canonical package name.
$_package_name = $oss ? {
true => "${package_name}-oss",
default => $package_name,
}
# Set the plugin path variable for use later in the module.
if $plugindir == undef {
$real_plugindir = "${homedir}/plugins"
} else {
$real_plugindir = $plugindir
}
# Should we restart Elasticsearch on config change?
$_notify_service = $elasticsearch::restart_config_change ? {
true => Service[$elasticsearch::service_name],
false => undef,
}
#### Manage actions
contain elasticsearch::package
contain elasticsearch::config
contain elasticsearch::service
create_resources('elasticsearch::index', $elasticsearch::indices)
create_resources('elasticsearch::pipeline', $elasticsearch::pipelines)
create_resources('elasticsearch::plugin', $elasticsearch::plugins)
create_resources('elasticsearch::role', $elasticsearch::roles)
create_resources('elasticsearch::script', $elasticsearch::scripts)
create_resources('elasticsearch::snapshot_repository', $elasticsearch::snapshot_repositories)
create_resources('elasticsearch::template', $elasticsearch::templates)
$elasticsearch::component_templates.each |String $key, Hash $values| {
elasticsearch::component_template { $key:
* => $values,
}
}
$elasticsearch::index_templates.each |String $key, Hash $values| {
elasticsearch::index_template { $key:
* => $values,
}
}
$elasticsearch::ilm_policies.each |String $key, Hash $values| {
elasticsearch::ilm_policy { $key:
* => $values,
}
}
$elasticsearch::slm_policies.each |String $key, Hash $values| {
elasticsearch::slm_policy { $key:
* => $values,
}
}
create_resources('elasticsearch::user', $elasticsearch::users)
if ($manage_repo == true) {
if ($repo_stage == false) {
# Use normal relationship ordering
contain elastic_stack::repo
Class['elastic_stack::repo']
-> Class['elasticsearch::package']
} else {
# Use staging for ordering
if !(defined(Stage[$repo_stage])) {
stage { $repo_stage: before => Stage['main'] }
}
include elastic_stack::repo
Class<|title == 'elastic_stack::repo'|> {
stage => $repo_stage,
}
}
}
if ($license != undef) {
contain elasticsearch::license
}
#### Manage relationships
#
# Note that many of these overly verbose declarations work around
# https://tickets.puppetlabs.com/browse/PUP-1410
# which means clean arrow order chaining won't work if someone, say,
# doesn't declare any plugins.
#
# forgive me for what you're about to see
if defined(Class['java']) { Class['java'] -> Class['elasticsearch::config'] }
if $ensure == 'present' {
# Installation, configuration and service
Class['elasticsearch::package']
-> Class['elasticsearch::config']
if $restart_config_change {
Class['elasticsearch::config'] ~> Class['elasticsearch::service']
} else {
Class['elasticsearch::config'] -> Class['elasticsearch::service']
}
# Top-level ordering bindings for resources.
Class['elasticsearch::config']
-> Elasticsearch::Plugin <| ensure == 'present' or ensure == 'installed' |>
Elasticsearch::Plugin <| ensure == 'absent' |>
-> Class['elasticsearch::config']
Class['elasticsearch::config']
-> Elasticsearch::User <| ensure == 'present' |>
# Elasticsearch::User <| ensure == 'absent' |>
# -> Class['elasticsearch::config']
# Class['elasticsearch::config']
# -> Elasticsearch::Role <| |>
Class['elasticsearch::config']
-> Elasticsearch::Template <| |>
Class['elasticsearch::config']
-> Elasticsearch::Pipeline <| |>
Class['elasticsearch::config']
-> Elasticsearch::Index <| |>
Class['elasticsearch::config']
-> Elasticsearch::Snapshot_repository <| |>
} else {
# Absent; remove configuration before the package.
Class['elasticsearch::config']
-> Class['elasticsearch::package']
# Top-level ordering bindings for resources.
Elasticsearch::Plugin <| |>
-> Class['elasticsearch::config']
Elasticsearch::User <| |>
-> Class['elasticsearch::config']
Elasticsearch::Role <| |>
-> Class['elasticsearch::config']
Elasticsearch::Template <| |>
-> Class['elasticsearch::config']
Elasticsearch::Pipeline <| |>
-> Class['elasticsearch::config']
Elasticsearch::Index <| |>
-> Class['elasticsearch::config']
Elasticsearch::Snapshot_repository <| |>
-> Class['elasticsearch::config']
}
# Install plugins before managing users/roles
Elasticsearch::Plugin <| ensure == 'present' or ensure == 'installed' |>
-> Elasticsearch::User <| |>
Elasticsearch::Plugin <| ensure == 'present' or ensure == 'installed' |>
-> Elasticsearch::Role <| |>
# Remove plugins after managing users/roles
Elasticsearch::User <| |>
-> Elasticsearch::Plugin <| ensure == 'absent' |>
Elasticsearch::Role <| |>
-> Elasticsearch::Plugin <| ensure == 'absent' |>
# Ensure roles are defined before managing users that reference roles
Elasticsearch::Role <| |>
-> Elasticsearch::User <| ensure == 'present' |>
# Ensure users are removed before referenced roles are managed
Elasticsearch::User <| ensure == 'absent' |>
-> Elasticsearch::Role <| |>
# Ensure users and roles are managed before calling out to REST resources
Elasticsearch::Role <| |>
-> Elasticsearch::Template <| |>
Elasticsearch::User <| |>
-> Elasticsearch::Template <| |>
Elasticsearch::Role <| |>
-> Elasticsearch::Pipeline <| |>
Elasticsearch::User <| |>
-> Elasticsearch::Pipeline <| |>
Elasticsearch::Role <| |>
-> Elasticsearch::Index <| |>
Elasticsearch::User <| |>
-> Elasticsearch::Index <| |>
Elasticsearch::Role <| |>
-> Elasticsearch::Snapshot_repository <| |>
Elasticsearch::User <| |>
-> Elasticsearch::Snapshot_repository <| |>
# Ensure that any command-line based user changes are performed before the
# file is modified
Elasticsearch_user <| |>
-> Elasticsearch_user_file <| |>
# Ensure component templates are loaded before index templates
Elasticsearch_component_template <| |>
-> Elasticsearch_index_template <| |>
# Ensure ILM policies are loaded before index or component templates
Elasticsearch_ilm_policy <| |>
-> Elasticsearch_component_template <| |>
Elasticsearch_ilm_policy <| |>
-> Elasticsearch_index_template <| |>
# Ensure snapshot repositories are loaded before SLM policies
Elasticsearch::Snapshot_repository <| |>
-> Elasticsearch_slm_policy <| |>
}
|