Take one of the Morocco crisis, have France and Britain gang up on Spain to give Spanish Morocco to France. Then have the Spanish people enraged over this combined with some really arrogant statements in the British Press, and Spain could be a part of the CP by 1910.
It was France and Britain who agreed to make a Spanish Morocco in the first place.
In fact, if we just keep the ball rolling as it was during one of the Morocco crisis and war is declared it's almost a given that Spain would join against Germany. Spain did send ships to Moroccan waters and occupied Larache & Alcazarquivir in response to the Agadir Crisis in OTL.
Another earlier POD would be to avoid the Spanish-American War altogether, and then just continue with OTL events more or less. This results in the Ferrol naval academy not closing down for a decade and a larger Spanish naval presence, and avoids the deadset neutrality policy adopted in the aftermath of the war. Once Germany adopts unrestricted submarine warfare (a policy that resulted in the loss of several Spanish merchant ships and deeply damaged German-Spanish relations IOTL), Spain would join the Allies much like Portugal did, and with the same results (i.e. skyrocketing debt and token gains in Africa).
For Spain to join Germany it would require a very early POD in the 19th century. Going against France is unlikely, going against Britain is even more unlikely, and going against both at the same time dinamitates two centuries worth of national policy.