i刚刚设置和Ansible Testing Server,并尝试在要启动的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
使用以下格式正确执行此操作:
- 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