From 63eb166eb907bc3108d24a7c8920d1b5412185f1 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Sat, 5 Feb 2022 18:59:14 +0100 Subject: [PATCH] Configure eth1 and set hostname --- locals.tf | 2 +- master.tf | 1 + templates/config.ign.tpl | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/locals.tf b/locals.tf index 983461c..a5cab15 100644 --- a/locals.tf +++ b/locals.tf @@ -13,7 +13,7 @@ locals { microOS_install_commands = [ "set -ex", - "apt install -y aria2", + "apt-get install -y aria2", "aria2c --follow-metalink=mem https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-k3s-kvm-and-xen.qcow2.meta4", "qemu-img convert -p -f qcow2 -O host_device $(ls -a | grep -ie '^opensuse.*microos.*k3s.*qcow2$') /dev/sda", "sgdisk -e /dev/sda", diff --git a/master.tf b/master.tf index 8fa2da1..e2f7a76 100644 --- a/master.tf +++ b/master.tf @@ -33,6 +33,7 @@ resource "hcloud_server" "first_control_plane" { provisioner "file" { content = templatefile("${path.module}/templates/config.ign.tpl", { + name = self.name ssh_public_key = local.ssh_public_key }) destination = "/root/config.ign" diff --git a/templates/config.ign.tpl b/templates/config.ign.tpl index 3be1a77..7cdc43f 100644 --- a/templates/config.ign.tpl +++ b/templates/config.ign.tpl @@ -11,5 +11,21 @@ ] } ] + }, + "storage": { + "files": [ + { + "path": "/etc/hostname", + "mode": 420, + "overwrite": true, + "contents": { "source": "data:,${name}" } + }, + { + "path": "/etc/sysconfig/network/ifcfg-eth1", + "mode": 420, + "overwrite": true, + "contents": { "source": "data:,BOOTPROTO%3D%27dhcp%27%0ASTARTMODE%3D%27auto%27" } + } + ] } }