ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.95k stars 3.41k forks source link

tower-cli not supporting AWX at non-root path #12097

Open adpavlov opened 2 years ago

adpavlov commented 2 years ago

Please confirm the following

Summary

Changes from #11342 and #652 are not ported to tower-cli and awxkit

AWX version

20.1.0

Select the relevant components

Installation method

kubernetes

Modifications

yes

Ansible version

No response

Operating system

No response

Web browser

No response

Steps to reproduce

Install AWX to serve in prefixed path

Expected results

tower-cli and awxkit working

Actual results

/usr/bin/awx --conf.host http://192.168.119.100:32262/awx --conf.username admin --conf.password sudo kubectl -n awx get secret awx-admin-password -o jsonpath="{.data.password}" | base64 --decode --conf.insecure project list An error occurred while fetching http://192.168.119.100:32262/awx/api/

/usr/bin/awx --conf.host http://192.168.119.100:32262/awx --conf.username admin --conf.password sudo kubectl -n awx get secret awx-admin-password -o jsonpath="{.data.password}" | base64 --decode --conf.insecure project list -v DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.119.100:32262 DEBUG:urllib3.connectionpool:http://192.168.119.100:32262 "GET /awx/api/ HTTP/1.1" 200 198 DEBUG:awxkit.api.client:"GET http://192.168.119.100:32262/awx/api/" elapsed: 0:00:00.045573 DEBUG:awxkit.api.registry:Retrieved <class 'awxkit.api.pages.base.Base'> by url: /awx/api/ Traceback (most recent call last): File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/awxkit/cli/client.py", line 134, in fetch_version_root self.v2 = self.root.get().available_versions.v2.get() AttributeError: 'str' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/awxkit/cli/init.py", line 24, in run cli.connect() File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/awxkit/cli/client.py", line 121, in connect self.fetch_version_root() File "/opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/awxkit/cli/client.py", line 136, in fetch_version_root raise RuntimeError( RuntimeError: An error occurred while fetching http://192.168.119.100:32262/awx/api/

Additional information

No response

adpavlov commented 2 years ago

@gundalow I was able to WA this behavior by stripping path in awxkit/awxkit/api/pages/page.py in class Page(object):

After value = self.json[name] I added following code:

            if isinstance(value, dict):
                for key, val in value.items():
                    value[key] = re.sub(r'^.*?/api', '/api', value[key])
            else:
                value = re.sub(r'^.*?/api', '/api', value)