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")

  • 相关阅读:
    API创建员工联系人
    API创建员工Element
    API创建员工
    API创建员工支付方式
    用API创建用户
    用API给用户添加职责
    创建银行API
    创建银行分行的API
    初探C++ 深拷贝与浅拷贝
    推断数据是否为整数
  • 原文地址:https://www.cnblogs.com/chenyuxia/p/13339999.html
Copyright © 2011-2022 走看看