It was absolutely a contributing factor. It started in Feb. 1918. The war was one of attrition and with soldiers and workers in Germany either sick or dying of flu, it absolutely played a role in the end of the war. Especially with fresh troops coming from thr US. Is it the only factor? Of course not. Marxist revolutaries in Germany played a role as did homefront weariness over the war effort. German soldiers were underfed and the ability of Germany to keep them fed and armed was becoming more and more difficult
Interestingly, Germany was close to winning the war at the start of 1918 and had they taken Paris the war would have ended. (They were a few miles away) Despite being pushed back, the war was never fought on German soil in the west. Revolutaries at home, starving people and a deadly flu were all contributing factors to their request for an armistice.