Ansible requires python-apt but it's already installed

Thanks to @David Maze for pointing me to the right direction

I was checking for python-apt in the controller machine, not in the controlled machine.

So I installed the package from the controller into the controller machine using

$ ansible openvpn -m "apt name=python-apt state=latest" --become-user realtebo

You can also use the following form, that does sudo apt-get update and wait for operator to enter the password. The user is the one logged in via ssh; so check your config. In my case, I'm using ssh keys, password login is disabled at all.

$ ansible openvpn -m apt -a "update-cache=yes" --become --ask-become-pass

Tip 1: To avoid this interaction is available the vault, but I've not tried it yet.

Tip 2: Also, --ask-become-pass is not in the doc where you're probably looking for, at letter a; this is because the option is shortened in -K, uppercase, so look more down See the doc

After ensuring that remotely the package python-apt is available, then the -C option started to work, exactly because now python-apt is available remotely.

ansible openvpn -C -m "apt name=python state=latest"

192.168.1.225 | SUCCESS => {
    "cache_update_time": 1533077635,
    "cache_updated": false,
    "changed": false
}

I solved this error by using ansible_python_interpreter argument while running the ansible-playbook, like below.

ansible-playbook playbook_name.yml -e ansible_python_interpreter=/usr/bin/python --check

Tags:

Python

Ansible