[timezone module] Check if timedatectl command is actually available
This commit is contained in:
parent
a532dd915a
commit
112d950794
1 changed files with 3 additions and 2 deletions
|
@ -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…
Reference in a new issue