响应模块未加载路径

时间:2020-02-12 10:29:36

标签: ansible ansible-2.x

编辑: 我使用的是同一用户,并且守护进程正在运行,我可以在目标上执行所有docker命令,而不会出现任何问题。

尝试使用响应模块失败。我认为问题是从PATH来的,因此无法加载,因此找不到docker bin。 尝试使用command: /bin/bash "docker image prune --all ",但不起作用 你有主意吗?

- name: docker image prune
  # become: True
  expect:
    command: docker image prune --all 
    responses:
      (?i)continue: "y"

错误:

TASK [docker_purge : docker image prune] ********************************************
fatal: [s00xxxxxx]: FAILED! => {"changed": true, "cmd": "docker image prune --all", "delta": "0:00:00.187062", "end": "2020-02-12 11:17:38.911435", "msg": "non-zero return code", "rc": 1, "start": "2020-02-12 11:17:38.724373", "stdout": "WARNING! This will remove all images without at least one container associated to them.\r\nAre you sure you want to continue? [y/N] Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?", "stdout_lines": ["WARNING! This will remove all images without at least one container associated to them.", "Are you sure you want to continue? [y/N] Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"]}

谢谢

1 个答案:

答案 0 :(得分:1)

可能有2个问题:
1. docker未在目标计算机上运行
2.权限,对于您要删除图像的用户,没有权限。

像我可以看到的

一样,已被注释,因此您可以在这里尝试使用。