introduce node.metadata['hostname'] to other bundles, update nodefiles to reflect changes
All checks were successful
bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2020-10-25 11:07:23 +01:00
parent de73552700
commit 831545d8b1
Signed by: kunsi
GPG key ID: 12E3D2136B818350
11 changed files with 24 additions and 18 deletions

View file

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

View file

@ -1,4 +1,4 @@
${node.hostname}
${node.metadata['hostname']}
% for domain, aliases in sorted(node.metadata.get('letsencrypt', {}).get('domains', {}).items()):
${domain} ${' '.join(sorted(aliases))}

View file

@ -24,7 +24,7 @@ $TTL 60
)
"""
for rnode in sorted(repo.nodes_in_group('dns')):
ZONE_HEADER += '@ IN NS {}.\n'.format(rnode.metadata.get('powerdns', {}).get('my_hostname', rnode.hostname))
ZONE_HEADER += '@ IN NS {}.\n'.format(rnode.metadata.get('powerdns', {}).get('my_hostname', rnode.metadata['hostname']))
directories = {
'/etc/powerdns/pdns.d': {

View file

@ -109,10 +109,20 @@ def hosts_entries_for_all_dns_servers(metadata):
entries = {}
for rnode in repo.nodes_in_group('dns'):
entries[rnode.metadata.get('external_ipv4')] = {
rnode.metadata.get('powerdns/my_hostname', node.hostname)
if rnode.name == node.name:
continue
ip = rnode.metadata.get('external_ipv4')
if ip:
entries[ip] = {
rnode.metadata.get('hostname'),
rnode.name,
}
if rnode.metadata.get('powerdns/my_hostname', None):
entries[ip].add(rnode.metadata.get('powerdns/my_hostname'))
return {
'hosts': {
'entries': entries,

View file

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

View file

@ -9,3 +9,6 @@ for node in Path(join(repo_path, "nodes")).rglob("*.py"):
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'

View file

@ -2,6 +2,7 @@
# Frankfurt, Germany
nodes['gce.bind01'] = {
'hostname': '34.89.208.78',
'bundles': {
'nodejs',
'powerdnsadmin',

View file

@ -2,6 +2,7 @@
# Belgium
nodes['gce.dns02'] = {
'hostname': '35.187.109.249',
'bundles': set(),
'groups': {
'dns',

View file

@ -2,6 +2,7 @@
# Finland
nodes['gce.dns03'] = {
'hostname': '35.228.143.71',
'bundles': set(),
'groups': {
'dns',

View file

@ -6,7 +6,6 @@ nodes['home.kodi-wohnzimmer'] = {
},
'groups': set(),
'metadata': {
'hostname': 'kodi-wohnzimmer',
'interfaces': {
'eth0': {
'ipv4': {

View file

@ -8,7 +8,6 @@ nodes['home.octoprint-vielschichtigkeit'] = {
'raspberry',
},
'metadata': {
'hostname': 'octoprint-vielschichtigkeit',
'interfaces': {
'eth0': {
'ipv4': {