In some cases, you may see the WHM API call set_primary_servername does not work as expected with edits made to the Apache template files.
If you have adjusted the Apache template file to have your IP address defined for the VirtualHost manually, this will prevent the API call set_primary_servername from properly changing the primary server name within the Apache configuration.
We've opened an internal case for our development team to investigate this further. For reference, the case number is CPANEL-37082. Follow this article to receive an email notification when a solution is published in the product.
At this time, you will want to move aside to all of the local template files, then rebuild the Apache configuration file and restart Apache. Doing that should allow you to set the primary server name as intended.