bundles/telegraf: support requesting additional capabilities and/or groups

This commit is contained in:
Franzi 2021-04-24 11:44:55 +02:00
parent f78c024edc
commit a980e22ecb
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,2 @@
[Service]
AmbientCapabilities=${' '.join(sorted(capabilities))}

View file

@ -79,11 +79,46 @@ files = {
},
}
if node.metadata.get('telegraf/additional_capabilities', set()):
files['/etc/systemd/system/telegraf.service.d/bundlewrap.conf'] = {
'source': 'override.conf',
'content_type': 'mako',
'context': {
'capabilities': node.metadata['telegraf']['additional_capabilities'],
},
'triggers': {
'action:systemd-reload',
'svc_systemd:telegraf:restart',
},
}
else:
files['/etc/systemd/system/telegraf.service.d/bundlewrap.conf'] = {
'delete': True,
'triggers': {
'action:systemd-reload',
'svc_systemd:telegraf:restart',
},
}
users = {
'telegraf': {
'groups': node.metadata.get('telegraf/additional_groups', set()),
'needs': {
'pkg_apt:telegraf',
},
'triggers': {
'svc_systemd:telegraf:restart',
},
},
}
svc_systemd = {
'telegraf': {
'needs': {
'file:/etc/telegraf/telegraf.conf',
'file:/etc/systemd/system/telegraf.service.d/bundlewrap.conf',
'pkg_apt:telegraf',
'user:telegraf',
},
},
}