使用社区 EE 镜像运行 Ansible¶
你无需构建自定义 EE 即可运行 Ansible,可以使用社区镜像。使用仅包含 ansible-core
的 community-ee-minimal
镜像,或者使用包含几个基础集合的 community-ee-base
镜像。
运行以下命令查看 community-ee-base
镜像中包含的集合
ansible-navigator collections --execution-environment-image ghcr.io/ansible-community/community-ee-base:latest
在 community-ee-minimal
容器内,对 localhost 运行以下 Ansible ad-hoc 命令
ansible-navigator exec "ansible localhost -m setup" --execution-environment-image ghcr.io/ansible-community/community-ee-minimal:latest --mode stdout
现在,创建一个简单的测试剧本,并在容器内对 localhost 运行它
cat > test_localhost.yml<<EOF
- name: Gather and print local facts
hosts: localhost
become: true
gather_facts: true
tasks:
- name: Print facts
ansible.builtin.debug:
var: ansible_facts
EOF
ansible-navigator run test_localhost.yml --execution-environment-image ghcr.io/ansible-community/community-ee-minimal:latest --mode stdout
想讨论社区 EE 镜像和其他 EE 相关主题吗?加入 论坛组!