summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsdc <taras@vyos.io>2024-02-06 16:09:36 +0200
committerzdc <zdc@users.noreply.github.com>2024-02-06 16:18:44 +0200
commit412287741b70b536458d84972257eda0b3c18d9f (patch)
treeb34181f269773b1244a5add91d99a6ada9380481
parent3e026561f4787d2b6e634b8d170dc3fade85a96f (diff)
downloadvyos-cloud-init-412287741b70b536458d84972257eda0b3c18d9f.tar.gz
vyos-cloud-init-412287741b70b536458d84972257eda0b3c18d9f.zip
cc_vyos: T6007: Run config migrations before Cloud-init
Configuration in `vyos_config_commands` is expected to use a syntax from the target VyOS version. But, if Cloud-init applies configuration commands to a default file, all the migrations (from the 0 version to the latest) will still be executed on top of it. This process can break proper config, for example, if the current syntax variant partially repeats one of the older ones, which will trigger a migration without need.
-rw-r--r--cloudinit/config/cc_vyos.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/cloudinit/config/cc_vyos.py b/cloudinit/config/cc_vyos.py
index 550811b7..eaa873d6 100644
--- a/cloudinit/config/cc_vyos.py
+++ b/cloudinit/config/cc_vyos.py
@@ -1081,6 +1081,10 @@ def handle(name, cfg, cloud, log, _args):
file_name = cfg_file_name
logger.debug("Using configuration file: {}".format(file_name))
+ # We must run all migrations on the config before Cloud-init will modify it
+ # Otherwise, regardless of proper syntax for the current version, migrations will be re-run with unpredictable result
+ logger.debug("Running migrations for: {}".format(file_name))
+ run(['/usr/libexec/vyos/run-config-migration.py', file_name])
with open(file_name, 'r') as f:
config_file = f.read()
config = ConfigTree(config_file)