Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
timezone cannot change timezone in systemd based containers #19280
From @kayhayen on December 3, 2016 8:49
In my playbook, I got the following:
The condition was added as a workaround, because in the Debian Stretch, systemd based LXC container, timedatectl reports:
This is likely because systemd-timesyncd and systemd-timedated are disabled in virtual machines, but Ansible insists on using them to change the timezone.
OS / ENVIRONMENT
Running on Debian Testing, managing Debian Testing container running under LXC on Turris Omnia, OpenWRT kernel.
Changing the timezone is definitely possible without timedatectl. It could also be that Debian falsely disables systemd-timedated inside the container when there is virtualization, of that I am not entirely sure.
STEPS TO REPRODUCE
Use example above on LXC Debian Stretch container.
Expected to change /etc/timezone
Crashed ansible playbook.
Copied from original issue: ansible/ansible-modules-extras#3641
From @ansibot on December 7, 2016 15:50
This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible
Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.
referenced this issue
Dec 13, 2016
@kayhayen So the situation is: with LXC container,
Then, could you tell me
diff --git a/lib/ansible/modules/system/timezone.py b/lib/ansible/modules/system/timezone.py index 7d8d9ae..057becb 100644 --- a/lib/ansible/modules/system/timezone.py +++ b/lib/ansible/modules/system/timezone.py @@ -98,10 +98,11 @@ class Timezone(object): module: The AnsibleModule. """ if get_platform() == 'Linux': - if module.get_bin_path('timedatectl') is not None: - return super(Timezone, SystemdTimezone).__new__(SystemdTimezone) - else: - return super(Timezone, NosystemdTimezone).__new__(NosystemdTimezone) + # if module.get_bin_path('timedatectl') is not None: + # return super(Timezone, SystemdTimezone).__new__(SystemdTimezone) + # else: + # return super(Timezone, NosystemdTimezone).__new__(NosystemdTimezone) + return super(Timezone, NosystemdTimezone).__new__(NosystemdTimezone) else: # Not supported yet return super(Timezone, Timezone).__new__(Timezone)
referenced this issue
Dec 15, 2016
I think it does. I tried it, but I noticed that the real issue was that "dbus" was not installed. So not the disabled daemon (it is), but it being unreachable was the issue. Once dbus daemon is there, the "timedatectl" starts to work and does the job, even with ansible unmodified.
So this is a robustness feature and not generally applicable to all kinds of containers. My LXC container may or may not be typical. It's my first one. I had used ansible previously only on proper virtual machines that are full installs.
Is it necessary to have the warning?
In my opinion, it is unnecessary and creates extra critical output when in fact the timezone was changed successfully. Do users of this module really care what the underlying implementation is?