I hate to be the bearer of bad news, but it’s not your lemon tree that developed the nodules, it’s an armored scale infestation. (And a massive one, judging by the photo.) The ants are likely there for the honeydew, excreted by the insects - although most sources claim armored scale don’t produce it, so it may also be that they prey on them, but certainly not to an extent that would eliminate the infestation.
Scale is treatable, but you need to consider that the hard shell shields them from a lot of insecticides. The younger specimens can be treated more easily, for the adults, scraping or washing them off with rubbing alcohol is a start. If you can’t take the systemic (= absorbed through the plant’s roots) route, you need a lot of patience. Left untreated, the plant will die, it’s in a bad shape already and the scale insects are depriving it of nutrients.