1) спросить у кого-то, спросить кого-то
e.g. спросить у мужа, спросить мужа
In modern Russian, both forms are used and both forms are correct. You may find discussion where natives assume that one of the forms is colloquial, but grammarians state that they both are equally used.
See # 5 in Д.Э. Розенталь. Пунктуация и управление в русском языке
upravlenie.academic.ru/2252/спросить
2) In poetry, songs and fairy tales, you may find this collocation (with or without the preposition) used in a technically incorrect way — with unanimated nouns. "Я спросил у месяца" is one of those. The noun "месяц" is unanimated but, in the poetic context, represents a living being and that is why the question could be asked to it or, to be precise, to him in this particular case. Normally, you can't спросить у стула // спросить стул or спросить у ясеня/ у тополя / у месяца / у облака / у осени — it doesn't make any sense.
In situations like this, the choice of the form (with or without the preposition) depends on the author's preference. In the song "Я спросил у ясеня, где моя любимая", the preposition is used for the sake of rhythm as it gives one more syllable.
I also think in situations like this, the form with the preposition is more frequent as its usage more clearly emphasizes or brings literary flair, and let distinguish it from "спросить что?"
3) Keep in mind that it's possible to use the verb спрашивать with unanimated nouns: спросить что?
See #1 and # 3 in upravlenie.academic.ru/2252/спросить