diff --git a/changelogs/fragments/57698-update-ce_facts-to-fix-array-out-of-range-bug.yml b/changelogs/fragments/57698-update-ce_facts-to-fix-array-out-of-range-bug.yml new file mode 100644 index 00000000000..e14150c768b --- /dev/null +++ b/changelogs/fragments/57698-update-ce_facts-to-fix-array-out-of-range-bug.yml @@ -0,0 +1,2 @@ +bugfixes: + - update ce_facts to fix array out of range bug(https://github.com/ansible/ansible/pull/57187). diff --git a/lib/ansible/modules/network/cloudengine/ce_facts.py b/lib/ansible/modules/network/cloudengine/ce_facts.py index d4849ea8a44..ceff0238207 100644 --- a/lib/ansible/modules/network/cloudengine/ce_facts.py +++ b/lib/ansible/modules/network/cloudengine/ce_facts.py @@ -324,7 +324,10 @@ class Interfaces(FactsBase): tmp_neighbors = neighbors[2:] for item in tmp_neighbors: tmp_item = item.split() - neighbors_dict[tmp_item[0]] = tmp_item[3] + if len(tmp_item) > 3: + neighbors_dict[tmp_item[0]] = tmp_item[3] + else: + neighbors_dict[tmp_item[0]] = None self.facts['neighbors'] = neighbors_dict