diff --git a/plugins/module_utils/main/wireguard_server.py b/plugins/module_utils/main/wireguard_server.py index ccb98fa4..afb2944c 100644 --- a/plugins/module_utils/main/wireguard_server.py +++ b/plugins/module_utils/main/wireguard_server.py @@ -123,10 +123,14 @@ def _find_peers(self) -> list: existing[peer['name']] = peer['uuid'] for peer in self.p['peers']: - if peer not in existing: + if peer not in existing and peer not in existing.values(): self.m.fail_json(f"Peer '{peer}' does not exist!") - peers.append(existing[peer]) + if peer in existing: + peers.append(existing[peer]) + + else: + peers.append(peer) return peers