Subscribed unsubscribe Subscribe Subscribe

oinume journal

Scratchpad of what I learned

CentOS 6.x上でtomahawk-0.4.x使ってsudoつきのコマンドが失敗する場合

CentOS 6.2で sudo 付きのコマンドを送る場合は

 

tomahawk -o=-t -l -h localhost 'sudo uptime'

 

のように、-o=-t をつけます。これでssh時に pseudo-tty が割り当てられる。ちなみに今開発中の0.5系はデフォルトで -o=-t がつく状態になっています。

 

あと、-D でデバッグ出力が有効になります。同僚からバグ報告をもらったのですが、"sudo: sorry, you must have a tty to run sudo

" と言われているので、「ああ、そういうことか」とわかりました。

 

 

$ bin/tomahawk -D -l -h localhost 'sudo uptime'

[DEBUG] options = Namespace(command=['sudo uptime'],

continue_on_error=None, debug=True, delay=0,

expect_delay=0.050000000000000003, expect_encoding='utf-8',

expect_timeout=None, hosts='localhost', hosts_files=None,

no_sudo_password=False, output_format='${user}@${host} %

${command}n${output}n', parallel=1, profile=False,

prompt_login_password=True, prompt_sudo_password=False, ssh='ssh',

ssh_options=None, ssh_user=None, timeout=10)

[DEBUG] arguments = ['sudo uptime']

Enter a password for ssh authentication:

Enter a password for sudo:

 

[DEBUG] command = ssh, args = ['-l', 'kazuhiro', 'localhost', '/bin/sh',

'-c', '"sudo uptime"']

[DEBUG] expect index = 1

[DEBUG] expect.EOF

[DEBUG] child closed.

[DEBUG] exit_status = 1

[DEBUG] line = kazuhiro@localhost's password: *********

[DEBUG] line = sudo: sorry, you must have a tty to run sudo

[DEBUG] output_text = sudo: sorry, you must have a tty to run sudo

[error] kazuhiro@localhost % sudo uptime

sudo: sorry, you must have a tty to run sudo

Command failed ! (status = 1)

[error] Command "sudo uptime" failed on host "localhost"