You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

构建AWX-EE自定义镜像时遭遇pip依赖冲突问题求助

AWX-EE自定义镜像构建pip依赖冲突解决

问题背景

使用ansible-builder构建基于最新版AWX-EE的自定义镜像时出现pip模块冲突,7月使用awx-ee 22.X/23.X版本时构建正常。冲突来自手动指定的依赖与AWX-EE基础镜像内置/管理的模块之间,即使清空自定义requirements.txt仍会出现类似错误。

配置文件

execution-environment.yml

---
version: 1

build_arg_defaults:
  EE_BASE_IMAGE: 'quay.io/ansible/awx-ee:latest'

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

additional_build_steps:
  prepend: |
    RUN cat /etc/os-release

  append:
   RUN whoami

requirements.yml

---
collections:
-  name: nutanix.ncp
-  name: community.hashi_vault
-  name: arubanetworks.aos_switch
-  name: community.general

requirements.txt

hvac

错误信息

The user requested requests>=2.4.2 and ~=2.26.0
210.3     azure-core 1.28.0 depends on requests>=2.18.4
210.3     awxkit 13.0.0 depends on requests
210.3     hvac 1.2.1 depends on requests<3.0.0 and >=2.27.1
210.3
210.3 To fix this you could try to:
210.3 1. loosen the range of package versions you've specified
210.3 2. remove package versions to allow pip attempt to solve the dependency conflict
210.3
210.3 ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
------
Dockerfile:54
--------------------
  52 |     COPY _build/requirements.txt requirements.txt
  53 |     RUN $PYCMD /output/scripts/introspect.py introspect --sanitize --user-pip=requirements.txt --write-bindep=/tmp/src/bindep.txt --write-pip=/tmp/src/requirements.txt
  54 | >>> RUN /output/scripts/assemble
  55 |
  56 |     # Final build stage
--------------------
ERROR: failed to solve: process "/bin/sh -c /output/scripts/assemble" did not complete successfully: exit code: 1

问题根源

nutanix.ncp集合自带的requirements.txt要求requests~=2.26.0,而hvac 1.2.1要求requests>=2.27.1,同时AWX-EE基础镜像中的awxkit、azure-core等模块也依赖requests,导致版本范围无法兼容。

解决方案

1. 锁定兼容的hvac版本

在requirements.txt中指定与requests~=2.26.0兼容的hvac版本,比如hvac 1.1.0(其对requests的要求为>=2.25.1,<3.0.0):

hvac==1.1.0

2. 覆盖集合的依赖限制

通过ansible-builder的additional_build_steps修改生成的requirements.txt,强制统一requests版本:
在execution-environment.yml的additional_build_steps中调整为:

additional_build_steps:
  prepend: |
    RUN cat /etc/os-release
  append: |
    RUN sed -i 's/requests~=2.26.0/requests>=2.26.0,<3.0.0/' /tmp/src/requirements.txt
    RUN /output/scripts/assemble

3. 回退到旧版AWX-EE基础镜像

直接指定之前可用的AWX-EE版本作为基础镜像,避开新版本的依赖变化:

build_arg_defaults:
  EE_BASE_IMAGE: 'quay.io/ansible/awx-ee:23.9.0'

4. 移除不必要的内置集合

如果不需要基础镜像中的azure相关集合,可以在构建步骤中先移除它们,减少冲突源:
在execution-environment.yml的prepend中添加:

prepend: |
    RUN ansible-galaxy collection remove azure.azcollection
    RUN cat /etc/os-release

内容的提问来源于stack exchange,提问作者motorbass

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 02:20:35