Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ansible-playbook -> ControlPath too long

I just trying ouy a playbook that a colleague has set up that I needed to modify. The first problem I get running on my mac was

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

This was easily solved by adding -i verif to the command. But then the following error occured.

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

This is true for all 8 machines (loadgen-verif-app[1-8].internal.machines)

After some debugging that the file could be too long, I tried the following command with the same result:

ansible nukes -m ping -i verif -vvvv

then I thought it was issues with ssh but executing the command through ssh works:

ssh loadgen-verif-app1.internal.machines ping loadgen-verif-app2.internal.machines

And now I am stumped because the ping command works on some of the machines not in the range listed above, the thing is that they are shorter than the loagenXXX.machines path if that makes it an issue. But then the ssh command shouldn't work I guess.

I have some ssh config settings set up for the targets as well, but that is no different that the ones that did work with the ping command.

Host loadgen1
    HostName loadgen-verif-app1.internal.machines

Now I am stumped as it works for the colleague on a mac as well. So not sure if there is some setting i'm missing or similar. He doesn't need to provide the -i verif either that can also be a reason why it doesn't work.

edit 2014-12-17:

  • Have tried modifying the ansible setting control_path according to http://docs.ansible.com/intro_configuration.html#control-path
  • We are running the same version of ansible
  • We are running the same version of OpenSSH.
  • We have the same ssh configs as far as we can tell.
  • Have been looking for Host* that I found in /etc/ssh_config and removed without progress according to 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-

edit 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

edit 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

And with the working one:

SE-C02N76PGG5RP:verif_provisioning andreas.joelsson$ ansible duke -m ping -i verif
steve-verif-app1.internal.machines | success >> {
    "changed": false,
    "ping": "pong"
}
like image 707
Andreas Avatar asked Dec 15 '14 15:12

Andreas


2 Answers

Solution to this error is mentioned at ansible documentation, please refer to this link.

I was getting this error, when I tried to connect to EC2 instances but after modifying the below mentioned configuration, it solved my problem.

I am supposing that you have installed the ansible on Mac using pip. So, please do these steps:

  1. create the /etc/ansible directory

    sudo mkdir /etc/ansible
    
  2. change the permission of it

    sudo chown $(whoami):staff /etc/ansible
    
  3. download the ansible.cfg file from here and place inside the /etc/ansible directory

  4. edit/uncomment the following line

    [ssh_connection]
    control_path = %(directory)s/%%h-%%r
    
  5. edit the ~/.ssh/config file:

    Host *
      GSSAPIAuthentication no
    

EXTRA STEP:

brew install https://raw.github.com/eugeneoden/homebrew/eca9de1/Library/Formula/sshpass.rb
like image 94
Arbab Nazar Avatar answered Oct 26 '22 01:10

Arbab Nazar


Ok the way I got it working was that I did the changes in ansible.cfg and the extra steps but it did not work. The only way I found is to export ANSIBLE_SSH_CONTROL_PATH:

This is coz, I think it always is picking the default path. Even after the change in ansible.cfg

  1.9.4 git:(master) pwd                                                                                                                                            
/usr/local/Cellar/ansible/1.9.4
➜  1.9.4 git:(master) ag ANSIBLE_SSH_CONTROL
libexec/lib/python2.7/site-packages/ansible/constants.py
187:ANSIBLE_SSH_CONTROL_PATH       = get_config(p, 'ssh_connection', 'control_path', 'ANSIBLE_SSH_CONTROL_PATH', "%(directory)s/ansible-ssh-%%h-%%p-%%r")

Output without exporting ANSIBLE_SSH_CONTOL_PATH:

ControlPath="/Users/vinitkhandagle/.ansible/cp/ansible-ssh-%h-%p-%r"

Exported the variable as:

export ANSIBLE_SSH_CONTROL_PATH='%(directory)s/%%h-%%r'

Control path changes accordingly:

ControlPath="/Users/vinitkhandagle/.ansible/cp/%h-%r"
like image 30
vinit khandagle Avatar answered Oct 26 '22 00:10

vinit khandagle