为什么Ansible复制模块没有复制这个目录?

Jef*_*eff 5 ansible ansible-playbook

这应该很容易,但我已经尝试了一个小时.我的代码将Ansible复制.vimrc到每个主机,但是会.vim被忽略.

---
- name: vim pkg
  apt: pkg=vim state=installed

- name: vim dirs
  file: path=/home/jefdaj/.vim state=directory
  file: path=/root/.vim        state=directory

- name: vim files

  # these work
  copy: src=vim/vimrc dest=/home/jefdaj/.vimrc force=yes
  copy: src=vim/vimrc dest=/root/.vimrc        force=yes

  # but these don't
  copy: src=vim/bundle dest=/home/jefdaj/.vim/bundle force=yes recurse=yes
  copy: src=vim/bundle dest=/root/.vim/bundle        force=yes recurse=yes
Run Code Online (Sandbox Code Playgroud)

那是怎么回事?我在路径上尝试了很多变化.它发生在Debian上的ansible 1.5.5中,也发生在当前的git版本上.

编辑:现在它尝试复制,但总是失败,同时创建一个错误的多个目录之一 OSError: [Errno 2] No such file or directory: '/root/.vim/bundle/bundle/vim-easymotion/autoload/vital/Over'

Jef*_*eff 6

不确定为什么会copy失败,但解决方案是使用synchronize.这有效:

- name: vim files
  synchronize:
    src=/absolute/repo/path/roles/common/files/{{ item.src }}
    dest={{ item.dst }}
  with_items:
    - {src: vim/bundle, dst: /home/jefdaj/.vim  }
    - {src: vim/vimrc , dst: /home/jefdaj/.vimrc}
    - {src: vim/bundle, dst: /root/.vim         }
    - {src: vim/vimrc , dst: /root/.vimrc       }

- name: vim permissions
  file: path={{ item.pth }} owner={{ item.own }} group={{ item.grp }} recurse=yes
  with_items:
    - {pth: /root/.vim         , own: root  , grp: root  }
    - {pth: /root/.vimrc       , own: root  , grp: root  }
    - {pth: /home/jefdaj/.vim  , own: jefdaj, grp: jefdaj}
    - {pth: /home/jefdaj/.vimrc, own: jefdaj, grp: jefdaj}
Run Code Online (Sandbox Code Playgroud)

我不得不对基本路径进行硬编码,因为它似乎没有正确处理相对路径.