zoukankan      html  css  js  c++  java
  • ansibile剧本---实现一键部署rsync备份服务

    [root@m01 ansible-playbook]# vim rsync-判断功能.yaml
    - 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
    - name: 04-create 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: 172.16.1.31,172.16.1.7
    tasks:
    - name: 01-install rsync
    yum: name=rsync state=installed
    - name: 02-cerate password file
    copy: content=oldboy123 dest=/etc/rsync.password mode=600
    - name: 03-create test file
    file: dest=/tmp/test_nfs.txt state=touch
    when: (ansible_hostname == "nfs01")
    - name: 04-create test file
    file: dest=/tmp/test_web.txt state=touch
    when: (ansible_hostname == "web01")
    - name: 05-chech test_nfs data
    shell: rsync -avz /tmp/test_nfs.txt rsync_backup@172.16.1.41::backup --password-file=/etc/rsync.password
    when: (ansible_hostname == "nfs01")
    - name: 06-check test_web data
    shell: rsync -avz /tmp/test_web.txt rsync_backup@172.16.1.41::web --password-file=/etc/rsync.password
    when: (ansible_hostname == "web01")

  • 相关阅读:
    CF1295D Same GCDs
    欧拉函数
    CF1509C The Sports Festival
    莫队学习笔记
    CF271D Good Substrings
    字符串
    P2704 [NOI2001] 炮兵阵地
    【洛谷 3399】丝绸之路
    【洛谷 3379】最近公共祖先
    【洛谷 2939】Revamping Trails G
  • 原文地址:https://www.cnblogs.com/chenyuxia/p/13339999.html
Copyright © 2011-2022 走看看