hi,i'am a sa&dba,for do remote task i find fabric+py,this very good for me。 and i have question for help: how could i run fabric task at any host?like this:when i finish a py script with fab,at host A,i can run python fabfile.py,it‘s work done and good。but i want make&complete the script with pyinstaller,it did work,raise error。
*follow is this script:* [root@gtlionsdev opt]# cat fabfile.py #!/usr/bin/env python # -*- coding: utf-8 -*- #------------------------------------------------------------------------------- # Name: # Filename : NewPython.py # What: # Version: # Release: 2012-9-26 # Author: Gtlions # Copyright: Copyright (c) Gtlions 2012 <[email protected]> # Licence: <Gtlions's licence> #------------------------------------------------------------------------------- from fabric.api import * env.hosts=['[email protected]','[email protected]','[email protected]'] env.passwords={'[email protected]':'hwttportal3','[email protected] ':'hwttmcp','[email protected]':'rbtdev'} def hostname(): '''show hostname''' run('hostname') def disk(): '''show diskinfo''' run('df -h') *work good use pytho fabfile.py* *[root@gtlionsdev opt]# fab disk* [[email protected]] Executing task 'disk' [[email protected]] run: df -h [[email protected]] out: 文件系统 容量 已用 可用 已用% 挂载点 [[email protected]] out: /dev/cciss/c0d0p8 2.9G 933M 1.8G 34% / [[email protected]] out: /dev/cciss/c0d0p9 609G 259G 319G 45% /usr [[email protected]] out: /dev/cciss/c0d0p7 2.9G 70M 2.7G 3% /tmp [[email protected]] out: /dev/cciss/c0d0p6 4.8G 4.1G 437M 91% /home [[email protected]] out: /dev/cciss/c0d0p5 4.8G 180M 4.4G 4% /var/log [[email protected]] out: /dev/cciss/c0d0p2 29G 6.6G 21G 25% /opt [[email protected]] out: /dev/cciss/c0d0p1 2.9G 93M 2.6G 4% /boot [[email protected]] out: tmpfs 1.8G 0 1.8G 0% /dev/shm [[email protected]] Executing task 'disk' [[email protected]] run: df -h [[email protected]] out: 文件系统 容量 已用 可用 已用% 挂载点 [[email protected]] out: /dev/mapper/VolGroup00-LogVol00 [[email protected]] out: 130G 51G 73G 42% / [[email protected]] out: /dev/sda1 99M 12M 82M 13% /boot [[email protected]] out: tmpfs 471M 0 471M 0% /dev/shm [[email protected]] Executing task 'disk' [[email protected]] run: df -h [[email protected]] out: 文件系统 容量 已用 可用 已用% 挂载点 [[email protected]] out: /dev/sda1 6.8G 5.3G 1.2G 82% / [[email protected]] out: tmpfs 252M 0 252M 0% /dev/shm [[email protected]] out: /dev/mapper/vgmain-lv_1 [[email protected]] out: 9.9G 6.4G 3.0G 69% /usr/app Done. Disconnecting from [email protected]... done. Disconnecting from 192.168.2.3... done. Disconnecting from 192.168.2.233... done. *raise error when i run it,with pyinstaller bulid it.* *[root@gtlionsdev opt]# ./fabfile* Traceback (most recent call last): File "<string>", line 15, in <module> File "/opt/pyinstaller/PyInstaller/loader/iu.py", line 409, in importHook raise ImportError("No module named %s" % fqname) ImportError: No module named fabric this problem may be like this:why can‘t run the script name is not named fabfile or fabfile.py;and how user the args -f? thk’s all! 叶子
_______________________________________________ Fab-user mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/fab-user
