From 1e3fc25c7e10dcc5f0df4830797efbb0b7584a5e Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 28 Jun 2024 16:18:40 +0100 Subject: [PATCH 1/2] allow cloud-config to work on distros with read-only /usr partitions (#1) --- commands/create.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/commands/create.go b/commands/create.go index 648159ae69..c697e7bf59 100644 --- a/commands/create.go +++ b/commands/create.go @@ -453,6 +453,10 @@ func writeCloudConfig(machineName, encodedData, machineOS, hostname string, cf m command := "sh" path := "/usr/local/custom_script/install.sh" key := "hostname" + // allow the script to work on distros with read-only /usr partitions + if strings.Contains(machineOS, "coreos") || strings.Contains(machineOS, "coreos") { + path = "/var/run/install.sh" + } if strings.Contains(machineOS, "windows") { // the writeFile path should ideally be C:\usr\local\custom_script\install.ps1 // however, we can't guarantee that directory exists or can be created on the target machine From 080ca04f672b7cc3004666b7a7efa509abc9682b Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 2 Jul 2024 15:25:44 +0100 Subject: [PATCH 2/2] remove detection logic --- commands/create.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/commands/create.go b/commands/create.go index c697e7bf59..d527132d9f 100644 --- a/commands/create.go +++ b/commands/create.go @@ -451,12 +451,9 @@ func updateUserdataFile(driverOpts *rpcdriver.RPCFlags, machineName, hostname, u // on how hostnames are set in cloud-config (userdata) func writeCloudConfig(machineName, encodedData, machineOS, hostname string, cf map[interface{}]interface{}, newUserDataFile *os.File) error { command := "sh" - path := "/usr/local/custom_script/install.sh" - key := "hostname" // allow the script to work on distros with read-only /usr partitions - if strings.Contains(machineOS, "coreos") || strings.Contains(machineOS, "coreos") { - path = "/var/run/install.sh" - } + path := "/var/run/install.sh" + key := "hostname" if strings.Contains(machineOS, "windows") { // the writeFile path should ideally be C:\usr\local\custom_script\install.ps1 // however, we can't guarantee that directory exists or can be created on the target machine