summaryrefslogtreecommitdiff
path: root/plugins/modules
diff options
context:
space:
mode:
authorlucaelin <git@luca.lsys.ac>2026-02-23 13:25:35 +0100
committerGitHub <noreply@github.com>2026-02-23 12:25:35 +0000
commite539028c2f9d062e7684abda5dd32affd92e9f08 (patch)
tree26bdccd9ae304c9d4eef843e60eb61f7ad54e3df /plugins/modules
parent8d96e7a700d30667c594ab7880538451f60d7fb4 (diff)
downloadvyos.vyos-e539028c2f9d062e7684abda5dd32affd92e9f08.tar.gz
vyos.vyos-e539028c2f9d062e7684abda5dd32affd92e9f08.zip
add commit-confirm options to vyos_config (#229)
* added vyos_config confirm options * fix: update commit comment to match main * fix: documentation example for automatic confirm * fix: add tests for commit confirm and confirm_timeout options * fix: add config_confirm changelog fragment * fix: lint missing diff parameter for edit_config * fix: add commit confirm integration test --------- Co-authored-by: omnom62 <75066712+omnom62@users.noreply.github.com>
Diffstat (limited to 'plugins/modules')
-rw-r--r--plugins/modules/vyos_config.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/plugins/modules/vyos_config.py b/plugins/modules/vyos_config.py
index eeb6bc44..a9774638 100644
--- a/plugins/modules/vyos_config.py
+++ b/plugins/modules/vyos_config.py
@@ -84,6 +84,25 @@ options:
is ignored.
default: configured by vyos_config
type: str
+ confirm:
+ description:
+ - The C(confirm) argument will tell vyos to revert to the previous configuration
+ if not explicitly confirmed after applying the new config. When set to C(automatic)
+ this module will automatically confirm the configuration, if the current session
+ remains working with the new config. When set to C(manual), this module does
+ not issue the confirmation itself.
+ type: str
+ default: none
+ choices:
+ - automatic
+ - manual
+ - none
+ confirm_timeout:
+ description:
+ - Minutes to wait for confirmation before reverting the configuration. Does
+ not apply when C(confirm) is set to C(none) .
+ type: int
+ default: 10
config:
description:
- The C(config) argument specifies the base configuration to use to compare against
@@ -142,6 +161,11 @@ EXAMPLES = """
vyos.vyos.vyos_config:
src: vyos_template.j2
+- name: revert after ten minutes, if connection is lost
+ vyos.vyos.vyos_config:
+ src: vyos_template.j2
+ confirm: automatic
+
- name: for idempotency, use full-form commands
vyos.vyos.vyos_config:
lines:
@@ -310,10 +334,15 @@ def run(module, result):
commit = not module.check_mode
comment = module.params["comment"]
+ confirm = None
+ if module.params["confirm"] == "automatic" or module.params["confirm"] == "manual":
+ confirm = module.params["confirm_timeout"]
diff = None
if commands:
- diff = load_config(module, commands, commit=commit, comment=comment)
+ diff = load_config(module, commands, commit=commit, comment=comment, confirm=confirm)
+ if module.params["confirm"] == "automatic":
+ run_commands(module, ["configure", "confirm", "exit"])
if result.get("filtered"):
result["warnings"].append(
@@ -333,6 +362,8 @@ def main():
lines=dict(type="list", elements="str"),
match=dict(default="line", choices=["line", "none"]),
comment=dict(default=DEFAULT_COMMENT),
+ confirm=dict(choices=["automatic", "manual", "none"], default='none'),
+ confirm_timeout=dict(type="int", default=10),
config=dict(),
backup=dict(type="bool", default=False),
backup_options=dict(type="dict", options=backup_spec),