Get your taxes done using TurboTax

if you don't rent it the rules are simple. own any occupy the primary residence for any 2 years in the five years before the sale. 

the same rule applies if you were to rent it for a period before the sale. but you must take depreciation during the rental period and when you sell that part of the gain is taxable