Defined Type: confd::file
- Defined in:
- modules/confd/manifests/file.pp
Overview
SPDX-License-Identifier: Apache-2.0
Define confd::file
Defines a service template to be monitored by confd, and the corresponding geneated config file.
Parameters
- prefix
-
Prefix to use for all keys; it will actually be joined with the global confd prefix
- instance
-
Which confd::instance we should configure. Anything other than the default 'main' instance will need to be instantiated explicitly
- watch_keys
-
list of keys to watch relative to the value assigned in $prefix
- uid
-
Numeric uid of the owner of the file produced. Default: 0
- gid
-
Numeric gid of the owner of the produced file. Default: 0
- mode
-
File mode for the generated file
- reload
-
Command to execute when the produced file changes
- check
-
Check to execute when the produced file changes
- content
-
The actual go text/template used for generating the file
- relative_prefix
-
if true prepend the global prefix configured in the confd class
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 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 |
# File 'modules/confd/manifests/file.pp', line 32
define confd::file (
$ensure = 'present',
$prefix = undef,
$instance = 'main',
$watch_keys = [],
$uid = undef,
$gid = undef,
$mode = '0444',
$reload = undef,
$check = undef,
$content = undef,
Boolean $relative_prefix = true,
) {
include confd
unless $confd::instances.has_key($instance) {
fail("confd class has no instance configuered for: ${instance}")
}
# TODO: currently prefix is optional, what do we do if its undef?
$confd_prefix = $confd::instances[$instance]['prefix']
$label = $instance ? {
'main' => 'confd',
default => sprintf('confd-%s', regsubst($instance, '/', '_', 'G')),
}
$path = "/etc/${label}"
$_prefix = $relative_prefix.bool2str("${confd_prefix}${prefix}", $prefix)
$safe_name = regsubst($name, '/', '_', 'G')
file { "${path}/templates/${safe_name}.tmpl":
ensure => $ensure,
mode => '0400',
content => $content,
require => Package['confd'],
before => File["${path}/conf.d/${safe_name}.toml"],
}
#TODO validate at least uid and guid
file { "${path}/conf.d/${safe_name}.toml":
ensure => $ensure,
content => template('confd/service_template.toml.erb'),
notify => Service[$label],
}
if $ensure == 'absent' {
file { $name:
ensure => 'absent',
}
}
}
|