响应模块没有加载路径

responsse module no path loaded

编辑: 我使用的是同一个用户,守护进程是 运行,我可以毫无问题地在目标上执行所有 docker 命令。

尝试使用 reponsse 模块但没有成功。我认为问题来自 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?"]}

谢谢

可能有 2 个问题:
1. docker 在目标机器
上不是 运行 2. 权限,你试图删除图像的用户没有权限。

好像我看到 become 被评论了,所以在这里你可以试试 become。