标签(空格分隔): Ago linux运维群:http://hankbook.cn


一.配置文件

1.rsyncd.conf

######rsync_config_______________start
##rsyncd.conf start##
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
ignore errors
read only = false
list = false
hosts allow = 172.16.1.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
[nfsbackup]
path = /nfsbackup/
[allbackup]
path = /allbackup/
#rsync_config_______________end

2.服务端的rsync.passowrd

rsync_backup:123456

3.客户端rsync.password

123456

二.部署脚本

rsync.yml

---
- hosts: aige
  tasks:
    - name: "install rsync"
      yum:
        name: rsync
        state: installed
      
- hosts: 172.16.1.41
  tasks:
    - name: "group add rsync"
      group:
        name: rsync
        gid: 900
    - name: "user add rsync"
      user:
        createhome: no
        group: rsync
        name: rsync
        uid: 900
        shell: /sbin/nologin
    - name: "copy cfg to server"
      copy:
        src: /server/files/rsyncd.conf
        dest: /etc/rsyncd.conf
    - name: "password cfg to server"
      copy:
        src: /server/files/rsync_server.pwd
        dest: /etc/rsync.password
        mode: 0600
    - name: "make dir nfsbackup"
      file:
        state: directory
        path: /nfsbackup/dedecms
        owner: rsync
        group: rsync
    - name: "make dir nfsbackup"
      file:
        state: directory
        path: /nfsbackup/discuz
        owner: rsync
        group: rsync
    - name: "make dir nfsbackup"
      file:
        state: directory
        path: /nfsbackup/wordpress
        owner: rsync
        group: rsync
    - name: "make dir allbackup"
      file:
        state: directory
        path: /allbackup
        owner: rsync
        group: rsync
    - name: "start rsync server"
      shell: rsync --daemon
- hosts: rsync_client
  tasks:
    - name: "password cfg to client"
      copy:
        src: /server/files/rsync_client.pwd
        dest: /etc/rsync.password
        mode: 0600
      

相关文章: