A very simple variational approach to pure SUðNÞ Yang-Mills theory is proposed, based on the Gaussian effective potential in a linear covariant gauge. The method provides an analytical variational argument for mass generation. The method can be improved order by order by a perturbative massive expansion around the optimal trial vacuum. At finite temperature, a weak first-order transition is found (at T c ≈ 250 MeV for N ¼ 3) where the mass scale drops discontinuously. Above the transition the optimal mass increases linearly as expected for deconfined bosons. The equation of state is found in good agreement with the lattice data.