cp over all the bundles from kunsis bw repo

This commit is contained in:
Rico 2021-12-21 15:56:24 +01:00
parent 65b117b819
commit 1f73b04351
Signed by: stillbeben
GPG key ID: AE1066B5BD0B5041
89 changed files with 3991 additions and 0 deletions

12
bundles/basic/files/hosts Normal file
View file

@ -0,0 +1,12 @@
127.0.0.1 localhost ${node.name} ${node.metadata['hostname']}
::1 ip6-localhost
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
% for ip, entries in sorted(node.metadata.get('hosts/entries', {}).items()):
${ip} ${' '.join(sorted(entries))}
% endfor

View file

@ -0,0 +1,39 @@
# Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly.
fields=0 48 17 18 38 39 40 2 46 47 49 1
sort_key=46
sort_direction=-1
tree_sort_key=0
tree_sort_direction=1
hide_kernel_threads=1
hide_userland_threads=0
shadow_other_users=0
show_thread_names=0
show_program_path=1
highlight_base_name=1
highlight_megabytes=0
highlight_threads=1
highlight_changes=0
highlight_changes_delay_secs=5
find_comm_in_cmdline=1
strip_exe_from_cmdline=1
show_merged_command=0
tree_view=0
tree_view_always_by_pid=0
header_margin=1
detailed_cpu_time=1
cpu_count_from_one=1
show_cpu_usage=1
show_cpu_frequency=0
show_cpu_temperature=0
degree_fahrenheit=0
update_process_names=0
account_guest_in_cpu_meter=0
color_scheme=0
enable_mouse=0
delay=10
left_meters=Tasks LoadAverage Uptime Memory CPU LeftCPUs CPU
left_meter_modes=2 2 2 1 1 1 2
right_meters=Hostname CPU RightCPUs
right_meter_modes=2 3 1
hide_function_bar=0

View file

@ -0,0 +1 @@
LANG=${node.metadata['locale']['default']}

View file

@ -0,0 +1,3 @@
% for locale in sorted(node.metadata['locale']['installed']):
${locale} ${locale.split('.')[-1]}
% endfor

88
bundles/basic/items.py Normal file
View file

@ -0,0 +1,88 @@
from inspect import cleandoc
from uuid import UUID
from bundlewrap.utils.text import italic
files = {
'/etc/default/locale': {
'content_type': 'mako',
'needs': {
'action:locale-gen',
},
},
'/etc/hosts': {
'content_type': 'mako',
},
'/etc/htoprc.global': {
'source': 'htoprc',
},
'/etc/motd': {
'content': '',
},
}
locale_needs = set()
for locale in sorted(node.metadata['locale']['installed']):
actions[f'ensure_locale_{locale}_is_enabled'] = {
'command': f"sed -i '/{locale}/s/^# *//g' /etc/locale.gen",
'unless': f"grep -e '^{locale}' /etc/locale.gen",
'triggers': {
'action:locale-gen',
},
'needs': locale_needs,
}
locale_needs = {f'action:ensure_locale_{locale}_is_enabled'}
actions = {
'locale-gen': {
'triggered': True,
'command': 'locale-gen',
},
}
description = []
if not node.metadata.get('icinga_options/exclude_from_monitoring', False):
description.append('icingaweb2: https://icinga.kunsmann.eu/monitoring/host/show?host={}'.format(node.name))
if node.has_bundle('telegraf'):
description.append('Grafana: https://grafana.kunsmann.eu/d/{}'.format(UUID(int=node.magic_number).hex[:10]))
if (
not node.metadata.get('icinga_options/exclude_from_monitoring', False) or
node.has_bundle('telegraf')
):
description.append('') # divider line
if node.metadata.get('nginx/vhosts', {}):
description.append('nginx vhosts:')
for vname, vconfig in sorted(node.metadata.get('nginx/vhosts', {}).items()):
if vconfig.get('ssl', 'letsencrypt') is not None:
proto = 'https'
else:
proto = 'http'
domain = vconfig.get('domain', vname)
description.append(' {}: {}://{}{}'.format(
vname,
proto,
domain,
vconfig.get('website_check_path', '/'),
))
if node.metadata.get('description', []):
description.append('') # divider line
for line in node.metadata.get('description', []):
description.append('# {}'.format(italic(line)))
if description:
files['/etc/node.description'] = {
'content': '\n'.join(description) + '\n',
}
else:
files['/etc/node.description'] = {
'delete': True,
}

25
bundles/basic/metadata.py Normal file
View file

@ -0,0 +1,25 @@
defaults = {
'bash_functions': {
'h': 'cp /etc/htoprc.global ~/.htoprc; mkdir -p ~/.config/htop; cp /etc/htoprc.global ~/.config/htop/htoprc; htop',
},
'locale': {
'default': 'en_US.UTF-8',
'installed': {
'de_DE.UTF-8',
'en_US.UTF-8',
},
},
}
@metadata_reactor.provides(
'locale/installed',
)
def ensure_default_is_installed(metadata):
return {
'locale': {
'installed': {
metadata.get('locale/default'),
},
},
}