diff --git a/plugins/modules/sonic_config.py b/plugins/modules/sonic_config.py index 7f91d17..3116311 100644 --- a/plugins/modules/sonic_config.py +++ b/plugins/modules/sonic_config.py @@ -420,10 +420,12 @@ def _genBGP(self, parser, newConf): if not newConf: return senseasn = newConf.get("asn", None) - runnasn = parser.running_config.get("bgp", {}).get("asn", None) if not senseasn: return - if runnasn and int(senseasn) != int(runnasn): + runnasn = parser.running_config.get("bgp", {}).get("asn", None) + if not runnasn: + return + if int(senseasn) != int(runnasn): msg = "Running ASN != SENSE ASN (%s != %s)" % (runnasn, senseasn) raise Exception(msg) # Append only if any new commands are added.