diff --git a/plugins/modules/logrotate.py b/plugins/modules/logrotate.py index c7cf8a74fe..c659ea0b53 100644 --- a/plugins/modules/logrotate.py +++ b/plugins/modules/logrotate.py @@ -249,10 +249,6 @@ options: - Whether the configuration should be enabled. - When V(false), adds V(.disabled) extension to the config file. type: bool - backup: - description: - - Make a backup of the logrotate config file before changing it. - type: bool start: description: - Base number for rotated files. @@ -446,11 +442,6 @@ config_content: echo 'Nginx logs rotated' endscript } -backup_file: - description: Path to the backup file if backup was created. - type: str - returned: when backup was created - sample: /etc/logrotate.d/nginx.backup enabled_state: description: Current enabled state of the configuration. type: bool @@ -460,7 +451,6 @@ enabled_state: import os import re -from datetime import datetime from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.common.text.converters import to_native @@ -773,24 +763,6 @@ class LogrotateConfig: return "\n".join(lines) - def _backup_config(self, config_path: str) -> str | None: - """Create backup of existing configuration.""" - if not os.path.exists(config_path): - return None - - if self.params.get("backup"): - try: - # Используем встроенный механизм Ansible для создания бэкапа - backup_file = self.module.backup_local(config_path) - self.result["backup_file"] = backup_file - return backup_file - except Exception as e: - self.module.fail_json( - msg=f"Failed to create backup of {config_path}: {to_native(e)}" - ) - - return None - def apply(self) -> dict[str, object]: """Apply logrotate configuration.""" self._validate_parameters() @@ -807,7 +779,6 @@ class LogrotateConfig: config_path = os.path.join(self.config_dir, self.config_name + suffix) if os.path.exists(config_path): if not self.module.check_mode: - self._backup_config(config_path) os.remove(config_path) self.result["changed"] = True self.result["config_file"] = config_path @@ -832,7 +803,6 @@ class LogrotateConfig: if os.path.exists(old_path) and not os.path.exists(new_path): self.result["changed"] = True if not self.module.check_mode: - self._backup_config(old_path) self.module.atomic_move(old_path, new_path, unsafe_writes=False) self.result["config_file"] = new_path @@ -942,7 +912,6 @@ def main() -> None: include=dict(type="path"), tabooext=dict(type="list", elements="str"), enabled=dict(type="bool"), - backup=dict(type="bool"), start=dict(type="int"), syslog=dict(type="bool"), ),