Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么';Ansible copy模块是否复制此目录?_Ansible_Ansible Playbook - Fatal编程技术网

为什么';Ansible copy模块是否复制此目录?

为什么';Ansible copy模块是否复制此目录?,ansible,ansible-playbook,Ansible,Ansible Playbook,这应该很容易,但我已经试了一个小时了。我的代码可以将.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

这应该很容易,但我已经试了一个小时了。我的代码可以将
.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
怎么回事? 我尝试了很多不同的路径。 它发生在Debian上的ansible 1.5.5中,也发生在当前的git版本中


编辑:现在它尝试复制,但在创建一个目录时总是失败,错误如下:“/root/.vim/bundle/bundle/vim easymotion/autoload/vital/Over”不确定为什么
复制
失败,但解决方案是使用
同步
。这项工作:

- 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}

我不得不硬编码基本路径,因为它似乎无法正确处理相关路径。

您的
文件
复制任务的问题在于一个任务中有多个操作。一个可执行的任务只能有一个操作

按以下方式更改您的游戏,它应该可以工作:

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

- name: vim dir for jefdaj
  file: path=/home/jefdaj/.vim state=directory

- name: vim dir for root
  file: path=/root/.vim        state=directory

...

“vim文件”任务也是如此:将它们分为四个任务。

那么你是说问题出在这一部分<代码>副本:src=vim/vim/bundle dest=/home/jefdaj/.vim/
如果没有,请澄清。我认为是这样。我只是把剩下的放在这里,因为我不确定。好吧,我现在对Ansible更熟悉了一点。简化了这个问题。
copy
synchronize
相比有多么糟糕,真是令人惊讶。对于批量拷贝,差异是数量级。