HCL-TECH-SOFTWARE / connections-automation

Deployment and upgrade automation scripts for HCL Connections 7.0 based on Ansible

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

problem with python & task "component-pack : Test Docker Registry Login RHEL" - No module named 'requests'

MagnaFrisia90 opened this issue · comments

TASK [component-pack : Show me Linux distribution version] ***************************************************************************************
ok: [solcon15.solvito.cloud] => {
"msg": "7.9"
}

TASK [component-pack : Test Docker Registry Login RHEL] ******************************************************************************************
fatal: [solcon15.solvito.cloud]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on solcon15.solvito.cloud's Python /usr/bin/python3. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via pip install docker or pip install docker-py (Python 2.6). The error was: No module named 'requests'"}

Any ideas what could cause these issues ?
I have executed "ansible-playbook -i environments/examples/cnx7/quick_start/inventory.ini playbooks/hcl/setup-component-pack.yml"

"pip list" => contains many modules including "requests (2.6.0)"
"pip3 list" => contains only "pip (9.0.3)" & "setuptools (39.2.0)"

Could you do a ansible --version to see which python Ansible is using? v2.6 seems too old I'd suggest to install request to your python3.

Also note that the playbooks/hcl/setup-component-pack.yml is obsolete as it used the old Component Pack zip and we've switched to use the HCL Harbor online registry to pull the artifacts. The setup-component-pack.yml equivalent is playbooks/hcl/harbor/setup-component-pack.yml

My intention is to install Component Pack with Connections 7 with a local docker registry.
Component Pack with Connections 8 with online repository is the next step. But I am not there yet.
I assume "harbor" is only for v8 which is why I am forced to run the "legacy" local registry setup if I want to use v7 ?

First of all: We are talking about the ansible-controller or the python that is installed on target servers e.g. k8s_master ?
On target servers I have python2 & python3. On ansible-controller only python2 is installed.

When I run ansible --version on ansible-controller

[ansible@solcon13 component-pack]$ ansible --version
ansible 2.9.27
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/ansible/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Jun 28 2022, 15:30:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

I will try to install v3 on ansible-controller & re-run script. But how is this approached ?

[ansible@solcon13 root]$ cat /etc/ansible/ansible.cfg |grep py
ansible_python_interpreter=/usr/bin/python3

Applying the interpreter via config does not seem to work. It still says "python version 2.7.5".

And which cleanup-scripts should I use ? Or just re-run ?

Regards,
Jan

Update: I did some research & it seems like you can not remove python2 from CentOS7 since it is built-in.
Also referencing a different python interpreter will not work as this will only affect target host interpreter (which are also CentOS7 hosts).
I am wondering how anybody could successfully setup Component Pack on CentOS7 with these ansible playbooks ? It seems like there are pitfalls everywhere...

@sabrina-yee Could you please comment on a) if CentOS7 in 2023 is still supported & if b) which python version is supported on ansible & target hosts ?

We're still using this repo with CentOS7 in most of our internal systems daily.
Please note that you can install the Component Pack from Harbor with Connections 7 directly, especially since you're doing a fresh install.

It is true that python2 cannot be removed from CentOS7, but python2 and python3 can co-exist as long as python2 is the default python for CentOS7 it will not break the OS.

For comparison, my Centos7 controller has both python2 and python3 installed:

[sabrinayee@controller ~]$ python -V
Python 2.7.5

[sabrinayee@c7controller1 ~]$ ansible --version
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red
 Hat 4.8.5-44)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
ansible [core 2.11.7]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/sabrinayee/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  ansible collection location = /home/sabrinayee/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
  jinja version = 3.0.3
  libyaml = True

Per Ansible doc, when the interpreter is set via ansible.cfg the setting is interpreter_python, whereas when it's set in the inventory the setting is ansible_python_interpreter.

As for the target hosts, python3 is needed for example to run the script in this step
but the script should take care of install it.

I am still not sure about this setting.

ansible_python_interpreter=/usr/bin/python3
interpreter_python=/usr/bin/python3

These two have been set inside /etc/ansible/ansible.cfg & /opt/connections-automation/ansible.cfg.
It has switched to python3 now. But it is still on python3 when I remove the added lines.

I will try to rerun the playbook with v3 now & report result

python3 as interpreter solves the problem