Fabric ,远程创建文件夹

新建脚本文件 fabmkdir.py,

from fabric.api import *
from fabric.colors import *	
env.roledefs = {
			'slave1server':['root@slave1',],
			'slave2server':['root@slave2',],
			'slave3server':['root@slave3',]
			}
#env.password = '123456'
	
@roles('slave1server')	
def test():
	with cd('/usr'):
		run('mkdir A0124')
		run('ls -lh')
执行脚本  fab -f fabmkdir .py test

[root@master ~]# fab -f fabmkdir.py test
[root@slave1] Executing task 'test'
[root@slave1] run: mkdir A0124
[root@slave1] run: ls -lh
[root@slave1] out: 总用量 22M
[root@slave1] out: drwxr-xr-x.  2 root root    6 1月  24 15:31 A0124
[root@slave1] out: dr-xr-xr-x.  2 root root  16K 1月  19 11:13 bin
[root@slave1] out: drwxr-xr-x.  2 root root    6 8月  12 2015 etc
[root@slave1] out: drwxr-xr-x.  2 root root    6 8月  12 2015 games
[root@slave1] out: drwxr-xr-x. 15 root root 4.0K 11月 26 16:26 hadoop
[root@slave1] out: drwxr-xr-x.  9 root root 4.0K 10月 19 11:23 hbase
[root@slave1] out: drwxr-xr-x.  3 root root   22 10月 16 17:35 include
[root@slave1] out: drwxr-xr-x.  5 root root   51 11月 24 10:45 java
[root@slave1] out: drwxr-xr-x.  3 root root   24 10月 17 11:46 java_bak
[root@slave1] out: dr-xr-xr-x. 26 root root 4.0K 10月 16 17:36 lib
[root@slave1] out: dr-xr-xr-x. 40 root root  20K 1月  19 11:13 lib64
[root@slave1] out: drwxr-xr-x. 15 root root 4.0K 10月 28 16:40 libexec
[root@slave1] out: drwxr-xr-x. 12 root root 4.0K 10月 16 17:34 local
[root@slave1] out: dr-xr-xr-x.  2 root root  12K 10月 28 16:40 sbin
[root@slave1] out: drwxrwxr-x.  6 root root   46 10月 28 11:08 scala
[root@slave1] out: drwxr-xr-x. 71 root root 4.0K 10月 16 17:37 share
[root@slave1] out: drwxr-xr-x. 17 root root 4.0K 11月 10 17:59 spark
[root@slave1] out: drwxr-xr-x.  4 root root   32 10月 16 17:34 src
[root@slave1] out: drwxr-xr-x.  3 root root   19 1月  18 11:54 storm1.0.0
[root@slave1] out: drwxr-xr-x. 14 root root 4.0K 1月  18 13:58 storm1.1.1
[root@slave1] out: lrwxrwxrwx.  1 root root   10 10月 16 17:34 tmp -> ../var/tmp
[root@slave1] out: drwxr-xr-x. 13 1000 1000 4.0K 1月  24 15:02 zookeeper
[root@slave1] out: -rw-r--r--.  1 root root  22M 2月  22 2016 zookeeper-3.4.8.tar.gz
[root@slave1] out: 




Done.
Disconnecting from slave1... done.
[root@master ~]# 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值