rsync剧本编写
- vim rsync_server.yaml #创立剧本
- hosts:172.1.1.1 tasks: - name: 01-install rsync yum: name=rsync state=installed - name:02-push conf file copy:src=/etc/ansible/server_file/rsync_server/rsyncd.conf dest=/etc/ #此处如果是批改了文件,须要重启的时候呈现的问题 - name:03-create user user: name=rsync create_home=no shell=/sbin/nologin shell: useradd rsync -M -s /sbin/nologin - name:04-create backup directory file:path/backup state=directory owner=rsync group=rsync - name:05-create password directory copy: content=rsync_backup:demo123 dest=/etc/password mode=600 - name: 06-start service service: name=rsyncd state=started enabled=yes - hosts: 172.1.1.2 #如果是多台客户端,怎么启动 tasks: - name: 01-installed software yum:name=rsync state=installed - name: 02 -create password file copy:content=demo123 dest=/etc/rsync.password mode=600 - name: 03 test data backup file:dest=/tmp/test.txt state=touch - name:04 start test shell:rsync -avz /tmp/test.txt rsync_backup@172.1.1.1::backup --password-file=/etc/rsync.password ansible-playbook --syntax-check rsync_server.yaml
剧本常见谬误
1、剧本语法标准是否合乎(空格、冒号、短横线)2、剧本中的模块应用是否正确3、剧本中的一个name标识上面只能够写一个工作信息
337