Defined Type: elasticsearch::template

Defined in:
manifests/template.pp

Overview

This define allows you to insert, update or delete Elasticsearch index

templates.

Template content should be defined through either the `content` parameter
(when passing a hash or json string) or the `source` parameter (when passing
the puppet file URI to a template json file).

Parameters:

  • ensure (String) (defaults to: 'present')

    Controls whether the named index template should be present or absent in the cluster.

  • api_basic_auth_password (String) (defaults to: $elasticsearch::api_basic_auth_password)

    HTTP basic auth password to use when communicating over the Elasticsearch API.

  • api_basic_auth_username (String) (defaults to: $elasticsearch::api_basic_auth_username)

    HTTP basic auth username to use when communicating over the Elasticsearch API.

  • api_ca_file (String) (defaults to: $elasticsearch::api_ca_file)

    Path to a CA file which will be used to validate server certs when communicating with the Elasticsearch API over HTTPS.

  • api_ca_path (String) (defaults to: $elasticsearch::api_ca_path)

    Path to a directory with CA files which will be used to validate server certs when communicating with the Elasticsearch API over HTTPS.

  • api_host (String) (defaults to: $elasticsearch::api_host)

    Host name or IP address of the ES instance to connect to.

  • api_port (Integer) (defaults to: $elasticsearch::api_port)

    Port number of the ES instance to connect to

  • api_protocol (String) (defaults to: $elasticsearch::api_protocol)

    Protocol that should be used to connect to the Elasticsearch API.

  • api_timeout (Integer) (defaults to: $elasticsearch::api_timeout)

    Timeout period (in seconds) for the Elasticsearch API.

  • content (Enum[String, Hash]) (defaults to: undef)

    Contents of the template. Can be either a puppet hash or a string containing JSON.

  • source (String) (defaults to: undef)

    Source path for the template file. Can be any value similar to ‘source` values for `file` resources.

  • validate_tls (Boolean) (defaults to: $elasticsearch::validate_tls)

    Determines whether the validity of SSL/TLS certificates received from the Elasticsearch API should be verified or ignored.

Author:

  • Richard Pijnenburg <richard.pijnenburg@elasticsearch.com>

  • Tyler Langlois <tyler.langlois@elastic.co>



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
# File 'manifests/template.pp', line 55

define elasticsearch::template (
  $ensure                  = 'present',
  $api_basic_auth_password = $elasticsearch::api_basic_auth_password,
  $api_basic_auth_username = $elasticsearch::api_basic_auth_username,
  $api_ca_file             = $elasticsearch::api_ca_file,
  $api_ca_path             = $elasticsearch::api_ca_path,
  $api_host                = $elasticsearch::api_host,
  $api_port                = $elasticsearch::api_port,
  $api_protocol            = $elasticsearch::api_protocol,
  $api_timeout             = $elasticsearch::api_timeout,
  $content                 = undef,
  $source                  = undef,
  $validate_tls            = $elasticsearch::validate_tls,
) {
  if ! defined(Class['elasticsearch']) {
    fail('You must include the elasticsearch base class before using defined resources')
  }

  validate_string(
    $api_protocol,
    $api_host,
    $api_basic_auth_username,
    $api_basic_auth_password
  )
  validate_bool($validate_tls)

  if ! ($ensure in ['present', 'absent']) {
    fail("'${ensure}' is not a valid 'ensure' parameter value")
  }
  if ! is_integer($api_port)    { fail('"api_port" is not an integer') }
  if ! is_integer($api_timeout) { fail('"api_timeout" is not an integer') }
  if ($api_ca_file != undef) { validate_absolute_path($api_ca_file) }
  if ($api_ca_path != undef) { validate_absolute_path($api_ca_path) }

  if $source != undef { validate_string($source) }

  if $content != undef and is_string($content) {
    $_content = parsejson($content)
  } else {
    $_content = $content
  }

  if $ensure == 'present' and $source == undef and $_content == undef {
    fail('one of "file" or "content" required.')
  } elsif $source != undef and $_content != undef {
    fail('"file" and "content" cannot be simultaneously defined.')
  }

  es_instance_conn_validator { "${name}-template":
    server  => $api_host,
    port    => $api_port,
    timeout => $api_timeout,
  }
  -> elasticsearch_template { $name:
    ensure       => $ensure,
    content      => $_content,
    source       => $source,
    protocol     => $api_protocol,
    host         => $api_host,
    port         => $api_port,
    timeout      => $api_timeout,
    username     => $api_basic_auth_username,
    password     => $api_basic_auth_password,
    ca_file      => $api_ca_file,
    ca_path      => $api_ca_path,
    validate_tls => $validate_tls,
  }
}