[cron] Remove deprecated features (#74197)
Change: - Require name always - Drop 'reboot' parameter in favor of 'special_time: reboot' Test Plan: - CI Tickets: - fixes #74132 Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
parent
d5ce6e6bed
commit
d7df8a4484
5 changed files with 12 additions and 36 deletions
3
changelogs/fragments/cron-deprecations.yml
Normal file
3
changelogs/fragments/cron-deprecations.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
minor_changes:
|
||||
- "cron - ``name`` is now a required parameter always"
|
||||
- "cron - ``reboot`` parameter has been dropped in favor of ``special_time: reboot``"
|
|
@ -37,7 +37,8 @@ No notable changes
|
|||
Modules
|
||||
=======
|
||||
|
||||
No notable changes
|
||||
* ``cron`` now requires ``name`` to be specified in all cases.
|
||||
* ``cron`` no longer allows a ``reboot`` parameter. Use ``special_time: reboot`` instead.
|
||||
|
||||
|
||||
Modules removed
|
||||
|
|
|
@ -33,11 +33,9 @@ options:
|
|||
name:
|
||||
description:
|
||||
- Description of a crontab entry or, if env is set, the name of environment variable.
|
||||
- Required if I(state=absent).
|
||||
- Note that if name is not set and I(state=present), then a
|
||||
new crontab entry will always be created, regardless of existing ones.
|
||||
- This parameter will always be required in future releases.
|
||||
- This parameter is always required as of ansible-core 2.12.
|
||||
type: str
|
||||
required: yes
|
||||
user:
|
||||
description:
|
||||
- The specific user whose crontab should be modified.
|
||||
|
@ -98,12 +96,6 @@ options:
|
|||
type: str
|
||||
default: "*"
|
||||
aliases: [ dow ]
|
||||
reboot:
|
||||
description:
|
||||
- If the job should be run at reboot. This option is deprecated. Users should use I(special_time).
|
||||
version_added: "1.0"
|
||||
type: bool
|
||||
default: no
|
||||
special_time:
|
||||
description:
|
||||
- Special time specification nickname.
|
||||
|
@ -562,7 +554,7 @@ def main():
|
|||
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
name=dict(type='str'),
|
||||
name=dict(type='str', required=True),
|
||||
user=dict(type='str'),
|
||||
job=dict(type='str', aliases=['value']),
|
||||
cron_file=dict(type='str'),
|
||||
|
@ -573,7 +565,6 @@ def main():
|
|||
day=dict(type='str', default='*', aliases=['dom']),
|
||||
month=dict(type='str', default='*'),
|
||||
weekday=dict(type='str', default='*', aliases=['dow']),
|
||||
reboot=dict(type='bool', default=False),
|
||||
special_time=dict(type='str', choices=["reboot", "yearly", "annually", "monthly", "weekly", "daily", "hourly"]),
|
||||
disabled=dict(type='bool', default=False),
|
||||
env=dict(type='bool', default=False),
|
||||
|
@ -582,7 +573,6 @@ def main():
|
|||
),
|
||||
supports_check_mode=True,
|
||||
mutually_exclusive=[
|
||||
['reboot', 'special_time'],
|
||||
['insertafter', 'insertbefore'],
|
||||
],
|
||||
)
|
||||
|
@ -598,7 +588,6 @@ def main():
|
|||
day = module.params['day']
|
||||
month = module.params['month']
|
||||
weekday = module.params['weekday']
|
||||
reboot = module.params['reboot']
|
||||
special_time = module.params['special_time']
|
||||
disabled = module.params['disabled']
|
||||
env = module.params['env']
|
||||
|
@ -622,17 +611,6 @@ def main():
|
|||
|
||||
module.debug('cron instantiated - name: "%s"' % name)
|
||||
|
||||
if not name:
|
||||
module.deprecate(
|
||||
msg="The 'name' parameter will be required in future releases.",
|
||||
version='2.12', collection_name='ansible.builtin'
|
||||
)
|
||||
if reboot:
|
||||
module.deprecate(
|
||||
msg="The 'reboot' parameter will be removed in future releases. Use 'special_time' option instead.",
|
||||
version='2.12', collection_name='ansible.builtin'
|
||||
)
|
||||
|
||||
if module._diff:
|
||||
diff = dict()
|
||||
diff['before'] = crontab.n_existing
|
||||
|
@ -646,15 +624,12 @@ def main():
|
|||
|
||||
# --- user input validation ---
|
||||
|
||||
if env and not name:
|
||||
module.fail_json(msg="You must specify 'name' while working with environment variables (env=yes)")
|
||||
|
||||
if (special_time or reboot) and \
|
||||
if special_time and \
|
||||
(True in [(x != '*') for x in [minute, hour, day, month, weekday]]):
|
||||
module.fail_json(msg="You must specify time and date fields or special time.")
|
||||
|
||||
# cannot support special_time on solaris
|
||||
if (special_time or reboot) and platform.system() == 'SunOS':
|
||||
if special_time and platform.system() == 'SunOS':
|
||||
module.fail_json(msg="Solaris does not support special_time=... or @reboot")
|
||||
|
||||
if cron_file and do_install:
|
||||
|
@ -667,9 +642,6 @@ def main():
|
|||
if (insertafter or insertbefore) and not env and do_install:
|
||||
module.fail_json(msg="Insertafter and insertbefore parameters are valid only with env=yes")
|
||||
|
||||
if reboot:
|
||||
special_time = "reboot"
|
||||
|
||||
# if requested make a backup before making a change
|
||||
if backup and not module.check_mode:
|
||||
(backuph, backup_file) = tempfile.mkstemp(prefix='crontab')
|
||||
|
|
|
@ -91,8 +91,9 @@
|
|||
- assert:
|
||||
that: remove_task_idempotence is not changed
|
||||
|
||||
- name: Check that removing a cron task with cron_file and without specifying an user is allowed (#58493)
|
||||
- name: Check that removing a cron task with cron_file and without specifying a user is allowed (#58493)
|
||||
cron:
|
||||
name: test cron task
|
||||
cron_file: unexistent_cron_file
|
||||
state: absent
|
||||
register: remove_cron_file
|
||||
|
|
|
@ -103,7 +103,6 @@ lib/ansible/modules/copy.py pylint:blacklisted-name
|
|||
lib/ansible/modules/copy.py validate-modules:doc-default-does-not-match-spec
|
||||
lib/ansible/modules/copy.py validate-modules:nonexistent-parameter-documented
|
||||
lib/ansible/modules/copy.py validate-modules:undocumented-parameter
|
||||
lib/ansible/modules/cron.py pylint:ansible-deprecated-version
|
||||
lib/ansible/modules/dnf.py validate-modules:doc-required-mismatch
|
||||
lib/ansible/modules/dnf.py validate-modules:parameter-invalid
|
||||
lib/ansible/modules/file.py validate-modules:doc-default-does-not-match-spec
|
||||
|
|
Loading…
Reference in a new issue