From 112d95079455d6bcb5417e3972ebbd605336cdea Mon Sep 17 00:00:00 2001 From: tmshn Date: Thu, 15 Dec 2016 12:15:53 +0900 Subject: [PATCH] [timezone module] Check if timedatectl command is actually available --- lib/ansible/modules/system/timezone.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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)