使用社区 EE 镜像运行 Ansible

您可以无需构建自定义 EE 即可使用社区镜像运行 ansible。

使用community-ee-minimal镜像,其中仅包含ansible-core,或者使用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上运行它

- name: Gather and print local facts
  hosts: localhost
  become: true
  gather_facts: true
  tasks:

   - name: Print facts
     ansible.builtin.debug:
      var: ansible_facts
ansible-navigator run test_localhost.yml --execution-environment-image ghcr.io/ansible-community/community-ee-minimal:latest --mode stdout