1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

timezone: Tidy up docs and arg parsing (#20133)

* Small tweaks for timezone module:

- small textual fixes
- ensure the generated docs list either hwclock or name as required
  by using a non-generated value for required_one_of

* Update docs with the DOCUMENTATION block about either name/hwclock being required
This commit is contained in:
Jasper Lievisse Adriaanse 2017-01-11 16:22:27 +01:00 committed by John R Barker
parent 7c6916f8d1
commit b384a0f795

View file

@ -34,19 +34,20 @@ module: timezone
short_description: Configure timezone setting
description:
- This module configures the timezone setting, both of the system clock
and of the hardware clock. I(Currently only Linux platform is supported.)
and of the hardware clock. I(Currently only the Linux platform is supported).
It is recommended to restart C(crond) after changing the timezone,
otherwise the jobs may run at the wrong time.
It uses the C(timedatectl) command if available. Otherwise, it edits
C(/etc/sysconfig/clock) or C(/etc/timezone) for the system clock,
and uses the C(hwclock) command for the hardware clock.
If you want to set up the NTP, use M(service) module.
version_added: "2.2.0"
version_added: "2.2"
options:
name:
description:
- Name of the timezone for the system clock.
Default is to keep current setting.
Default is to keep current setting. B(At least one of name and
hwclock are required.)
required: false
hwclock:
description:
@ -54,6 +55,7 @@ options:
Default is to keep current setting.
Note that this option is recommended not to change and may fail
to configure, especially on virtual environments such as AWS.
B(At least one of name and hwclock are required.)
required: false
aliases: ['rtc']
author: "Shinichi TAMURA (@tmshn)"
@ -233,7 +235,7 @@ class Timezone(object):
class SystemdTimezone(Timezone):
"""This is a Timezone manipulation class systemd-powered Linux.
"""This is a Timezone manipulation class for systemd-powered Linux.
It uses the `timedatectl` command to check/set all arguments.
"""
@ -430,13 +432,12 @@ class NosystemdTimezone(Timezone):
def main():
# Construct 'module' and 'tz'
arg_spec = dict(
hwclock=dict(choices=['UTC', 'local'], aliases=['rtc']),
name =dict(),
)
module = AnsibleModule(
argument_spec=arg_spec,
required_one_of=[arg_spec.keys()],
argument_spec=dict(
hwclock=dict(default=None, choices=['UTC', 'local'], aliases=['rtc']),
name=dict(default=None),
),
required_one_of=['hwclock', 'name'],
supports_check_mode=True
)
tz = Timezone(module)