我正在尝试复制本地文件夹" stuff"进入"分期" ansible中的文件夹:
- name: Copy the ansible stuff
copy:
src: ./stuff
dest: ./staging
这是suff的结果:
- stuff
- foo
- bar
- file.txt
我收到此错误:
Destination directory ./staging/stuff/foo/bar does not exist"
文件夹staging
确实存在!它似乎在复制嵌套文件夹时出现问题。
为什么?
这确实有效:
- name: Copy the ansible stuff
shell: "cp -r ./stuff ./staging/"
答案 0 :(得分:1)
Copy使用来自中间ansible主机的src,而不是来自playhost。使用shell副本,您将在playhost上进行本地复制。
答案 1 :(得分:1)
@dgw是对的。你的shell:" cp .."如果你正在运行playbook到localhost,似乎工作。
您的原始剧本因为相对目的地路径(./staging)而变得更加糟糕 如果设置绝对路径,它就可以工作。 e.g。
- name: Copy the ansible stuff
copy:
src: ./stuff
dest: /tmp/staging