I would agree that the NATO membership was just an excuse from Putin to attack Ukraine.
And it could be ideological, he believed that it is still with Russia, and since the government is anti-Putin, it has to be reminded that it was once was a part of Russia. And we may say that Putin has a nationalistic idea that he takes very seriously and no one can stop him from fighting for it even if it means attacking Ukraine and getting condemnation from the West.
The reason for Russia's military intervention in Ukraine is primarily deeply ideological. At the same time, the very entry of Ukraine into NATO does not pose any danger to Russia, because Russia has long had common borders in the west with NATO members - Latvia and Estonia. This is all fiction and the main reason here is different. Russia is now a sharply authoritarian state, where the people now have practically no rights. Their actual tsar Putin has unlimited power, and the country's legislative body, the State Duma, is such only on paper. Everyone who opposes Putin, regardless of position and rank, either goes to jail or is physically eliminated.
In Ukraine, in contrast to Russia, there is a high level of democracy and freedom of speech. This is very dangerous for the Putin regime. He is afraid of his people and is afraid that the Russian people will also want the same arrangement of society. By destroying Ukraine, Putin is destroying a threat to his rule.
In addition, Putin is very obsessed with the history and greatness of Russia. But with this without Ukraine is just a big problem. Everything that Russia has now in terms of history, all this has Ukrainian roots. Russia even got its name during the time of Tsar Peter the Great at the beginning of the 18th century. Prior to that, it was called the Moscow Principality or Muscovy. Russia, Russian, is borrowed from the name of a powerful state of the 9th-12th centuries, which existed on the territory of Ukraine and was called Kievan Rus with its center in Kyiv. The current Moscow at that time was a small settlement called Mokva and belonged to the prince of Kievan Rus Yuri Dolgoruky.
RUSSIAN, ROSS, RUSSIAN - the population of the territory of Russia, which originally (9th century) was a small section of the Dnieper Right Bank with a center in Kyiv and a southern border along the Ros River. The current name of Russia and the word "Russian" has nothing to do with the current territory of Russia, and therefore Putin hates Ukraine and wants to seize and appropriate its history by annexing this territory.