When running an Ansible playbook with the command ansible-playbook -i <playbook>
, you may encounter the following error:
PLAY [my_hosts] ************************************************************************************************************************************************************************************************************************
ERROR! Unexpected Exception, this is probably a bug: No module named 'distutils'
to see the full traceback, use -vvv
This error indicates that the ‘distutils’ module is missing, which is required by Ansible. To resolve this issue on Ubuntu, you can install the necessary package using the following command:
pip install setuptools
Collecting setuptools
Using cached setuptools-75.8.0-py3-none-any.whl.metadata (6.7 kB)
Using cached setuptools-75.8.0-py3-none-any.whl (1.2 MB)
Installing collected packages: setuptools
Successfully installed setuptools-75.8.0
By installing the setuptools
package, you will ensure that the ‘distutils’ module is available for Ansible to use, resolving the error you encountered while running the playbook.