dj-wasabi/ansible-zabbix-agent

Error installing python-netaddr on CentOS7 controller

djjuhasz opened this issue · 2 comments

Describe the bug

I get the following error when running the role against a Ubuntu 18.04 node.

TASK [dj-wasabi.zabbix-agent : Install local python-netaddr package] ***************************************************
FAILED - RETRYING: Install local python-netaddr package (3 retries left).
FAILED - RETRYING: Install local python-netaddr package (2 retries left).
FAILED - RETRYING: Install local python-netaddr package (1 retries left).
fatal: [djj-fhya-test -> localhost]: FAILED! => {"attempts": 3, "changed": false, "msg": "Unable to find any of pip2, pip to use.  pip needs to be installed."}

pip3 and pip2 are both installed on the target node:

$ pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

Installation method/version
Installed using Ansible Galaxy, role version: 2.1.0

Ansible Version

$ ansible --version
ansible 2.9.2

Targetted hosts

~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:        18.04
Codename:       bionic

Expected behavior
Python netaddr library is installed and role runs to completion without a fatal error.

Additional context

The Ansible controller is running on a CentOS7 host.

If I run pip install netaddr directly on the target node, it installs fine:

********@djj-fhya-test:~$ pip install netaddr
Collecting netaddr
  Downloading https://files.pythonhosted.org/packages/ba/97/ce14451a9fd7bdb5a397abf99b24a1a6bb7a1a440b019bebd2e9a0dbec74/netaddr-0.7.19-py2.py3-none-any.whl (1.6MB)
    100% |████████████████████████████████| 1.6MB 476kB/s
Installing collected packages: netaddr
Successfully installed netaddr-0.7.19

But after installing netaddr manually with pip, the role still fails on the same step:

TASK [dj-wasabi.zabbix-agent : Install local python-netaddr package] ***************************************************
FAILED - RETRYING: Install local python-netaddr package (3 retries left).
FAILED - RETRYING: Install local python-netaddr package (2 retries left).
FAILED - RETRYING: Install local python-netaddr package (1 retries left).
fatal: [djj-fhya-test -> localhost]: FAILED! => {"attempts": 3, "changed": false, "msg": "Unable to find any of pip2, pip to use.  pip needs to be installed."}

Ohhhh, I see - netaddr is required on the controller not the target node. 🤦‍♂

I've never encountered a situation with Ansible where additional python libraries are required on the controller, so I totally didn't have this on my radar. :(

@djjuhasz

No worries, had the same issues when implementing it in the role 😉