Defined Type: graphdb::instance

Defined in:
manifests/instance.pp

Summary

This define allows you to create or remove an graphdb instance

Overview

Parameters:

  • ensure (Graphdb::Ensure) (defaults to: $graphdb::ensure)

    String. Controls if the managed resources shall be present or absent. If set to absent:

    • The managed instance is being uninstalled.

    • Any traces of installation will be purged as good as possible. This may include existing configuration files. The exact behavior is provider dependent. Q.v.:

    • System modifications (if any) will be reverted as good as possible (e.g. removal of created users, services, changed log settings, …).

    • This is thus destructive and should be used with care.

    Defaults to present.

  • external_url (Optional[String]) (defaults to: undef)

    GraphDB external URL if GraphDB instance is accessed via proxy

  • extra_properties (Hash) (defaults to: {})

    Hash of properties to include in graphdb.properties file example: => ‘some.property.value’

  • heap_size (Optional[String]) (defaults to: undef)

    GraphDB java heap size given by -Xmx parameter. Note heap_size parameter will also set xms=xmx

  • http_port (Integer) (defaults to: 8080)

    The http port at which GraphDB will run.

  • java_opts (Array) (defaults to: [])

    Array of java options to give to GraphDB java process example: [‘-Xmx1g’, ‘-Xms1g’]

  • jolokia_access_link (Boolean) (defaults to: versioncmp($graphdb::ensure, '9.10.0') > -1)

    Add jolokia-access.xml link

  • kill_timeout (Integer) (defaults to: 180)

    Time before force kill of GraphDB process. Instances with big repositories may time to flush on shutdown. default: 180

  • license (Optional[String]) (defaults to: undef)

    GraphDB license file.

  • logback_config (Optional[String]) (defaults to: undef)

    GraphDB logback log configuration

  • protocol (String) (defaults to: 'http')

    A string, either ‘http’ or ‘https defining under what protocol to connect to GraphDB’

  • status (Graphdb::Status) (defaults to: $graphdb::status)

    String to define the status of the service. Possible values:

    • enabled: Service is running and will be started at boot time.

    • disabled: Service is stopped and will not be started at boot time.

    • running: Service is running but will not be started at boot time. You can use this to start a service on the first Puppet run instead of the system startup.

    • unmanaged: Service will not be started at boot time and Puppet does not care whether the service is running or not. For example, this may be useful if a cluster management software is used to decide when to start the service plus assuring it is running on the desired node.

    Defaults to enabled. The singular form (“service”) is used for the sake of convenience. Of course, the defined status affects all services if more than one is managed (see service.pp to check if this is the case).

  • validator_test_enabled (Boolean) (defaults to: true)

    GraphDB validator

  • validator_timeout (Integer) (defaults to: 60)

    Time before GraphDB validator decides that the GraphDB instance is not running



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
189
190
191
192
193
194
195
196
197
198
# File 'manifests/instance.pp', line 74

define graphdb::instance (
  Graphdb::Ensure   $ensure                 = $graphdb::ensure,
  Optional[String]  $external_url           = undef,
  Hash              $extra_properties       = {},
  Optional[String]  $heap_size              = undef,
  Integer           $http_port              = 8080,
  Array             $java_opts              = [],
  Boolean           $jolokia_access_link    = versioncmp($graphdb::ensure, '9.10.0') > -1,
  Integer           $kill_timeout           = 180,
  Optional[String]  $license                = undef,
  Optional[String]  $logback_config         = undef,
  String            $protocol               = 'http',
  Graphdb::Status   $status                 = $graphdb::status,
  Boolean           $validator_test_enabled = true,
  Integer           $validator_timeout      = 60,
) {
  if $heap_size {
    $heap_size_array = ["-Xmx${heap_size}", "-Xms${heap_size}"]

    if $external_url {
      $java_opts_final = concat($java_opts, $heap_size_array, ["-Dgraphdb.workbench.external-url=${external_url}"])
    } else {
      $java_opts_final = concat($java_opts, $heap_size_array)
    }
  } else {
    $java_opts_final = $java_opts
  }

  $service_name = "graphdb-${title}"

  $instance_home_dir = "${graphdb::install_dir}/instances/${title}"
  $instance_data_dir = "${graphdb::data_dir}/${title}"
  $instance_plugins_dir = "${instance_data_dir}/plugins"
  $instance_temp_dir = "${graphdb::tmp_dir}/${title}"
  $instance_conf_dir = "${instance_home_dir}/conf"
  $instance_log_dir = "${graphdb::log_dir}/${title}"

  if $ensure == 'present' {
    File {
      owner => $graphdb::graphdb_user,
      group => $graphdb::graphdb_group,
    }

    $license_file_name = basename($license)
    $licence_file_destination = "${instance_home_dir}/${license_file_name}"

    file { $licence_file_destination:
      ensure => $ensure,
      source => $license,
      mode   => '0555',
      notify => Service[$service_name],
    }

    file { [$instance_home_dir, $instance_data_dir, $instance_plugins_dir,
      $instance_temp_dir, $instance_conf_dir, $instance_log_dir]:
        ensure => 'directory',
        notify => Service[$service_name],
    }

    if $logback_config {
      file { "${instance_conf_dir}/logback.xml":
        ensure => $ensure,
        source => $logback_config,
      }
    } else {
      file { "${instance_conf_dir}/logback.xml":
        ensure => 'link',
        target => "${graphdb::install_dir}/dist/conf/logback.xml",
      }
    }

    file { "${instance_conf_dir}/tools-logback.xml":
      ensure => 'link',
      target => "${graphdb::install_dir}/dist/conf/tools-logback.xml",
    }

    if $jolokia_access_link {
      file { "${instance_conf_dir}/jolokia-access.xml":
        ensure => 'link',
        target => "${graphdb::install_dir}/dist/conf/jolokia-access.xml",
      }
    }

    $default_properties = {
      'graphdb.home.data'      => "${graphdb::data_dir}/${title}",
      'graphdb.home.logs'      => $instance_log_dir,
      'graphdb.license.file'   => $licence_file_destination,
      'graphdb.connector.port' => $http_port,
      'graphdb.extra.plugins'  => $instance_plugins_dir,
      'graphdb.workbench.importDirectory' => $graphdb::import_dir,
    }

    file { "${instance_home_dir}/conf/graphdb.properties":
      ensure  => $ensure,
      content => Sensitive(epp("${module_name}/config/graphdb.properties.epp",
      { properties => merge($default_properties, $extra_properties) })),
      notify  => Service[$service_name],
    }

    if $validator_test_enabled {
      #$ipaddress = $facts['ipaddress'] # lint:ignore:legacy_facts
      $ipaddress = $facts['networking']['ip']
      graphdb_validator { $service_name:
        endpoint  => "${protocol}://${ipaddress}:${http_port}",
        timeout   => $validator_timeout,
        subscribe => Service[$service_name],
      }
    }
  } else {
    file { [$instance_home_dir, $instance_data_dir, $instance_plugins_dir, $instance_temp_dir, $instance_log_dir]:
      ensure  => 'absent',
      force   => true,
      backup  => false,
      recurse => true,
    }
  }

  graphdb::service { $title:
    ensure       => $ensure,
    status       => $status,
    java_opts    => $java_opts_final,
    kill_timeout => $kill_timeout,
    subscribe    => Exec['unpack-graphdb-archive'],
  }
}