mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-30 07:18:09 +02:00
Refactor systemctl service handling with @ support
- Unified variable naming: system_service_id → systemctl_id - Added automatic removal of trailing '@' for role directory resolution - Improved first_found search: prefer target role, fallback to sys-systemctl defaults - Split template resolution logic to avoid undefined variable errors - Added assertion in sys-timer to forbid '@' in systemctl_id - Corrected default systemctl.service.j2 template description - Cleaned up path handling and script directory generation Context: conversation about fixing template resolution and @ handling https://chatgpt.com/share/68a39994-1bb0-800f-a219-109e643c3efb
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
# filter_plugins/get_service_script_path.py
|
||||
# Custom Ansible filter to generate service script paths.
|
||||
|
||||
def get_service_script_path(system_service_id, script_type):
|
||||
def get_service_script_path(systemctl_id, script_type):
|
||||
"""
|
||||
Build the path to a service script based on system_service_id and type.
|
||||
Build the path to a service script based on systemctl_id and type.
|
||||
|
||||
:param system_service_id: The identifier of the system service.
|
||||
:param systemctl_id: The identifier of the system service.
|
||||
:param script_type: The script type/extension (e.g., sh, py, yml).
|
||||
:return: The full path string.
|
||||
"""
|
||||
if not system_service_id or not script_type:
|
||||
raise ValueError("Both system_service_id and script_type are required")
|
||||
if not systemctl_id or not script_type:
|
||||
raise ValueError("Both systemctl_id and script_type are required")
|
||||
|
||||
return f"/opt/scripts/{system_service_id}/script.{script_type}"
|
||||
return f"/opt/scripts/{systemctl_id}/script.{script_type}"
|
||||
|
||||
|
||||
class FilterModule(object):
|
||||
|
Reference in New Issue
Block a user