在结构中以sudo执行 [英] execute as sudo in fabric

查看:67
本文介绍了在结构中以sudo执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一条命令service app start-demo要求我在命令行中键入sudo service app start-demo.

I have a command service app start-demo requires me to type sudo service app start-demo in the command line.

我使用了sudo(service app start-demo)sudo(sudo service app start-demo),但我仍然得到了

I used sudo(service app start-demo) and sudo(sudo service app start-demo) but I still get

警告:sudo()在执行"sudo服务应用程序启动演示"时遇到错误(返回码1)

Warning: sudo() encountered an error (return code 1) while executing 'sudo service app start-demo'

我可以在终端中将其作为命令行执行.

I have no problem executing that as a command line in a terminal.

我不确定SADeprecationWarning:是否算作结构失败?

I am not sure if SADeprecationWarning: counts as a failure to fabric?

谢谢.

user@box:/var/lib/app$ fab kickstart
You are installing prereqs..........
### Install Prereqs for Populate ###
No hosts found. Please specify (single) host string for connection: localhost
[localhost] Login password: 

### I am starting demo ###
[localhost] sudo: sudo service app start-demo
[localhost] out: Starting demo

Fatal error: sudo() encountered an error (return code 1) while executing 'sudo service app start-demo'

Aborting.
Disconnecting from localhost... done.

代码

def pserve():
    print '### I am starting demo ###'
    #with settings(warn_only=True):
    sudo('sudo service app start-demo')
    #sudo('service app start-demo')

任一sudo命令都将失败.

/etc/sudoers

# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults    env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Allow members of group sudo to execute any command after they have
# provided their password
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d

# Members of the admin group may gain root privileges
%admin ALL=(ALL) NOPASSWD:ALL

推荐答案

这与

This is prolly related to this mention in the faq, but also if the command doesn't return 0 (unix standard for all good) it'll fail-fast unless you tell it to warn only.

这篇关于在结构中以sudo执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆