If you install solar panels and then have to replace your roof because it’s old, you will have to remove the panels and mountings before they can replace the roof. If your roof is close to the end of its life, you should look at replacement prior to adding the panels. Tell your roof of your intent to go solar and see if they have any recommendations.