"Pulmonary nodules" is a descriptive x-ray term. There are a number of causes of pulmonary nodules, including infection and auto-immune disease. In either case, infection or not, cavitation, which is the formation of a cavity, can occur with the development of a lung abscess. The treatment of lung abscess requires the expertise to first diagnose the cause. You should seek consultation with a lung specialist, also called a pulmonologist. Infection can usually be treated with medicine alone but sometimes requires surgery. Key to successful treatment is the determination of the nature of the infecting organism, be it bacterial or fungal.
Non-infection cavitation is treated with medicine.