如何解决puppet open3.capture3 返回 127 not found
我正在尝试为 puppet 编写自定义函数。 这是:
require 'open3'
Puppet::Functions.create_function(:'clickhouse::query') do
# Headers (somehow are called signatures in puppet)
dispatch :query do
param 'String',:query_string
param 'String',:db_user
param 'String',:db_password
optional_param 'Integer',:db_timeout
optional_param 'String',:bin_path
return_type 'String'
end
# Implementations
def query(query_string,db_user,db_password,db_timeout=3,bin_path='/usr/bin')
cmd_string = "#{bin_path}clickhouse-client --user #{db_user}--password #{db_password} --idle_connection_timeout #{db_timeout} --query='#{query_string}';"
stdout,stderr,status = Open3.capture3(cmd_string,:binmode=>true)
if not status.success?
raise Puppet::ParseError,"clickhouse::query failure: exitcode #{status.exitstatus} stdout #{stdout} stderr #{stderr}"
end
return stdout
end
end
我尝试了 capture3 和 popen3 的所有选项,但总是得到
错误:无法从远程服务器检索目录:服务器上的错误 500:服务器错误:评估错误:评估函数调用时出错,clickhouse::query 失败:exitcode 127 stdout stderr sh:1:clickhouse-client:not找到
我尝试了 /usr/bin/clickhouse-client,/usr/bin/clickhouse client,PATH=/usr/bin /usr/bin/clickhouse-client,/bin/bash -c "/usr/bin/clickhouse-client"
但总是得到相同的结果。
也许有什么秘诀?
顺便说一句:/usr/bin/clickhouse-client 存在
# /usr/bin/clickhouse-client
ClickHouse client version 20.12.4.5 (official build).
Connecting to localhost:9000 as user default.
Code: 516. DB::Exception: Received from localhost:9000. DB::Exception: default: Authentication Failed: password is incorrect or there is no user with such name.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。