Skip to content

Commit 93aad26

Browse files
committed
vyos_config smart diffing ... special value
1 parent b834432 commit 93aad26

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- vyos_config - Added new `match`-value `smart` with updated configuration diffing for more reproducible provisioning of devices.

plugins/cliconf_utils/vyosconf.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import re
2222

23+
KEEP_EXISTING_VALUES = "..."
24+
2325

2426
class VyosConf:
2527
def __init__(self, commands=None):
@@ -188,15 +190,15 @@ def diff_to(self, other, structure):
188190
(subset, subdel) = self.diff_to(other[key], structure[key])
189191
for s in subset:
190192
toset.append(quoted_key + " " + s)
191-
if "!" not in other[key]:
193+
if KEEP_EXISTING_VALUES not in other[key]:
192194
for d in subdel:
193195
todel.append(quoted_key + " " + d)
194196
else:
195197
# keys only in this, pls del
196198
todel.append(quoted_key)
197199
continue # del
198200
for (key, value) in other.items():
199-
if key == "!":
201+
if key == KEEP_EXISTING_VALUES:
200202
continue
201203
quoted_key = "'" + key + "'" if " " in key or '"' in key else key
202204
if key not in structure:

plugins/modules/vyos_config.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@
6161
active configuration. By default, the configuration commands config are
6262
matched against the active config and the deltas are loaded line by line.
6363
If the C(match) argument is set to C(none) the active configuration is ignored
64-
and the configuration is always loaded. If the C(match) argument is set to C(smart)
65-
both the active configuration and the target configuration are simlulated
64+
and the configuration is always loaded. If the C(match) argument is set to
65+
C(smart) both the active configuration and the target configuration are simlulated
6666
and the results compared to bring the target device into a reliable and
67-
reproducable state.
67+
reproducable state. Using C(smart), the special value C(...) indicates that
68+
this keys value should not be changed and any preexisting siblings should not
69+
be removed from the target.
6870
type: str
6971
default: line
7072
choices:

0 commit comments

Comments
 (0)