allow setting hostname in metadata
This commit is contained in:
parent
5d1e71e83e
commit
c2c9913514
2 changed files with 10 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue