2016-11-09 71 views
0

我试图本地文件夹的 “东西” 复制到 “升级” 文件夹中ansible:复制文件夹recursivly在ansible

- name: Copy the ansible stuff 
    copy: 
    src: ./stuff 
    dest: ./staging 

这是SUFF的direcotry结构:

- 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/" 
+1

试着给出绝对路径。 – Shasha99

回答

1

@dgw是对的。你的shell:“cp ..”似乎正在运行,只要你在本地主机上运行playbook。

您的原始剧本获取erorr,因为相对的dest路径(./staging) 如果您设置了绝对路径,它将起作用。例如

- name: Copy the ansible stuff 
    copy: 
    src: ./stuff 
    dest: /tmp/staging 
1

复制使用从中央ansible主机SRC,而不是从playhost。用你的shell复制你的本地拷贝在主机上。

+0

是的。在我的情况下,主机是本地主机,这就是为什么我可以用shell来测试它。 – Nathan