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

  • 相关阅读:
    linux目录结构
    php程序员要懂那些linux知识?
    树和二叉树
    linux学习课程
    顺序栈的实现
    编写一个插件(前面JavaScript高级总结)
    javascript高级课程-4
    字符串的顺序表
    js 万年历实现
    利用 postMessage 进行数据传递 (iframe 及web worker)及问题
  • 原文地址:https://www.cnblogs.com/chenyuxia/p/13339999.html
Copyright © 2011-2022 走看看