diff --git a/lib/ansible/modules/system/timezone.py b/lib/ansible/modules/system/timezone.py index 7d8d9aef76c..008a34a850f 100644 --- a/lib/ansible/modules/system/timezone.py +++ b/lib/ansible/modules/system/timezone.py @@ -92,13 +92,14 @@ class Timezone(object): """Return the platform-specific subclass. It does not use load_platform_subclass() because it need to judge based - on whether the `timedatectl` command exists. + on whether the `timedatectl` command exists and available. Args: module: The AnsibleModule. """ if get_platform() == 'Linux': - if module.get_bin_path('timedatectl') is not None: + timedatectl = module.get_bin_path('timedatectl') + if timedatectl is not None and module.run_command(timedatectl)[0] == 0: return super(Timezone, SystemdTimezone).__new__(SystemdTimezone) else: return super(Timezone, NosystemdTimezone).__new__(NosystemdTimezone)