Puppet Class: promtail::config
- Defined in:
- manifests/config.pp
Summary
Creates files and folders associated with promtail's configOverview
Creates files and folders associated with promtail’s config
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 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 83 84 85 |
# File 'manifests/config.pp', line 6
class promtail::config {
case $facts['kernel'] {
'Linux': {
$config_dir = '/etc/promtail'
}
default: { fail("${facts['kernel']} is not supported")}
}
file { $config_dir:
ensure => directory,
}
$config_file = "${config_dir}/config.yaml"
concat { $config_file:
ensure => present,
notify => Service['promtail'],
}
concat::fragment { 'config_header':
target => $config_file,
content => "---\n",
order => '01',
}
# Configures the server for Promtail.
# [server: <server_config>]
if $promtail::server_config_hash {
concat::fragment { 'server_config_hash':
target => $config_file,
content => $promtail::server_config_hash.promtail::to_yaml.promtail::strip_yaml_header,
order => '10',
}
}
# Describes how Promtail connects to multiple instances
# of Loki, sending logs to each.
# clients:
# - [<client_config>]
concat::fragment { 'clients_config_hash':
target => $config_file,
content => $promtail::clients_config_hash.promtail::to_yaml.promtail::strip_yaml_header,
order => '20',
}
# Describes how to save read file offsets to disk
# [positions: <position_config>]
concat::fragment { 'positions_config_hash':
target => $config_file,
content => $promtail::positions_config_hash.promtail::to_yaml.promtail::strip_yaml_header,
order => '30',
}
# scrape_configs:
# - [<scrape_config>]
concat::fragment { 'scrape_configs_hash':
target => $config_file,
content => $promtail::scrape_configs_hash.promtail::to_yaml.promtail::strip_yaml_header,
order => '40',
}
# Configures how tailed targets will be watched.
# [target_config: <target_config>]
if $promtail::target_config_hash {
concat::fragment { 'target_config_hash':
target => $config_file,
content => $promtail::target_config_hash.promtail::to_yaml.promtail::strip_yaml_header,
order => '50',
}
}
if $promtail::password_file_path and $promtail::password_file_content {
file { $promtail::password_file_path:
ensure => file,
mode => '0600',
content => unwrap($promtail::password_file_content),
show_diff => false,
}
}
}
|