tweaked userdata

This commit is contained in:
Karim Naufal 2022-03-02 22:19:58 +01:00
parent 7f1cefe1e6
commit c5c8004928
3 changed files with 35 additions and 44 deletions

View File

@ -75,16 +75,4 @@ data "template_cloudinit_config" "config" {
}
)
}
# Initialization script (runs at every reboot)
part {
content_type = "text/cloud-boothook"
filename = "boothook.sh"
content = templatefile(
"${path.module}/templates/boothook.sh.tpl",
{
hostname = var.name
}
)
}
}

View File

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

View File

@ -1,6 +1,6 @@
#cloud-config
write_files:
write_files:
# Configure private network
- content: |
BOOTPROTO='dhcp'
@ -28,6 +28,12 @@ ssh_authorized_keys:
- ${key}
%{ endfor ~}
# Making sure the hostname is set correctly
manage_etc_hosts: "localhost"
preserve_hostname: true
prefer_fqdn_over_hostname: false
hostname: ${hostname}
runcmd:
# Activate the private network
- systemctl reload network
@ -35,9 +41,11 @@ runcmd:
# Activate ssh configuration
- systemctl reload sshd
# Fix hostname (during first boot)
- hostnamectl hostname ${hostname}
# Finishing automatic reboot via Kured setup
- rebootmgrctl set-strategy off
# Reduce the default number of snapshots from 2-10 number limit, to 4
# And from 4-10 number limit important, to 2
- snapper -c root set-config "NUMBER_LIMIT=4"
- snapper -c root set-config "NUMBER_LIMIT_IMPORTANT=2"