allow setting hostname in metadata

This commit is contained in:
Franzi 2020-09-27 16:46:54 +02:00
parent 5d1e71e83e
commit c2c9913514
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 10 additions and 2 deletions

View file

@ -1,4 +1,7 @@
127.0.0.1 localhost ${node.name} ${node.hostname}
% if 'hostname' in node.metadata:
127.0.0.1 ${node.metadata['hostname']}
% endif
::1 ip6-localhost
fe00::0 ip6-localnet

View file

@ -1,3 +1,8 @@
if 'hostname' in node.metadata:
hostname = node.metadata['hostname']
else:
hostname = node.hostname
actions = {
'systemd-reload': {
'command': 'systemctl daemon-reload',
@ -8,8 +13,8 @@ actions = {
},
},
'systemd-hostname': {
'command': 'hostnamectl set-hostname {}'.format(node.hostname),
'unless': '[ "$(hostnamectl --static)" = "{}" ]'.format(node.hostname),
'command': 'hostnamectl set-hostname {}'.format(hostname),
'unless': '[ "$(hostnamectl --static)" = "{}" ]'.format(hostname),
# Provided by 'hostname' bundle
'needs': {
'file:/etc/hosts',