与osx apple Silicon上docker引擎的可靠连接



我正试图连接到在OSX(m1芯片(上运行的本地docker引擎,以便创建动态库存。我使用以下配置创建了一个主机文件我确保docker_containers模块安装良好。

plugin: community.docker.docker_containers
docker_host: "unix://Users/ME/.docker/run/docker-cli-api.sock"

然后我运行ansible-inventory --graph -i ./hosts/hosts-docker-local.yaml

但我得到了以下错误:

[WARNING]:  * Failed to parse /Users/ME/Projects/ansible-test/hosts/hosts-docker-local.yaml with auto plugin: inventory source '/Users/ME/Projects/ansible-test/hosts/hosts-docker-local.yaml' could not be
verified by inventory plugin 'community.docker.docker_containers'
[WARNING]:  * Failed to parse /Users/ME/Projects/ansible-test/hosts/hosts-docker-local.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]:  * Failed to parse /Users/ME/Projects/ansible-test/hosts/hosts-docker-local.yaml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this character is reserved to
provide a port.
[WARNING]: Unable to parse /Users/ME/Projects/ansible-test/hosts/hosts-docker-local.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
@all:
|--@ungrouped:

我试过

ansible-doc -t inventory -l  | grep docker
community.docker.docker_containers                      Ansible dynamic inv...
community.docker.docker_machine                         Docker Machine inve...
community.docker.docker_swarm                           Ansible dynamic inv...

但不知怎么的,如果我这样做ansible localhost -i ./hosts/hosts-docker-local.yaml -m community.docker.docker_containers

它抱怨

localhost | FAILED! => {
"msg": "The module community.docker.docker_containers was not found in configured module paths"
}
maybe something wrong with my module path, something wierd with OSX? (I installed Ansible with brew) 

@Zeitounator指出,库存文件必须以docker.yaml结尾。

使用以docker.[yml|yaml]结尾的YAML配置文件。

https://docs.ansible.com/ansible/latest/collections/community/docker/docker_containers_inventory.html#synopsis

最新更新