mirror of
https://github.com/ansible/ansible.git
synced 2026-08-03 00:22:10 +02:00
service_facts: Handle KeyError while processing service name (#85572)
* service_facts: Handle KeyError while processing service name As a part of follow up review, * Handle KeyError with exception handling * Warn user about the missing service name in the given service details Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
---
|
||||
minor_changes:
|
||||
- service_facts - warn user about missing service details instead of ignoring.
|
||||
- service_facts - handle keyerror exceptions with warning.
|
||||
@@ -232,7 +232,11 @@ class ServiceScanService(BaseService):
|
||||
if service_name == "*":
|
||||
continue
|
||||
service_state = line_data[1]
|
||||
service_runlevels = all_services_runlevels[service_name]
|
||||
try:
|
||||
service_runlevels = all_services_runlevels[service_name]
|
||||
except KeyError:
|
||||
self.module.warn(f"Service {service_name} not found in the service list")
|
||||
continue
|
||||
service_data = {"name": service_name, "runlevels": service_runlevels, "state": service_state, "source": "openrc"}
|
||||
services[service_name] = service_data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user