summaryrefslogtreecommitdiff
path: root/pkg/machine/ignition.go
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2021-12-14 14:16:09 -0600
committerBrent Baude <bbaude@redhat.com>2021-12-16 12:40:20 -0600
commita86495ea6fdd56519afc65586c0f7f9c0f4f5ab2 (patch)
treebdf7576ddf565cf60b889bc7fd825b40ec6376e5 /pkg/machine/ignition.go
parent273da42af237dde44d34d215dfafa33f0b76d9ab (diff)
downloadpodman-a86495ea6fdd56519afc65586c0f7f9c0f4f5ab2.tar.gz
podman-a86495ea6fdd56519afc65586c0f7f9c0f4f5ab2.tar.bz2
podman-a86495ea6fdd56519afc65586c0f7f9c0f4f5ab2.zip
Set machine timezone
Added an option to podman machine init to declare the timezone of the resulting machine. the default is to use the value of the host name or else a given timezone name like America/Chicago. Fixes: #11895 Signed-off-by: Brent Baude <bbaude@redhat.com> [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/machine/ignition.go')
-rw-r--r--pkg/machine/ignition.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/pkg/machine/ignition.go b/pkg/machine/ignition.go
index 5c465d37d..9368cc8ed 100644
--- a/pkg/machine/ignition.go
+++ b/pkg/machine/ignition.go
@@ -7,6 +7,7 @@ import (
"fmt"
"io/ioutil"
"net/url"
+ "path/filepath"
)
/*
@@ -44,6 +45,7 @@ func getNodeGrp(grpName string) NodeGroup {
type DynamicIgnition struct {
Name string
Key string
+ TimeZone string
VMName string
WritePath string
}
@@ -76,6 +78,37 @@ func NewIgnitionFile(ign DynamicIgnition) error {
Links: getLinks(ign.Name),
}
+ // Add or set the time zone for the machine
+ if len(ign.TimeZone) > 0 {
+ var (
+ err error
+ tz string
+ )
+ // local means the same as the host
+ // lookup where it is pointing to on the host
+ if ign.TimeZone == "local" {
+ tz, err = getLocalTimeZone()
+ if err != nil {
+ return err
+ }
+ } else {
+ tz = ign.TimeZone
+ }
+ tzLink := Link{
+ Node: Node{
+ Group: getNodeGrp("root"),
+ Path: "/etc/localtime",
+ Overwrite: boolToPtr(false),
+ User: getNodeUsr("root"),
+ },
+ LinkEmbedded1: LinkEmbedded1{
+ Hard: boolToPtr(false),
+ Target: filepath.Join("/usr/share/zoneinfo", tz),
+ },
+ }
+ ignStorage.Links = append(ignStorage.Links, tzLink)
+ }
+
// ready is a unit file that sets up the virtual serial device
// where when the VM is done configuring, it will send an ack
// so a listening host knows it can being interacting with it