Ansible剧本(rsync+inotify+sersync)

vi sersync.yaml

~~~

- hosts: rsync_server

  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 dir

      file: path=/backup state=directory owner=rsync group=rsync

    - name: 05-create password file

      copy: content=rsync_backup:oldboy123 dest=/etc/rsync.password mode=600

    - name: 06-start rsync server

      service: name=rsyncd state=started enabled=yes

 

- hosts: rsync_clients

  tasks:

    - name: 01-install rsync

      yum: name=rsync state=installed

    - name: 02-create password file

      copy: content=oldboy123 dest=/etc/rsync.password mode=600

    - name: 03-install inotify-tools

      yum: name=inotify-tools state=installed

    - name: 04-install sersync

      copy: src=/soft/sersync dest=/usr/local

    - name: 05-push sersync config file

      copy: src=/etc/ansible/server_file/rsync_server/confxml.xml dest=/usr/local/sersync/conf/confxml.xml

    - name: 06-add exectue to sersync

      file: dest=/usr/local/sersync/bin/sersync mode=755

    - name: 07-start service about sersync

      shell: /usr/local/sersync/bin/sersync -dro /usr/local/sersync/conf/confxml.xml

~~~

posted @ 2022-02-23 15:17  哲学家  阅读(61)  评论(0编辑  收藏  举报