diff --git a/anta/tests/system.py b/anta/tests/system.py index 84e050c1d..ec8925002 100644 --- a/anta/tests/system.py +++ b/anta/tests/system.py @@ -366,9 +366,6 @@ def test(self) -> None: for ntp_server in self.inputs.ntp_servers: server_address = str(ntp_server.server_address) - # Collecting the expected NTP peer details. - expected_peer_details = {"condition": "sys.peer" if ntp_server.preferred else "candidate", "stratum": ntp_server.stratum} - # Check if NTP server details exists. matching_peer = next((peer for peer in peer_details if server_address in peer), None) @@ -376,6 +373,9 @@ def test(self) -> None: failures += f"NTP peer {server_address} is not configured.\n" continue + # Collecting the expected NTP peer details. + expected_peer_details = {"condition": "sys.peer" if ntp_server.preferred else "candidate", "stratum": ntp_server.stratum} + # Collecting the actual NTP peer details. actual_peer_details = { "condition": get_value(peer_details[matching_peer], "condition"),