From 23a486dc9add424b32c5fda30917173dbc22e90a Mon Sep 17 00:00:00 2001 From: Mathieu Trossevin Date: Mon, 27 Jul 2020 11:53:03 +0200 Subject: [PATCH 1/2] [LXC] Force lxc containers to be in the correct timezone Right now lxc containers are in the Etc/UTC timezone, this commit change it so that they are in the same timezone as the host by copying /etc/timezone and /etc/localtime (without dereferencing it) inside of the container. It might not be able to survive an update of the tzdata package however. (Debian shouldn't change manual configuration upon update but they chose to anyways so bear with it). --- lxc/tasks/create-container.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lxc/tasks/create-container.yml b/lxc/tasks/create-container.yml index 8b8a68e3..71048b14 100644 --- a/lxc/tasks/create-container.yml +++ b/lxc/tasks/create-container.yml @@ -52,6 +52,23 @@ insertbefore: "^exit 0$" when: release == 'jessie' +- name: "Force container {{ name }} to be in the correct timezone [1/2]" + copy: + src: "/etc/timezone" + dest: "/var/lib/lxc/{{ name }}/rootfs/etc/timezone" + force: yes + owner: root + group: root + +- name: "Force container {{ name }} to be in the correct timezone [2/2]" + copy: + src: "/etc/localtime" + dest: "/var/lib/lxc/{{ name }}/rootfs/etc/localtime" + force: yes + local_follow: no + owner: root + group: root + - name: "Ensure that {{ name }} container is running" lxc_container: name: "{{ name }}" -- 2.39.2 From 0618c18b4e99e9d11c8d0b54116631d80bad8324 Mon Sep 17 00:00:00 2001 From: Mathieu Trossevin Date: Tue, 20 Oct 2020 17:20:31 +0200 Subject: [PATCH 2/2] Update changelog: force lxc containers to be in correct TZ --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07f1e37f..1fd34343 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ The **patch** part changes incrementally at each release. ### Fixed +* lxc: Force lxc containers to be in the correct timezone + ### Removed ### Security -- 2.39.2