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?
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)
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.