Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aoscx_config is not failing in case of configuration error #123

Open
ssasso opened this issue Jan 7, 2025 · 1 comment
Open

aoscx_config is not failing in case of configuration error #123

ssasso opened this issue Jan 7, 2025 · 1 comment

Comments

@ssasso
Copy link

ssasso commented Jan 7, 2025

In case aoscx_config is supplied a config file with the src param, the playbook execution continues even if the source config file has invalid configuration in it.

I would have expected a module failure in case of invalid config, but this is not happening.

@ssasso
Copy link
Author

ssasso commented Jan 7, 2025

Quick & dirty proposal(s):

The config is sent to the device here:

load_config(module, commands)

and

https://github.com/aruba/aoscx-ansible-collection/blob/master/plugins/module_utils/aoscx.py#L124

Option (a):

It would be possible to return from load_config the stdout/stderr of every command invocation (out and err) and then:
if any of out (or err) contains the string ^Invalid input: (which is returned by the CLI in case of config command error) return an error instead of success - or, at least, return all the stdout/stderr to the user as a module output, and let the user decide what to do.

Option (b):

Directly edit the load_config to trigger an error (returing also the content of out - which will be useful to understand the broken command) in case it contains ^Invalid input: for a command.

Example (not tested nor validated):

        try:
            out = exec_command(module, command)
        except ConnectionError as exc:
            module.fail_json(
                msg="unable to enter configuration mode",
                err=to_text(exc, errors="surrogate_then_replace"),
            )
        if out.startswith("Invalid input:"):
            module.fail_json(
                msg="unable to send command",
                err=to_text(out, errors="surrogate_then_replace"),
            )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant