diff --git a/ansible/library/bgp_facts.py b/ansible/library/bgp_facts.py index f6ec49dde06..044950c69cd 100644 --- a/ansible/library/bgp_facts.py +++ b/ansible/library/bgp_facts.py @@ -1,4 +1,5 @@ #!/usr/bin/python +import re DOCUMENTATION = ''' module: bgp_facts @@ -76,6 +77,14 @@ def run(self): """ Main method of the class """ + + # Check if bgp is enabled as a feature, and if not return facts with empty bgp_neighbors. + rc, self.out, err = self.module.run_command("show feature status bgp", executable='/bin/bash', + use_unsafe_shell=True) + regex_bgp = re.compile(r'bgp\s+disabled') + if regex_bgp.search(self.out): + self.module.exit_json(ansible_facts=self.facts) + for instance in self.instances: self.collect_data('summary', instance) self.parse_summary()