只执行一个副本

时间:2014-10-28 18:50:06

标签: ansible ansible-playbook

我在.yml文件中有这些行:

- name: copy nagios libraries
  copy: src=binaries/nagios/check_disk dest=/usr/local/nagios/libexec/check_disk owner=nagios group=nagios mode=0755
  copy: src=binaries/nagios/check_load dest=/usr/local/nagios/libexec/check_load owner=nagios group=nagios mode=0755
  copy: src=binaries/nagios/check_mem.pl dest=/usr/local/nagios/libexec/check_mem.pl owner=nagios group=nagios mode=0755
  copy: src=binaries/nagios/check_procs dest=/usr/local/nagios/libexec/check_procs owner=nagios group=nagios mode=0755
  copy: src=binaries/nagios/check_swap dest=/usr/local/nagios/libexec/check_swap owner=nagios group=nagios mode=0755
  copy: src=binaries/nagios/check_users dest=/usr/local/nagios/libexec/check_users owner=nagios group=nagios mode=0755

只有最后一个似乎正在运作。

感谢downvote,非常有建设性。毫无疑问,您是该网站的资产。

1 个答案:

答案 0 :(得分:0)

基本上,每个副本似乎都需要处于单独的任务中,这是一种方法:

- name: copy nagios libraries
  copy: src=binaries/nagios/check_disk dest=/usr/local/nagios/libexec/check_disk owner=nagios group=nagios mode=0755
- copy: src=binaries/nagios/check_load dest=/usr/local/nagios/libexec/check_load owner=nagios group=nagios mode=0755
- copy: src=binaries/nagios/check_mem.pl dest=/usr/local/nagios/libexec/check_mem.pl owner=nagios group=nagios mode=0755
- copy: src=binaries/nagios/check_procs dest=/usr/local/nagios/libexec/check_procs owner=nagios group=nagios mode=0755
- copy: src=binaries/nagios/check_swap dest=/usr/local/nagios/libexec/check_swap owner=nagios group=nagios mode=0755
- copy: src=binaries/nagios/check_users dest=/usr/local/nagios/libexec/check_users owner=nagios group=nagios mode=0755

我找到了解决问题的另一种方法,这有点滑:

- name: copy nagios libraries
  copy: src={{ item }} dest=/usr/local/nagios/libexec/ owner=nagios group=nagios mode=0755
  with_fileglob:
    - binaries/nagios/*