Error message: Set failed

Sometimes after a misconfiguration I can’t change configuration because of the following error messages:

# Some set command results in
Set failed

and

# Some del command results in
Failed to delete specified config path
Delete failed

After a reboot I can configure again. Is there a way to restart the configuration service so I can configure again without a reboot?

Thank you for your help!

Does “exit discard” not work?

Hello carl.byington,

First I have to clarify what I mean by misconfiguration. I’m using an ansible-vyos role to import configuration-file into the VyOS-router.

The import of this file is executed by the following commands:

/opt/vyatta/sbin/my_cli_shell_api loadFile configuration_file
/opt/vyatta/sbin/my_commit
/opt/vyatta/sbin/vyatta-save-config.pl

This works great. But sometimes I make a syntax error in the configuration file which results in parts not being commited.

After I login the router and enter into the configuration-mode, the set- and del-commands are not working anymore. Unless I reboot.

Perhaps a process is messed up because I’ve tried to commit a syntax error with the api?

I think that any automated system that tries to load configuration data needs to either

  1. somehow validate the config so it never tries to load an invalid configuration

or

  1. feed the (possibly invalid) configuration in one line at a time, and watch the output for error messages. Assuming a python script:
proc = subprocess.Popen('ssh -t -t vyos@router', shell=True, close_fds=True, bufsize=4096, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
proc.stdin.write('set ...\n')
proc.stdin.write('commit\n')
rc=proc.stdout.readline()

I wonder if it is rejecting your changes because there is still a configuration session open from the API, and you have to close out that configuration session by discarding its changes?

If so then your script would have to detect when a command failed, and then issue a discard command. Probably a good idea anyway; I’m going to go modify my own scripts to do the same.

This can also be a permission problem.

If so then running
sudo chown -R root:vyattacfg /opt/vyatta/config/active/

will fix it. I added to my own vyos ansible module (not yet released)

if [ “$(id -g -n)” != ‘vyattacfg’ ] ; then
exec sg vyattacfg -c “/bin/vbash $(readlink -f $0) $@”
fi

Thanks to dmbaturin for the tip on ‘sg’ and confirmation on the permissions fix.