ansible-playbook - > ControlPath太长了

And*_*eas 7 macos ssh yaml ansible

我只是尝试了一个我需要修改的同事设置的剧本.我在mac上运行的第一个问题是

ERROR: Unable to find an inventory file, specify one with -i ?
Run Code Online (Sandbox Code Playgroud)

通过在命令中添加-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
Run Code Online (Sandbox Code Playgroud)

所有8台机器都是如此(loadgen-verif-app [1-8] .internal.machines)

经过一些调试,文件可能太长了,我尝试了以下命令,结果相同:

ansible nukes -m ping -i verif -vvvv
Run Code Online (Sandbox Code Playgroud)

然后我认为这是ssh的问题,但通过ssh执行命令工作:

ssh loadgen-verif-app1.internal.machines ping loadgen-verif-app2.internal.machines
Run Code Online (Sandbox Code Playgroud)

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

我也为目标设置了一些ssh配置设置,但这与使用ping命令的设置没有什么不同.

Host loadgen1
    HostName loadgen-verif-app1.internal.machines
Run Code Online (Sandbox Code Playgroud)

现在我很困难,因为它也适用于Mac上的同事.所以不确定是否有一些设置我缺少或类似.他不需要提供-i verif,这也可能是它无效的原因.

编辑2014-12-17:

编辑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
Run Code Online (Sandbox Code Playgroud)

编辑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
Run Code Online (Sandbox Code Playgroud)

随着工作:

SE-C02N76PGG5RP:verif_provisioning andreas.joelsson$ ansible duke -m ping -i verif
steve-verif-app1.internal.machines | success >> {
    "changed": false,
    "ping": "pong"
}
Run Code Online (Sandbox Code Playgroud)

Arb*_*zar 6

在ansible文档中提到了此错误的解决方案,请参阅此链接.

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

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

  1. 创建/etc/ansible目录

    sudo mkdir /etc/ansible
    
    Run Code Online (Sandbox Code Playgroud)
  2. 改变它的许可

    sudo chown $(whoami):staff /etc/ansible
    
    Run Code Online (Sandbox Code Playgroud)
  3. ansible.cfg这里下载文件并放在/etc/ansible目录中

  4. 编辑/取消注释以下行

    [ssh_connection]
    control_path = %(directory)s/%%h-%%r
    
    Run Code Online (Sandbox Code Playgroud)
  5. 编辑~/.ssh/config文件:

    Host *
      GSSAPIAuthentication no
    
    Run Code Online (Sandbox Code Playgroud)

额外步骤:

brew install https://raw.github.com/eugeneoden/homebrew/eca9de1/Library/Formula/sshpass.rb
Run Code Online (Sandbox Code Playgroud)