To be fair, I'm sure some amount of magic was involved, but the question still stands. Did armies ever try to position themselves in such a way that the sun would blind their enemies and put them at a disadvantage?
The sun gets mentioned a lot in Roman literary accounts of battles, though it is usually as a marker of time that had passed. However, there are a few mentions of the tactical significance of the sun in some battle or another. Livy says the following of the Roman and Carthaginian deployment at Cannae:
"The sun, very conveniently for both parties, shone on their flanks, whether this position was chosen designedly, or that it fell out by accident; for the Romans faced the south, the Carthaginians the north. The wind, which the natives of the country call Vulturnus, blew briskly against the Romans, and, by driving great quantities of sand into their faces, prevented them from seeing clearly." (Livy 22.46).
To my surprise, I had a bit of a look and couldn't find any other similar mentions however. That Livy emphasises it suggests that it must have been pretty common for one side or another to have the sun in their eyes and that this could be by design. I wish I could find more corroborative mentions of the sun being used by ancient armies to give a slight advantage. However, I might add that as a number of battles went for a number of hours, this advantage might only be short-lived. For what it's worth, Sun Tzu mentions the sun several times in his chapters on the "Army on the March" and "Terrain". Have a look here: just ctrl+f "sun", and (aside from getting "Sun Tzu says..." over and over) you'll see he talks about it quite a bit.
Of course, the sun could be an important factor in the result of a battle through the sheer heat of it. Livy mentions this in the Battle of Ilipa in 206 BC, where Hasdrubal Barca was defeated by Scipio in Spain:
"Hasdrubal’s troops began to grow faint, having been surprised by the alarm in the morning, and obliged to hasten out to the field before they could take food to support their strength. With a view to this, Scipio had taken care to create delay, for it was not until the seventh hour that the battalions of foot fell upon the wings, and the battle reached the centre somewhat later; so that, before the enemy began regularly to engage, they were enfeebled by the heat of the meridian sun, the labour of standing under arms, and by hunger and thirst, distressing them at once. They stood, therefore, leaning on their shields...The Romans were not far from the rampart; and, continuing their efforts, had nearly surmounted it, when such a quantity of rain poured suddenly down, that it was with difficulty they regained their camp. The sun too, had been excessively hot, as is usually the case when shining forth from among clouds surcharged with water; which added greatly to the fatigues of the day." (Livy 28.15).
And now in 193 BC, in a battle between a Roman consular army and a marauding army of Gauls in Italy:
"The left wing was withdrawn out of the action, and the right took its place, in the van. The intense heat of the sun discomposed the Gauls, whose bodies were very ill qualified to endure it: nevertheless, keeping their ranks close, and leaning sometimes on each other, sometimes on their bucklers, they withstood the attack of the Romans..." (Livy 35.5).
Ammianus Marcellinus also records the suffering of the Romans from the heat of the sun in Julian's ill-fated Persian campaign in AD 363:
"So by the weight of great strength the Parthians were driven back, and when the signal for retreat was given in the usual manner, our soldiers, long wearied by the fiery course of the sun, returned to their tents, encouraged to dare greater deeds of valour in the future. (25.1.18).
As such, the sun must have been one of the many factors that ancient generals kept in mind when siting their camps and planning battles. However, I can't think of any instance where the sun shining in the eyes of their opponents was decisive. Rather, the decisive element of the sun in ancient battles seems to have merely been the effects of heat in fatiguing and demoralising soldiers.
[Meta] Sometimes I'll see '1 comment' written under the OP, but I can't see any comments. Why?
This doesn't involve land armies but, before aircraft carried 3D radars on board, fighter aircraft would try to position themselves higher than their opponents so that they could dive at them from the sun. It was a viable tactic that led to gunners on larger aircraft being unable to locate diving attackers and smaller fighter pilots unable to maneuver since they did not know where the enemy was.
The Dicta Boelcke, a list of fundamental maneuvers from WW1 written by Oswald Boelcke, called to use the glare of the sun as a hiding spot to achieve surprise.
Chandragupta Maurya was supposed to have used this tactic in a battle. On the advise of Kautilya / Chankya, he arrayed his troops with the rising sun to his back, and used this as an advantage against his numerically superior foes.