Skip to content
Advertisement

Ansible after ‘vagrant provision’ gives this error “Could not import python modules: apt, apt_pkg. Please install python-apt package.”

I have a very simple VagrantFile and Ansible Playbook. I just want to test install httpd. But every time I run vagrant provision after the VM is up I get this error:

JavaScript

This is my VagrantFile:

JavaScript

And this is my simple playbook.yml:

JavaScript

And my inventory.yml:

JavaScript

I did install the python-apt package on the virtual machine, but still no dice. If anybody has any tips, I’d love to hear them.

Advertisement

Answer

I see you’re using a specific python interpreter for python2.6, and that you’re using an Ubuntu Precise 64 image. I believe the Precise 64 package for apt-get is for python 2.7 (per apt-cache show python-apt). Assuming you used apt & default sources to install python-apt, I don’t think the apt packages will be available to the 2.6 interpreter.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement