Switch to cloud-init for host initialization

This commit is contained in:
Marco Nenciarini
2022-02-23 19:36:03 +01:00
parent c309a1b290
commit 5f7d47783b
6 changed files with 88 additions and 70 deletions

View File

@@ -0,0 +1,5 @@
#!/bin/sh
#cloud-boothook
# Fix hostname after reboot
hostnamectl hostname "${hostname}"

View File

@@ -0,0 +1,35 @@
#cloud-config
write_files:
# Configure private network
- content: |
BOOTPROTO='dhcp'
STARTMODE='auto'
path: /etc/sysconfig/network/ifcfg-eth1
# Disable ssh password authentication
- content: |
PasswordAuthentication no
X11Forwarding no
MaxAuthTries 2
AllowTcpForwarding no
AllowAgentForwarding no
AuthorizedKeysFile .ssh/authorized_keys
path: /etc/ssh/sshd_config.d/kube-hetzner.conf
# Add ssh authorized keys
ssh_authorized_keys:
%{ for key in sshAuthorizedKeys ~}
- ${key}
%{ endfor ~}
runcmd:
# Activate the private network
- systemctl reload network
# Activate ssh configuration
- systemctl reload sshd
# Fix hostname (during first boot)
- hostnamectl hostname ${hostname}