From b66a8575a22973fcacf0bcf465282a3f5a559ad7 Mon Sep 17 00:00:00 2001
From: Federico Cucinella <10742159+QcFe@users.noreply.github.com>
Date: Tue, 19 Mar 2024 17:51:47 +0100
Subject: [PATCH] missing pieces

---
 operators/pkg/forge/cloudinit.go      | 11 +++++++++++
 operators/pkg/forge/cloudinit_test.go |  4 ++++
 2 files changed, 15 insertions(+)

diff --git a/operators/pkg/forge/cloudinit.go b/operators/pkg/forge/cloudinit.go
index 2b3b6d66f..08d620285 100644
--- a/operators/pkg/forge/cloudinit.go
+++ b/operators/pkg/forge/cloudinit.go
@@ -23,6 +23,7 @@ import (
 // userdata is a helper structure to marshal the userdata configuration.
 type userdata struct {
 	Users             []user     `yaml:"users"`
+	Network           network    `yaml:"network"`
 	Mounts            [][]string `yaml:"mounts"`
 	SSHAuthorizedKeys []string   `yaml:"ssh_authorized_keys,omitempty"`
 }
@@ -37,6 +38,12 @@ type user struct {
 	Shell             string   `yaml:"shell"`
 }
 
+// network is a helper structure to marshal the userdata configuration to configure the network subsystem.
+type network struct {
+	Version int    `yaml:"version"`
+	ID0     interf `yaml:"id0"`
+}
+
 // interf is a helper structure to marshal the userdata configuration to configure a given interface.
 type interf struct {
 	DHCP4 bool `yaml:"dhcp4"`
@@ -55,6 +62,10 @@ func CloudInitUserData(nfsServerName, nfsPath string, publicKeys []string) ([]by
 			SSHAuthorizedKeys: publicKeys,
 			Shell:             "/bin/bash",
 		}},
+		Network: network{
+			Version: 2,
+			ID0:     interf{DHCP4: true},
+		},
 		SSHAuthorizedKeys: publicKeys,
 	}
 	if nfsServerName != "" && nfsPath != "" {
diff --git a/operators/pkg/forge/cloudinit_test.go b/operators/pkg/forge/cloudinit_test.go
index ca8ee2985..dfa03dea4 100644
--- a/operators/pkg/forge/cloudinit_test.go
+++ b/operators/pkg/forge/cloudinit_test.go
@@ -40,6 +40,10 @@ users:
         - tenant-key-1
         - tenant-key-2
       shell: /bin/bash
+network:
+    version: 2
+    id0:
+        dhcp4: true
 mounts:
     - - rook-ceph-nfs-my-nfs-a.rook-ceph.svc.cluster.local:/path
       - /media/mydrive