mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-21 08:11:12 +00:00
* fix(logrotate): add missing defaults and parameter validation declarations - Add default="present" to state parameter - Add default="/etc/logrotate.d" to config_dir parameter - Add required_by declarations for shred and compression parameters * fix(logrotate): fix runtime validation bugs, remove duplicate checks - Fix shred_cycles TypeError when value is None - Fix enabled=None handling in get_config_path - Remove duplicate runtime mutually_exclusive checks - Add runtime boolean truthiness checks - Add 'create' parameter format validation - Remove stale test method * fix(logrotate): restructure file operations, validate before write - Write content to tmpdir temp file, validate, then atomic move to destination. - Wrap all os.remove() calls in try/except with fail_json on error - Wrap all module.atomic_move() calls in try/except with fail_json on error - Also add self.mock_module.tmpdir = self.test_dir to test setUp for new code path * docs(logrotate): update DOCUMENTATION block - Add 'default: present' to state option - Add 'default: /etc/logrotate.d' to config_dir option * feat(logrotate): add optional backup parameter * chore: add logrotate fixes changelog fragment * chore(changelog/logrotate): use present tense singular * fix(logrotate): handle trailing spaces in create param Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * refactor(logrotate): remove redundant checks These are already handled by `required_if` statements in the module spec * refactor(logrotate): use tempfile to create temporary file * refactor(logrotate): remove redundant `bool()` casts on `target_enabled` `target_enabled` is guaranteed to be bool by this point. It's either the module param (typed bool) or falls back to `current_enabled` (also bool). The `bool()` wraps are no-ops. * refactor(logrotate): remove unused `self.config_file` attribute * refactor(logrotate): remove dead `any_state` parameter from `read_existing_config` * fix(logrotate): raise error instead of falling through on enabled-state rename failures * refactor(logrotate): tighten `get_config_path` sig to bool `None` callers are removed now so this is safe * test(logrotate): remove stale open mock assertion after tempfile refactor * style(logrotate): format file * chore(logrotate): add missing `version_added` attribute Co-authored-by: Felix Fontein <felix@fontein.de> * fix(logrotate): clean up temp file Co-authored-by: Felix Fontein <felix@fontein.de> * fix(logrotate): remove redundant temp file cleanup Co-authored-by: Felix Fontein <felix@fontein.de> * refactor(logrotate): Use dict subscript to access required backup param Co-authored-by: Felix Fontein <felix@fontein.de> * fix(logrotate): fix: only remove old config file when path differs from target Co-authored-by: Felix Fontein <felix@fontein.de> * fix(logrotate): update logrotate_bin type hint to str * feat(logrotate): add backup file handling when removing old config * style(logrotate): format file * test(logrotate): add missing backup default to `_setup_module_params` * test(logrotate): fix incorrect `os.remove` assertion in update test * refactor(logrotate): remove unnecessary `to_native()` call Co-authored-by: Felix Fontein <felix@fontein.de> * refactor(logrotate): replace str quotes with !r Co-authored-by: Felix Fontein <felix@fontein.de> * fix(logrotate): change backup default back to true * fix(logrotate): raise error when `shred_cycle`s is set with `shred=false` * docs(logrotate): clarify `shred_cycles` behaviour * fix(logrotate): remove to_native calls for exception messages * docs(logrotate): improve `config_dir` param description * refactor(logrotate): simplify backup file assignment logic * style(logrotate): format file * docs(logrotate): improve config_map description --------- Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein <felix@fontein.de>