使用ansible-builder构建执行环境时遇Unknown yaml key 'images'错误如何解决?
修复Ansible执行环境构建时的DefinitionError错误
问题描述
构建Ansible执行环境时执行命令:
ansible-builder build --tag postgresql_ee --container-runtime docker
触发如下错误:
ansible_builder.exceptions.DefinitionError: Error: Unknown yaml key(s), {'images'}, found in the definition file. Allowed options are: {'ansible_config', 'build_arg_defaults', 'dependencies', 'version', 'additional_build_steps'}
使用的软件版本:
- Amazon Linux 2 (4.14.336-257.568.amzn2.x86_64)
- Python 3.8.16
- ansible-builder 1.2.0
- ansible [core 2.13.13]
- Docker 20.10.25
当前execution-environment.yml内容:
cat > execution-environment.yml<<EOF version: 3 images: base_image: name: quay.io/fedora/fedora:latest dependencies: ansible_core: package_pip: ansible-core ansible_runner: package_pip: ansible-runner system: - openssh-clients - sshpass galaxy: collections: - name: community.postgresql EOF
解决方案
你的ansible-builder版本是1.2.0,该版本的执行环境定义文件不支持images字段——这个嵌套字段是ansible-builder 2.x版本才新增的配置项。
修复方法是将images.base_image替换为1.x版本支持的顶级base_image字段,修改后的配置文件如下:
cat > execution-environment.yml<<EOF version: 3 base_image: quay.io/fedora/fedora:latest dependencies: ansible_core: package_pip: ansible-core ansible_runner: package_pip: ansible-runner system: - openssh-clients - sshpass galaxy: collections: - name: community.postgresql EOF
修改完成后重新执行构建命令即可正常运行。
内容的提问来源于stack exchange,提问作者hermit.crab
相关产品推荐
相关产品推荐

