您知道在EC2上,没有与“ubuntu”用户关联的密码.如果我尝试运行以下几行:
fab development install_dir
我明白了:
[ec2-46-51-132-252.eu-west-1.compute.amazonaws.com] sudo:chown -R webadmin:webadmin / var / www
[ec2-46-51-132-252.eu-west-1.compute.amazonaws.com]登录密码:
我试图将shell = False添加到sudo方法(根据Can I prevent fabric from prompting me for a sudo password?),但它不会改变任何东西
任何的想法 ?非常感谢 !
def development():
env.envname = 'development'
env.user = 'ubuntu'
env.group = 'ubuntu'
env.chuser = 'webadmin'
env.chgroup = 'webadmin'
env.hosts = ['ec2-***.eu-west-1.compute.amazonaws.com']
env.envname_abriev = 'dev'
env.key_filename = '/home/xx/.ssh/xx.pem'
env.postgresql_version = '9.0'
def install_dir():
if not exists('/var/www'):
sudo('mkdir /var/www')
sudo('chown -R %s:%s /var/www' % (env.chuser,env.chgroup))
最佳答案
从aws下载(或创建)密钥对文件,如下所示
原文链接:https://www.f2er.com/python/439187.htmlfrom fabric.context_managers import cd
from fabric.operations import sudo
from fabric.api import run,env
import os
HOME = os.getenv('HOME')
env.user = 'ubuntu'
env.hosts = ['PUBLICDNS.ap-southeast-1.compute.amazonaws.com','ANOTHERSERVER.compute.amazonaws.com'] #can add multiple instances
env.key_filename = [
'%s/
要运行该文件,请在终端中键入fab update.