zoukankan      html  css  js  c++  java
  • 原创: rsync软件服务利用ansible实现一键化部署

    ---恢复内容开始---

    首先创建一个脚本文件 /server/tools/peizhi.sh

    cat  /server/tools/peizhi.sh


    cat >>/etc/rsyncd.conf<<EOF
    #luo
    ##paichu.sh##

    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
    [backup]
    comment = "backup dir by oldboy"
    path = /backup
    EOF

    一键化剧本

    [root@m01 tools]# cat rsyncpiliang.yml
    - hosts: 172.16.1.141 #服务端
    tasks:
    - name: yum
    shell: yum install -y rsync #安装rsync
    - name: yunm
    shell: yum -y install sshpass #安装密钥的软件
    - name: chuangjianmulu
    shell: mkdir -p /server/tools/ #创建所在配置的文件
    - name: peizhi
    copy: src=/server/tools/peizhi.sh dest=/server/tools/peizhi.sh
    - name: yunxing
    script: /server/tools/peizhi.sh #运行脚本
    - name: guanliyunhu
    shell: useradd -s /sbin/nologin -M rsync #创建rsync虚拟用户
    - name: anquanwenjian
    shell: echo "rsync_backup:oldboy123" >/etc/rsync.password #设置密码文件
    - name: quanxian
    shell: chmod 600 /etc/rsync.password #给予权限
    - name: beifenmulu
    shell: mkdir -p /backup && chown -R rsync.rsync /backup
    - name: qidong
    shell: rsync --daemon #运行rsync
    - hosts: 172.16.1.108
    tasks:
    - name: yum
    shell: yum install -y rsync # 客户端
    - name: chuangjianmulu
    shell: mkdir -p /server/tools/
    - name: mimawenjian
    shell: echo "oldboy123" >/etc/rsync.password && chmod 600 /etc/rsync.password
    - hosts: 172.16.1.131
    tasks:
    - name: yum
    shell: yum install -y rsync #客户端
    - name: chuangjianmulu
    shell: mkdir -p /server/tools/
    - name: mimawenjian
    shell: echo "oldboy123" >/etc/rsync.password && chmod 600 /etc/rsync.password

    检查 

  • 相关阅读:
    jmeter压力测试报错:java.net.BindException: Address already in use: connect
    C# 对话框总结(转载)
    C# 文件操作方法大全(转载)
    C#实现进度条progress control(转载)
    在Windows下架设FTP服务器
    .Net环境下,使用installutil.exe注册、删除windows服务
    用双网卡实现跨网段访问(转载)
    HTTP协议详解(转载)
    学习开发web服务(转载)
    C# 实现http协议的GET和POST请求(转载)
  • 原文地址:https://www.cnblogs.com/dsab/p/7491431.html
Copyright © 2011-2022 走看看