Variables not evaluating

I have a clean new fusionpbx install.

Outbound SIP calls via a gateway are not working because they are inviting the internal IP. SIP Profile external ext-sip-ip is set to $${external_sip_ip}

Variable external_sip_ip is set to an outside address 202.x.x.x

The variable won't evaluate correctly in fs_cli. A test variable won't evaluate at all.

I suspect variable handling is broken, but not sure how to debug this. How do vars get from db to freeswitch?

freeswitch@fones> eval $${external_sip_ip}           <<< naughty, should be external ip

freeswitch@fones> eval $${testpexy}
-ERR no reply       <<< naughty, should be test value 123
Digging a bit deeper, file /etc/freeswitch/vars.xml is not being written.

On another system, any changes to Advanced/Variables are written to the above file on save by the FusionPBX web interface.

On this problem system, that file is not being updated.
Would be useful to know what operating system this is and how FusionPBX was installed.
Default Settings you should check category Switch look for subcategory conf type dir value /etc/freeswitch and enabled true.

Next make sure the web server has permission to write to the /etc/freeswtch directory. That should be enough to fix it. Unless its CentOS and SELinux is preventing it writing to the file system.
Fantastic Mark

Web Interface::Advanced:: Default Settings::Switch::conf was indeed blank.

OS is Debian 8 via LXC on Proxmox 5.2. Install was done by one of my team, because I thought it was a straight forward task. Not sure how he did it or messed it up.

Yes, permissions ok and checked, owned by www-data.

Thanks for the very useful lead.
If FreeSWITCH is running and you deleted the blank settings in Default Settings::Switch then you can run Upgrade -> App Defaults and it will make a request for information from FreeSWITCH to add the correct information to Default Settings. This is an easy way to get a wayward system back on track. After you get the correct values click on the Reload button on the top right. chown -R www-data:www-data /etc/fusionpbx/config.lua so that it can be updated and then run Upgrade -> App defaults this should rewrite the config.lua with the updated information. Then restart FreeSWITCH with service freeswitch restart.