我只是设置并安装测试服务器并尝试复制模块,以便在启动ssh服务后通过多个主机复制文件。但它的投掷错误。请告知我在这里做错了什么..
---
- hosts: Dummy_host
remote_user: root
tasks:
- name: Copying Files to Group of Hosts
copy: src=/tmp/{{ item.sname }} dest=/tmp/WWW/{{ item.dname }}
notify:
- restart sshd
with_items:
- { sname: file1.txt, dname: nm1.txt }
- { sname: file2.txt, dname: nm2.txt }
handlers:
- name: restart sshd
service: name=sshd state=restarted
以下是错误
root@test1# ansible-playbook cp4.yml
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/etc/ansible/Playbooks/cp4.yml': line 9, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- restart sshd
with_items:
^ here
答案 0 :(得分:7)
使用以下格式正确执行此操作:
- name: Copy the binary files into /etc/init.d
copy:
src: "{{ item }}"
dest: /etc/init.d
owner: root
group: root
mode: 0755
with_items:
- consul
- keymanager
- vault
- tarball.tar.gz