From 2c6073854b9bd997a584c5017304b191d98f079f Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Wed, 22 Dec 2021 07:41:50 +0100 Subject: [PATCH] cleanup some more kunsi leftovers --- bundles/basic/files/hosts | 6 +++++- bundles/systemd/items.py | 5 +++-- groups/all.py | 6 ------ nodes.py | 7 ------- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/bundles/basic/files/hosts b/bundles/basic/files/hosts index 2ecc921..8ebbe53 100644 --- a/bundles/basic/files/hosts +++ b/bundles/basic/files/hosts @@ -1,4 +1,8 @@ -127.0.0.1 localhost ${node.name} ${node.metadata['hostname']} +% if node.metadata.get('hostname', None): +127.0.0.1 localhost ${node.name} ${node.metadata.get('hostname')} +% else: +127.0.0.1 localhost ${node.name} +% endif ::1 ip6-localhost fe00::0 ip6-localnet diff --git a/bundles/systemd/items.py b/bundles/systemd/items.py index 6c8f671..48a27ea 100644 --- a/bundles/systemd/items.py +++ b/bundles/systemd/items.py @@ -1,4 +1,5 @@ timezone = node.metadata.get('timezone', 'UTC') +hostname = node.metadata.get('hostname', node.name) actions = { 'systemd-reload': { @@ -10,8 +11,8 @@ actions = { }, }, 'systemd-hostname': { - 'command': 'hostnamectl set-hostname {}'.format(node.metadata['hostname']), - 'unless': '[ "$(hostnamectl --static)" = "{}" ]'.format(node.metadata['hostname']), + 'command': 'hostnamectl set-hostname {}'.format(hostname), + 'unless': '[ "$(hostnamectl --static)" = "{}" ]'.format(hostname), # Provided by bundle:basic 'needs': { 'file:/etc/hosts', diff --git a/groups/all.py b/groups/all.py index f039f09..f695a4b 100644 --- a/groups/all.py +++ b/groups/all.py @@ -5,10 +5,4 @@ groups['all'] = { 'subgroups': { 'linux', }, - 'metadata': { - # XXX remove this once we're no longer symlinking kunsis bundles - 'icinga_options': { - 'exclude_from_monitoring': True, - }, - }, } diff --git a/nodes.py b/nodes.py index 28db2af..93f3419 100644 --- a/nodes.py +++ b/nodes.py @@ -7,10 +7,3 @@ from bundlewrap.metadata import atomic for node in Path(join(repo_path, "nodes")).rglob("*.py"): with open(node, 'r') as f: exec(f.read()) - -for name, data in nodes.items(): - if 'hostname' not in data.keys(): - data['hostname'] = '.'.join(reversed(name.split('.'))) + '.kunbox.net' - - if 'hostname' not in data['metadata'].keys(): - data['metadata']['hostname'] = '.'.join(reversed(name.split('.'))) + '.kunbox.net'