mirror of
https://github.com/rancher/os.git
synced 2025-09-05 08:42:38 +00:00
Post to Packet phone home URL on first boot
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cloudinitsave
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -76,8 +77,8 @@ func enablePacketNetwork(cfg *rancherConfig.RancherConfig) {
|
||||
}
|
||||
|
||||
netCfg.Interfaces["bond0"] = bondCfg
|
||||
bytes, _ := yaml.Marshal(netCfg)
|
||||
logrus.Debugf("Generated network config: %s", string(bytes))
|
||||
b, _ := yaml.Marshal(netCfg)
|
||||
logrus.Debugf("Generated network config: %s", string(b))
|
||||
|
||||
cc := rancherConfig.CloudConfig{
|
||||
Rancher: rancherConfig.RancherConfig{
|
||||
@@ -85,6 +86,13 @@ func enablePacketNetwork(cfg *rancherConfig.RancherConfig) {
|
||||
},
|
||||
}
|
||||
|
||||
// Post to phone home URL on first boot
|
||||
if _, err = os.Stat(rancherConfig.CloudConfigNetworkFile); err != nil {
|
||||
if _, err = http.Post(m.PhoneHomeURL, "application/json", bytes.NewReader([]byte{})); err != nil {
|
||||
logrus.Errorf("Failed to post to Packet phone home URL: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(path.Dir(rancherConfig.CloudConfigNetworkFile), 0700); err != nil {
|
||||
logrus.Errorf("Failed to create directory for file %s: %v", rancherConfig.CloudConfigNetworkFile, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user