infobloxopen / infoblox-ansible

Ansible modules for interfacing to Infoblox systems
GNU General Public License v3.0
54 stars 60 forks source link

infoblox-client is required but does not appear to be installed #168

Closed dc-chris-smith closed 1 year ago

dc-chris-smith commented 1 year ago

I am testing in my lab and recently upgraded our Ansible Automation Platform there to version 2.3. I have included the infoblox-client, the dependencies it requires, and infoblox.nios_modules in one of my EEs and I still get this message. Any help will be greatly appreciated. If more information is needed, I will provide what I am allowed to.

-- Ansible Automation Platform Controller version 4.3.1

Ansible version info

ansible [core 2.14.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.13 (main, Nov  9 2022, 13:16:24) [GCC 8.5.0 20210514 (Red Hat 8.5.0-15)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

EE build info

requirements.txt (I have had infoblox-client here as well as in the EE yaml file where it is now)

six>=1.11.0
requests>=2.5.2
urllib3>=1.13
oslo.serialization>=1.4.0
oslo.log>=1.8.0
setuptools>=17.1

execution-environment.yml

---
version: 1

dependencies:
  galaxy: requirements.yml
  python: requirements.txt

additional_build_steps:
  prepend: |
    RUN pip3 install --upgrade pip setuptools
    RUN pip3 install infoblox-client

requirements.yml

---
collections:
  - ansible.windows
  - community.windows
  - ansible.utils
  - ansible.posix
  - chocolatey.chocolatey
  - awx.awx
  - community.general
  - infoblox.nios_modules
fostermi commented 1 year ago

I think I ran into this as well using an older version of python3. See https://community.infoblox.com/t5/api-integration-devops-netops/issues-with-infoblox-client-in-ansible/td-p/16300.

dc-chris-smith commented 1 year ago

Thanks for the link @fostermi. I executed a bash shell on the execution environment container on one of the execution nodes and I see the client and all dependencies there. I even executed an example from the infoblox-client repo and it worked with no problems. It appears to have trouble working when run from a template defined on the controller.

bash-4.4# pip show infoblox-client
Name: infoblox-client
Version: 0.6.0
Summary: Client for interacting with Infoblox NIOS over WAPI
Home-page: https://github.com/infobloxopen/infoblox-client
Author: John Belamaric
Author-email: jbelamaric@infoblox.com
License: Apache
Location: /usr/lib/python3.8/site-packages
Requires: oslo.log, oslo.serialization, requests, setuptools, six, urllib3
Required-by:
bash-4.4#
bash-4.4# python3
Python 3.8.13 (default, Jun 24 2022, 15:27:57)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-13)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from infoblox_client import connector
opts = {'host': '0.0.0.0', 'username': 'xxxxxxxxxx', 'password': '*****************'}
conn = connector.Connector(opts)
network = conn.get_object('network', {'network': '0.0.0.0/24', 'network_view': 'default'})
network
[{'_ref': 'network/XXxxxXXxxxXXXxxxXxxxxxXxXXX:0.0.0.0/24/default', 'network': '0.0.0.0/24', 'network_view': 'default'}]
badnetmask commented 1 year ago

The Ansible information you posted on your original request says /usr/local/lib/python3.9, however your test on your last post says /usr/lib/python3.8. Go back to that bash and run ansible --version, see if they're pointing to the same Python location.

dc-chris-smith commented 1 year ago

The first post information is from the Ansible execution node. The later test is from the Execution Environment that Ansible uses to run the job. The job is run in the context of the EE container, not the host itself.

dc-chris-smith commented 1 year ago

I used a RHEL desktop with Ansible core, Python3.9, the infoblox-client and all the required modules installed. When I run a job there to add an A record in Infoblox, it works fine. The job parameters are the same as they are on the Ansible Automation Platform where it fails with the message that the client is not installed. Does anyone have any idea why this won't run from an execution environment in AAP?

fostermi commented 1 year ago

Hmmm, perhaps this: https://stackoverflow.com/questions/73028784/ansible-execution-environment-not-recognizing-installed-module

dc-chris-smith commented 1 year ago

No joy there. I even created a brand new container that only has little more than the infoblox-client installed in it. I still get the same error. I don't know where platform-python is coming from in the error either. The default python in any of these containers is python3.9. My containers are based on ubuntu-latest, could that be where the issue is?

fostermi commented 1 year ago

I'm able to use the infoblox modules in an Ubuntu container created from a custom Docker image.

root@3816cf105c2e:/work# python3 --version
Python 3.8.10
root@3816cf105c2e:/work# pip list | grep infoblox-client
infoblox-client    0.5.2   
dc-chris-smith commented 1 year ago

I see the same with these EE containers. I can run commands within the container, and they work. It is only when I execute a template on the AAP controller that I get this error. I did notice that your client is at version 0.5.2 where mine is 0.6.0.

matthewdennett commented 1 year ago

Try setting ansible_python_interpreter in your playbook and see if that helps. I have has some issues like this before when working in python virtual environments.

Here's and example you can dump straight into your playbook.

vars: 
  ansible_python_interpreter: "{{ ansible_playbook_python }}"
dc-chris-smith commented 1 year ago

Thanks @matthewdennett! I received that same advice from Red Hat as well.

Just so that anyone else who runs into this and finds this issue later, I did not have to change the interpreter if I used ansible-playbook to run the job with a base install of Ansible via the command line. When running it with an Execution Environment in Ansible Automation Platform 2.x, the problem appears.

The fix is to add the python interpreter path to the playbook variables. To ensure you get the correct interpreter, run the following inside the EE container:

bash-4.4# which python3
/usr/bin/python3

Then add the following line to the variables section in the AAP Template definition (using auto or auto-legacy as the setting did not work):

ansible_python_interpreter: /usr/bin/python3