diff --git a/bundles/hostname/items.py b/bundles/hostname/items.py new file mode 100644 index 0000000..74d4999 --- /dev/null +++ b/bundles/hostname/items.py @@ -0,0 +1,11 @@ +files['/etc/hostname'] = { + 'content': node.metadata.get('hostname'), + 'triggers': [ + 'action:update_hostname', + ], +} + +actions["update_hostname"] = { + "command": "hostname -F /etc/hostname", + 'triggered': True, +} diff --git a/bundles/hostname/metadata.py b/bundles/hostname/metadata.py new file mode 100644 index 0000000..71595b1 --- /dev/null +++ b/bundles/hostname/metadata.py @@ -0,0 +1,14 @@ +defaults = { + 'hostname': '.'.join([*reversed(node.name.split('.')), 'ckn', 'li']), +} + + +@metadata_reactor.provides( + 'dns', +) +def dns(metadata): + return { + 'dns': { + metadata.get('hostname'): repo.libs.dns.get_a_records(metadata, external=False), + }, + } diff --git a/groups/os/linux.py b/groups/os/linux.py index 3083f45..81f18e6 100644 --- a/groups/os/linux.py +++ b/groups/os/linux.py @@ -3,6 +3,7 @@ 'all', ], 'bundles': [ + 'hostname', 'network', 'systemd', 'systemd-networkd', diff --git a/libs/dns.py b/libs/dns.py index 1b65733..a630e8c 100644 --- a/libs/dns.py +++ b/libs/dns.py @@ -4,10 +4,10 @@ def get_a_records(metadata, internal=True, external=True): networks = metadata.get('network') if not internal: - networks.pop('internal') + networks.pop('internal', None) if not external: - networks.pop('external') + networks.pop('external', None) return { 'A': [ diff --git a/requirements.txt b/requirements.txt index aa688ee..d5312b2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -bundlewrap>=4.8.0 +bundlewrap>=4.10.1 pycryptodome PyNaCl PyYAML