How was Madara so sure that he would be able to get his Rinnegan back? To implement his Infinite Tsukuyomi plan, Madara would have to get his Rinnegan back. Given his propensity to plan everything, he had to have a plan when he died the first time. How did he plan to get the Rinnegan back?

He could not have expected Nagato to die becase that was pretty random. What he probably was expecting was that Nagato would be alive and that he would not cooperate with himself or Obito. So did he think that black Zetsu could overpower Nagato and order him to use Rinne Rebirth? But if Black Zetsu can overpower a Ninja as powerful as Nagato could he not have simply overpowered Hagoromo at the very beginning and be done with it?

The second possibility is that Black Zetsu can only overpower a ninja who has already been weakened. There are apparently three versions of Edo Tensei: Tobirama's, Orochimaru's, and Kabuto's. Madara could not have possibly known about Kabuto's version (he died before it was developed), he may or may not have known about Orochimaru's version. Was it not incredibly optimistic of him to expect to defeat alive Nagato as either Tobirama-style or Orochimaru-style Edo Tensei?
As Madara himself said his plan was to be resurrected through the use of Rinne Rebirth by Nagato. He was surprised and disappointed that his return didn't go as planned. He didn't want the Edo Tensei, as only a living person can become the Ten-Tails' jinchūriki.

Considering that the usage of the Rinne Rebirth always comes at the cost of the user's life it wouldn't be a problem for Madara to then take the Rinnegan from Nagato's corpse.

How exactly they wanted to force Nagato to resurrect Madara is unknown. It could be simply Obito convincing him that it would be the necessary next step in their plan towards world peace or by forcing him to use it via Genjutsu or a Zetsu takeover. 


  But if Black Zetsu can overpower a Ninja as powerful as Nagato could he not have simply overpowered Hagoromo at the very beginning and be done with it?


Nagato was far less powerful than Hagoromo. It pushed Nagato to the brink to trap Naruto inside his Chibaku Tensei, which was - as he told Konan - nothing compared to the creation of the moon by Hagoromo.