diff --git a/lib/ansible/modules/network/junos/junos_config.py b/lib/ansible/modules/network/junos/junos_config.py index efab50a41e7..6328fb55732 100644 --- a/lib/ansible/modules/network/junos/junos_config.py +++ b/lib/ansible/modules/network/junos/junos_config.py @@ -217,18 +217,19 @@ def diff_commands(commands, config): updates = list() visited = set() - for item in commands: - if not item.startswith('set') and not item.startswith('delete'): - raise ValueError('line must start with either `set` or `delete`') - - elif item.startswith('set') and item[4:] not in config: - updates.append(item) - - elif item.startswith('delete'): - for entry in config: - if entry.startswith(item[7:]) and item not in visited: - updates.append(item) - visited.add(item) + for item in commands.split('\n'): + if len(item) > 0: + if not item.startswith('set') and not item.startswith('delete'): + raise ValueError('line must start with either `set` or `delete`') + + elif item.startswith('set') and item[4:] not in config: + updates.append(item) + + elif item.startswith('delete'): + for entry in config: + if entry.startswith(item[7:]) and item not in visited: + updates.append(item) + visited.add(item) return updates