Skip to content

Conversation

lucaelin
Copy link

SUMMARY

I've added an option to the vyos_config module to use commit-confirm with a given timeout instead of running a straight commit. This functionality is included in vyos and now exposed to the vyos_config module. If no confirmation is received by vyos, it will reboot into the previously existing config, as an attempt to restore functionality.

The module can also automatically confirm the configuration if the connection remains working after applying the new config, or not confirm the configuration for you, leaving it up to the user to allow further testing and manual confirmation.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

commit-confirm

ADDITIONAL INFORMATION

If you accidentally remove the interface configuration your playbook is using to connect to the router, you would previously get a timeout from the module, but the broken config would still remain on the device. This change allows you to specify a timeout, after which the router reboots into the old configuration.

- name: render a Jinja2 template onto the VyOS router
  vyos.vyos.vyos_config:
    src: "../files/{{ template }}.j2"
    match: smart
    save: yes
    confirm: automatic
- name: render a Jinja2 template onto the VyOS router and test it for one minute
  vyos.vyos.vyos_config:
    src: "../files/{{ template }}.j2"
    match: smart
    save: yes
    confirm: manual
    confirm_timeout: 1

- name: check connectivity
  vyos.vyos.vyos_ping:
    dest: 1.1.1.1
    
- name: confirm configuration
  vyos.vyos.vyos_command:
    commands: 
      - configure
      - confirm
      - exit

I think tests should be implemented for this feature, but I am not sure how. Can you point me in the right directions here please?

@Qalthos Qalthos added the feature This issue/PR relates to a feature request. label Sep 2, 2022
@sever-sever
Copy link
Member

@lucaelin, could you rebase/resolve conflicts?

@sever-sever sever-sever requested review from gaige and omnom62 and removed request for NilashishC and GomathiselviS January 20, 2025 11:20
@omnom62 omnom62 self-assigned this Apr 16, 2025
@omnom62 omnom62 requested a review from a team as a code owner April 22, 2025 21:43
@omnom62 omnom62 requested a review from dmbaturin April 22, 2025 21:43
@omnom62
Copy link
Contributor

omnom62 commented Apr 22, 2025

Manually resolved conflicts, testing

@andamasov andamasov requested a review from Copilot May 15, 2025 11:54
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for VyOS’s commit-confirm feature to the vyos_config module, allowing automatic or manual confirmation with a configurable timeout before reverting to the previous configuration.

  • Introduce confirm and confirm_timeout parameters to vyos_config
  • Propagate confirm to load_config and update commit in CLIConf to use commit-confirm
  • Add example usage for manual and automatic confirm workflows

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
plugins/modules/vyos_config.py Added confirm/confirm_timeout parameters and integrated logic
plugins/module_utils/network/vyos/vyos.py Extended load_config signature to pass confirm through to CLI
plugins/cliconf/vyos.py Updated edit_config and commit to support commit-confirm calls
Comments suppressed due to low confidence (2)

plugins/modules/vyos_config.py:102

  • Parameter docs say confirm_timeout is in minutes, but VyOS's commit-confirm expects seconds. Either convert minutes to seconds before invoking CLI or clarify the unit in the documentation.
-    - Minutes to wait for confirmation before reverting the configuration. Does

plugins/modules/vyos_config.py:337

  • New confirm and confirm_timeout flows aren’t covered by existing tests. Consider adding unit or integration tests to validate manual and automatic confirmation behavior, including timeout and revert logic.
    confirm = None

- name: revert after ten minutes, if connection is lost
vyos.vyos.vyos_config:
src: vyos_template.j2
confirm: yes
Copy link
Preview

Copilot AI May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example uses confirm: yes, but valid choices are automatic, manual, or none. Update the example to a supported value (e.g., confirm: manual).

Suggested change
confirm: yes
confirm: manual

Copilot uses AI. Check for mistakes.

Comment on lines +199 to +204
command = 'commit-confirm {0} comment {1}'.format(confirm, comment)
else:
command = 'commit-confirm {0}'.format(confirm)
else:
command = "commit"
self.send_command(command)
if comment:
command = 'commit {0}'.format(comment)
Copy link
Preview

Copilot AI May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI call omits the comment keyword and quotes, producing commit foo instead of commit comment "foo". It should be commit comment "<message>" to handle spaces and match VyOS syntax.

Copilot uses AI. Check for mistakes.

Copy link

github-actions bot commented Jul 22, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@omnom62
Copy link
Contributor

omnom62 commented Aug 24, 2025

I have read the CLA Document and I hereby sign the CLA

@lucaelin
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

vyosbot added a commit to vyos/vyos-cla-signatures that referenced this pull request Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request.
Development

Successfully merging this pull request may close these issues.

4 participants