Defined Type: graphdb::instance
- Defined in:
- manifests/instance.pp
Overview
Define: graphdb::instance
This define allows you to create or remove an graphdb instance
Parameters
- ensure
-
String. Controls if the managed resources shall be
present
orabsent
. If set toabsent
:-
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.:
-
Puppet type reference: package, “purgeable”
-
-
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
. -
- 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 (seeservice.pp
to check if this is the case). -
- license
-
GraphDB license file.
- http_port
-
The http port at which GraphDB will run.
- kill_timeout
-
Time before force kill of GraphDB process. Instances with big repositories may time to flush on shutdown. default: 180
- validator_timeout
-
Time before GraphDB validator decides that the GraphDB instance is not running
- heap_size
-
GraphDB java heap size given by -Xmx parameter. Note heap_size parameter will also set xms=xmx
- external_url
-
GraphDB external URL if GraphDB instance is accessed via proxy
- logback_config
-
GraphDB logback log configuration
- extra_properties
-
Hash of properties to include in graphdb.properties file example: => ‘some.property.value’
- java_opts
-
Array of java options to give to GraphDB java process example: [‘-Xmx1g’, ‘-Xms1g’]
- protocol
-
A string, either ‘http’ or ‘https defining under what protocol to connect to GraphDB’
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 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 |
# File 'manifests/instance.pp', line 71
define graphdb::instance (
$license = undef,
$ensure = $graphdb::ensure,
$status = $graphdb::status,
$http_port = 8080,
$external_url = undef,
$kill_timeout = 180,
$validator_timeout = 60,
$heap_size = undef,
$logback_config = undef,
$extra_properties = {},
$java_opts = [],
$protocol = 'http',
) {
# ensure
if !($ensure in [ 'present', 'absent' ]) {
fail("\"${ensure}\" is not a valid ensure parameter value")
}
if $ensure == 'present' {
validate_string($license)
}
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",
}
$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,
}
$final_graphdb_properties = merge($default_properties, $extra_properties)
file { "${instance_home_dir}/conf/graphdb.properties":
ensure => $ensure,
content => template('graphdb/config/graphdb.properties.erb'),
notify => Service[$service_name],
}
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']
}
}
|