2. If for all $\theta \in \mathbf{R}$, the complex number
$$
z=(a+\cos \theta)+(2 a-\sin \theta) \mathrm{i}
$$

has a modulus not exceeding 2, then the range of the real number $a$ is
$\qquad$.
2. $\left[-\frac{\sqrt{5}}{5}, \frac{\sqrt{5}}{5}\right]$.

According to the problem, we have
$$
\begin{array}{l}
|z| \leqslant 2 \\
\Leftrightarrow(a+\cos \theta)^{2}+(2 a-\sin \theta)^{2} \leqslant 4 \\
\Leftrightarrow 2 a(\cos \theta-2 \sin \theta) \leqslant 3-5 a^{2} \\
\Leftrightarrow-2 \sqrt{5} a \sin (\theta-\varphi) \leqslant 3-5 a^{2}
\end{array}
$$

This must hold for any real number $\theta$, where $\varphi=\arcsin \frac{1}{\sqrt{5}}$.
Thus, $2 \sqrt{5}|a| \leqslant 3-5 a^{2} \Rightarrow|a| \leqslant \frac{\sqrt{5}}{5}$. Therefore, $a \in\left[-\frac{\sqrt{5}}{5}, \frac{\sqrt{5}}{5}\right]$.