OPNsense Forum

English Forums => General Discussion => Topic started by: Martienskie on April 06, 2022, 07:16:21 PM

Title: New config.xml via scp gets overwritten by current config
Post by: Martienskie on April 06, 2022, 07:16:21 PM
Hello all,

I try to implement some automation to easily change the config of a running opnsense instance (in my case a vm).

Currently, I change the /conf/config.xml by using scp from another device. When I go check in a shell whether the file has changed, it did. But when I exit and get back in the shell or restart, the newly uploaded config is reverted to the previous/current config.

Deleting /conf/config.xml and everything in /conf/backup triggers opnsense to use /usr/local/etc/config.xml but changing that config gives me exceptions or unexpected results.

How can I consistently upload a new config via cli which is used after reboot or a reload? 
Title: Re: New config.xml via scp gets overwritten by current config
Post by: zerwes on April 06, 2022, 08:49:57 PM
I use the same scenario via ansible (https://github.com/Rosa-Luxemburgstiftung-Berlin/ansible-opnsense)
After the cfg is changed under the hood (https://github.com/Rosa-Luxemburgstiftung-Berlin/ansible-opnsense/blob/main/tasks/main.yml#L248:L254) the playbook calls configctl filter sync (and optional configctl service reload all + configctl webgui restart) (https://github.com/Rosa-Luxemburgstiftung-Berlin/ansible-opnsense/blob/main/tasks/main.yml#L262:L283)
Title: Re: New config.xml via scp gets overwritten by current config
Post by: Martienskie on April 07, 2022, 03:32:53 PM
Thanks for your reply!

I figured out the problem after a lot of unnecessary troubleshooting. The template I used was putting a newline in the beginning and end of the config. That's why opnsense didn't accept and replaced it each time.

Just uploading the new config to /conf/config.xml and then rebooting did the trick.