Fabric实现自动化部署

Fabric实现自动化部署

  1. 安装fabric 

    yum install fabric -y

  2. 编写脚本来实现自动化部署

      注意:env.passwords中要指明端口22,以及多个用户用逗号隔开

      远程102,103两台主机执行 ls -l  目录

#cat frbfile.py

from fabric.api import * 

env.hosts = ['192.168.12.102','192.168.12.103'] env.passwords = { '[email protected]:22':'redhat', '[email protected]:22':'redhat', }

@runs_once def input_raw(): return prompt('please input you dir:>>>') def runs(dirN): run('ls -l ' + dirN) @task def test(): dirname = input_raw() runs(dirname) print('END.....')

  

猜你喜欢

转载自www.cnblogs.com/mxdboke/p/9157974.html