AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Ansible troubleshooting - Error markupsafe — Video Tutorial

Resolve the No module named markupsafe error in Ansible by reinstalling Ansible, ansible-lint, and python-markupsafe via Homebrew.

Watch Video

Watch "Ansible troubleshooting - Error markupsafe" on YouTube

What You'll Learn

Full Tutorial Content

Introduction After upgrading Python to version 3.12 on your Mac using Homebrew, you encountered an error when trying to run Ansible: "`ERROR: No module named 'markupsafe'`". This issue arises because Ansible relies on certain Python modules, and in this case, it seems that the '`markupsafe`' module is missing or not properly installed. Let's go through the steps to resolve this issue: ```bash ERROR: No module named 'markupsafe' ``` DL;DR ```bash $ ansible ERROR: No module named 'markupsafe' $ brew uninstall ansible-lint ansible python-markupsafe $ brew install ansible-lint ansible python-markupsafe $ ansible --version ansible [core 2.15.6] config file = None configured module search path = ['/Users/lberton/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /opt/homebrew/Cellar/ansible/8.6.1/libexec/lib/python3.12/site-packages/ansible ansible collection location = /Users/lberton/.ansible/collections:/usr/share/ansible/collections executable location = /opt/homebrew/bin/ansible python version = 3.12.0 (main, Oct 2 2023, 12:03:24) [Clang 15.0.0 (clang-1500.0.40.1)] (/opt/homebrew/Cellar/ansible/8.6.1/libexec/bin/python) jinja version = 3.1.2 libyaml = True ``` Step 1: Identify the Problem The error message indicates that the 'markupsafe' module is not found. This module is a dependency for Ansible and needs to be installed. Step 2: Check for 'markupsafe' Installation First, let's check if the 'markupsafe' module is installed. Open your terminal and run: ```bash python3.12 -m pip show markupsafe ``` If the module is not installed, you will need to install it. If it's already installed, proceed to the next step. Step 3: Install 'markupsafe' Install the 'markupsafe' module using the following command: ```bash brew uninstall ansible ansible-lint python-markupsafe brew install python-markupsafe ``` This command uses Homebrew package manager, `brew`, to install the '`markupsafe`' module. Otherwise you can use: ```bash python3.12 -m pip install markupsafe ``` This command uses Python's package manager, `pip`, to install the '`markupsafe`' module. Step 4: Verify 'markupsafe' Installation After installing 'markupsafe', verify that the installation was successful: ```bash python3.12 -c "import markupsafe" ``` If there are no errors, the '`markupsafe`' module is now installed correctly. Step 5: Reinstall Ansible and Ansible-Lint Now that '`markupsafe`' is installed, you can proceed to reinstall Ansible and Ansible-Lint to ensure they are using the correct dependencies: ```bash brew uninstall ansible ansible-lint brew install ansible ansible-lint ``` This will uninstall the current versions and install them again with the correct dependencies, including 'markupsafe'. Step 6: Verify Ansible Installation Finally, check if Ansible is working without any errors: ```bash ansible --version ``` This should display the version information for Ansible without any 'markupsafe

About This Tutorial

Read the full written article: Ansible troubleshooting - Error markupsafe

Topics Covered

Related Video Tutorials