macos - ansible-playbook -> ControlPath 太长

标签 macos ssh yaml ansible

我只是在尝试一个同事设置的剧本,我需要修改它。我在 Mac 上运行的第一个问题是

ERROR: Unable to find an inventory file, specify one with -i ?

通过在命令中添加 -i verif 可以轻松解决这个问题。但随后发生了以下错误。
loadgen-verif-app1.internal.machines | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/andreas.joelsson/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: auto-mux: Trying existing master
ControlPath too long

这适用于所有 8 台机器(loadgen-verif-app[1-8].internal.machines)

经过一些调试该文件可能太长后,我尝试了以下命令,结果相同:
ansible nukes -m ping -i verif -vvvv

然后我认为这是 ssh 的问题,但通过 ssh 执行命令有效:
ssh loadgen-verif-app1.internal.machines ping loadgen-verif-app2.internal.machines

现在我很难过,因为 ping 命令在上面列出的范围之外的一些机器上工作,问题是它们比 loagenXXX.machines 路径短,如果这会成为一个问题。但是我猜 ssh 命令应该不起作用。

我也为目标设置了一些 ssh 配置设置,但这与使用 ping 命令的那些设置没有什么不同。
Host loadgen1
    HostName loadgen-verif-app1.internal.machines

现在我很难过,因为它也适用于 Mac 上的同事。所以不确定是否有一些我遗漏或类似的设置。他也不需要提供 -i verif 这也可能是它不起作用的原因。

编辑 2014-12-17:
  • 已尝试根据 http://docs.ansible.com/intro_configuration.html#control-path 修改 ansible 设置 control_path
  • 我们正在运行相同版本的 ansible
  • 我们正在运行相同版本的 OpenSSH。
  • 据我们所知,我们有相同的 ssh 配置。
  • 一直在寻找我在/etc/ssh_config 中找到的 Host* 并根据 f.e. 删除而没有进展。 https://help.openshift.com/hc/en-us/articles/202186044-Unable-to-git-clone-an-application-when-SSH-session-sharing-is-in-use-ControlPath-too-long-

  • 编辑 2015-01-08:
    SE-C02N76PGG5RP:verif_provisioning andreas.joelsson$ ansible loadgen-verif-app1.internal.machines -m ping -i verif -vvvv
    <loadgen-verif-app1.internal.machines> ESTABLISH CONNECTION FOR USER: andreas.joelsson
    <loadgen-verif-app1.internal.machines> REMOTE_MODULE ping
    <loadgen-verif-app1.internal.machines> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/andreas.joelsson/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 loadgen-verif-app1.internal.machines /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1420723708.99-33622628424665 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1420723708.99-33622628424665 && echo $HOME/.ansible/tmp/ansible-tmp-1420723708.99-33622628424665'
    loadgen-verif-app1.internal.machines | FAILED => SSH encountered an unknown error. The output was:
    OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
    debug1: Reading configuration data /Users/andreas.joelsson/.ssh/config
    debug1: Reading configuration data /etc/ssh_config
    debug1: /etc/ssh_config line 20: Applying options for *
    debug1: auto-mux: Trying existing master
    ControlPath too long
    

    编辑 2015-02-12:
    SE-C02N76PGG5RP:verif_provisioning andreas.joelsson$ ansible nukes -m ping -i verif
    loadgen-verif-app4.internal.machines | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
    loadgen-verif-app5.internal.machines | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
    loadgen-verif-app3.internal.machines | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
    loadgen-verif-app1.internal.machines | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
    loadgen-verif-app2.internal.machines | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
    loadgen-verif-app8.internal.machines | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
    loadgen-verif-app6.internal.machines | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
    loadgen-verif-app7.internal.machines | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
    

    和工作:
    SE-C02N76PGG5RP:verif_provisioning andreas.joelsson$ ansible duke -m ping -i verif
    steve-verif-app1.internal.machines | success >> {
        "changed": false,
        "ping": "pong"
    }
    

    最佳答案

    ansible 文档中提到了此错误的解决方案,请引用此 link .

    我收到此错误,当我尝试连接到 EC2 实例但修改下面提到的配置后,它解决了我的问题。

    我假设您已经使用 pip 在 Mac 上安装了 ansible。因此,请执行以下步骤:

  • 创建 /etc/ansible目录
    sudo mkdir /etc/ansible
    
  • 更改它的权限
    sudo chown $(whoami):staff /etc/ansible
    
  • 下载 ansible.cfg文件来自 here并放入 /etc/ansible目录
  • 编辑/取消注释以下行
    [ssh_connection]
    control_path = %(directory)s/%%h-%%r
    
  • 编辑 ~/.ssh/config文件:
    Host *
      GSSAPIAuthentication no
    

  • 额外步骤:
    brew install https://raw.github.com/eugeneoden/homebrew/eca9de1/Library/Formula/sshpass.rb
    

    关于macos - ansible-playbook -> ControlPath 太长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27487332/

    相关文章:

    ios - DMG 安装程序可以支持脚本吗?

    bash - 在远程机器上运行本地脚本之前获取环境变量并执行 bash

    yaml - 向测试厨房添加属性

    java - 如何在java中调用yaml节点

    azure-devops - 值为 yaml 中变量名的变量

    macos - 在 wxPython for Mac 中获取顶部窗口

    swift - 如何仅为一个特定的修改器更改应用动画?

    java - 形状 jdialog 用于透明效果,导致拖动问题

    ssh - 是否可以通过ssh使用OpenCL?

    bash - 脚本检查我是否可以访问多个服务器