diff --git a/operators/pkg/forge/cloudinit.go b/operators/pkg/forge/cloudinit.go index 5cd60f0b3..2b4cdb49b 100644 --- a/operators/pkg/forge/cloudinit.go +++ b/operators/pkg/forge/cloudinit.go @@ -25,6 +25,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"` } @@ -39,6 +40,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"` @@ -66,6 +73,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 33a4a4fdf..67e941668 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