diff --git a/changelogs/fragments/nxos_facts_fix_backport_fix.yaml b/changelogs/fragments/nxos_facts_fix_backport_fix.yaml new file mode 100644 index 00000000000..be60f80353c --- /dev/null +++ b/changelogs/fragments/nxos_facts_fix_backport_fix.yaml @@ -0,0 +1,2 @@ +bugfixes: +- nxos_facts fix diff --git a/lib/ansible/modules/network/nxos/nxos_facts.py b/lib/ansible/modules/network/nxos/nxos_facts.py index 3c364c6da6a..6afc029ac38 100644 --- a/lib/ansible/modules/network/nxos/nxos_facts.py +++ b/lib/ansible/modules/network/nxos/nxos_facts.py @@ -881,7 +881,7 @@ class Legacy(FactsBase): def parse_module(self, data): objects = list() for line in data.splitlines(): - if line == '': + if line == '' or re.search(r'\b' + 'Sw' + r'\b', line): break if line[0].isdigit(): obj = {} @@ -901,7 +901,7 @@ class Legacy(FactsBase): if items: obj['type'] = items[0] obj['model'] = items[1] - obj['status'] = items[2] + obj['status'] = items[-1] objects.append(obj) return objects @@ -915,9 +915,11 @@ class Legacy(FactsBase): line = l.split() if len(line) > 1: obj = {} + if re.search(r'Direction', data, re.M): + obj['direction'] = line[-2] obj['name'] = line[0] obj['model'] = line[1] - obj['hw_ver'] = line[-2] + obj['hw_ver'] = line[2] obj['status'] = line[-1] objects.append(obj) return objects