Skip to main content
 首页 » 编程设计

python之fabric之如何在部署时获取主机名

2024年10月24日12del

我有一个文件

env.hosts = [ 
    # huge list, 80 hostnames 
] 
def dm(): 
    with cd('/home/project/application'): 
        # how to get the actual hostname here, so I can run certain commands depending on hostname? 

有什么想法吗? fabric 文档对此一无所知

请您参考如下方法:

您可以使用 env.host 访问主机名.