我正在使用ansible 2.0来管理远程机器上hub.docker.com的docker镜像。
我在集线器上有一个带有不同标签的私有映像,我希望在我的计算机上部署,但只有3个标签可用。
以下是我的ansible conf的相关信息:
tasks.yml:
- name: pull local images
docker:
image: "{{ item.image }}:{{ item.tag }}"
pull: always
with_items: "{{ docker_image_list }}"
register: docker_pull_result
项目示例:
docker_image1:
image: 'mynamespace/myimage'
tag: mytag
结果:
failed: [myhost] (item={u'image': u'mynamespace/myimage', u'tag': u'mytag'}) => {"failed": true, "item": {"image": "mynamespace/myimage", "local": "localhost:5000/mytag", "tag": "mytag"}, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n File \"/home/myuser/.ansible/tmp/ansible-tmp-1471514200.43-222544910756770/docker\", line 3752, in <module>\r\n main()\r\n File \"/home/myuser/.ansible/tmp/ansible-tmp-1471514200.43-222544910756770/docker\", line 1744, in main\r\n stopped(manager, containers, count, name)\r\n File \"/home/myuser/.ansible/tmp/ansible-tmp-1471514200.43-222544910756770/docker\", line 1623, in stopped\r\n containers.refresh()\r\n File \"/home/myuser/.ansible/tmp/ansible-tmp-1471514200.43-222544910756770/docker\", line 1531, in refresh\r\n self.deployed = self.manager.get_deployed_containers()\r\n File \"/home/myuser/.ansible/tmp/ansible-tmp-1471514200.43-222544910756770/docker\", line 1347, in get_deployed_containers\r\n repo_tags = self.get_image_repo_tags()\r\n File \"/home/myuser/.ansible/tmp/ansible-tmp-1471514200.43-222544910756770/docker\", line 1010, in get_image_repo_tags\r\n if resource in image.get('RepoTags', []):\r\nTypeError: argument of type 'NoneType' is not iterable\r\n", "msg": "MODULE FAILURE", "parsed": false}
我不明白为什么会失败以及如何解决这个问题,任何人都可以帮忙吗?
THX
答案 0 :(得分:0)
任务失败,因为docker
模块不支持在image参数中引用tags
。
自Ansible 2.2
起,docker module已弃用。
我建议您更新Ansible版本并使用推荐的docker_image和docker_container,它们都支持使用tags
引用name:tag
。