我有一個fabfile:--user =根似乎並不覆蓋面料env.user,怎麼來的?
env.user = 'deploy'
def infra():
"""You need to use a user that can root itself, deploy cannot without a
password."""
put('conf.d/etc/nginx/sites-available/www.foo.hk',
'/etc/nginx/sites-available/www.foo.hk', use_sudo=True)
sudo('nginx -s reload',)
它在我奔跑像fab infra -Rservers
。
所以我想我可以用--user=root or -u root
覆蓋用戶,當我運行fab infra --user=root
但它仍然要求我輸入密碼。但是,如果我改變env.user
到env.user = 'root'
事實並非如此。我也可以使用設置上下文管理器,如:
def infra(user):
"""You need to use a user that can root itself, deploy cannot without a
password."""
with settings(user=user):
put('conf.d/etc/nginx/sites-available/www.foo.hk',
'/etc/nginx/sites-available/www.foo.hk', use_sudo=True)
sudo('nginx -s reload',)
這有效,當我做fab infra:root -Rservers
。很顯然,可以重寫該設置,但似乎我不能從正常的命令行標誌中獲取。難道我做錯了什麼?
你運行的是什麼版本的面料? – Morgan 2012-07-12 17:25:52