Issue
I was trying out some experiments with Ansible playbooks on Ubuntu Vagrant machine. I have written a simple playbook named exampleyum.yml as follows:
---
- hosts: local
tasks:
- name: Installing packages
yum: name=httpd state=latest
sudo: yes
When I run
ansible-playbook -i ~/inventory.ini exampleyum.yml
I am getting below error:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named yum fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_qeXrGO/ansible_module_yum.py\", line 25, in \n import yum\nImportError: No module named yum\n", "module_stdout": "", "msg": "MODULE FAILURE"}
It gives some import error and module failure. I read somewhere that Yum
is a core module
and hence it should work properly, but it doesn't. Any help would be appreciated. I am pretty new to Ansible.
Solution
I am running Ansible on Ubuntu Vagrant machine.
So why do you use yum
and not apt
module first of all?
If you still need yum
module for some reason, ensure that yum
python package is installed on the managed host.
Answered By - Konstantin Suvorov Answer Checked By - David Marino (WPSolving Volunteer)