[timezone module] Check if timedatectl command is actually available

pull/19545/head
tmshn 8 years ago committed by Brian Coca
parent a532dd915a
commit 112d950794

@ -92,13 +92,14 @@ class Timezone(object):
"""Return the platform-specific subclass. """Return the platform-specific subclass.
It does not use load_platform_subclass() because it need to judge based 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: Args:
module: The AnsibleModule. module: The AnsibleModule.
""" """
if get_platform() == 'Linux': 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) return super(Timezone, SystemdTimezone).__new__(SystemdTimezone)
else: else:
return super(Timezone, NosystemdTimezone).__new__(NosystemdTimezone) return super(Timezone, NosystemdTimezone).__new__(NosystemdTimezone)

Loading…
Cancel
Save