From 636e1d5fcbc9b309f93f033cc77d4f03d8413df6 Mon Sep 17 00:00:00 2001 From: Jan-Philipp Litza Date: Wed, 9 Jan 2019 16:56:30 +0100 Subject: [PATCH] Fix sanitizing config lines (#50553) Previously, the index got out of sync with the actual config list. Invoked with lines: - bad - first - bad - second the sanitization would first delete index 0 and then index 2, which would result in the output - first - bad By reversing the list, we avoid that problem (though a filter() would be nicer) --- lib/ansible/modules/network/edgeos/edgeos_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/network/edgeos/edgeos_config.py b/lib/ansible/modules/network/edgeos/edgeos_config.py index 8a484154813..260e9bb2353 100644 --- a/lib/ansible/modules/network/edgeos/edgeos_config.py +++ b/lib/ansible/modules/network/edgeos/edgeos_config.py @@ -207,7 +207,7 @@ def diff_config(commands, config): def sanitize_config(config, result): result['filtered'] = list() for regex in CONFIG_FILTERS: - for index, line in enumerate(list(config)): + for index, line in reversed(list(enumerate(config))): if regex.search(line): result['filtered'].append(line) del config[index]