# ansible 2.0.0, ansible.cfg, and changing the control\_path

**URL:** <https://forum.ansible.com/t/ansible-2-0-0-ansible-cfg-and-changing-the-control-path/19713>\
**Category:** Ansible Developer\
**Created:** [November 9, 2015, 5:07pm UTC](https://forum.ansible.com/t/ansible-2-0-0-ansible-cfg-and-changing-the-control-path/19713 "2015-11-09T17:07:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [November 9, 2015, 5:07pm UTC](https://forum.ansible.com/t/ansible-2-0-0-ansible-cfg-and-changing-the-control-path/19713/1 "2015-11-09T17:07:48Z")

</div>

I have a long path name to my home directory and some fairly long hostnames so I’m hitting the 108 character limit on the control\_path

As a test I changed control\_path in the ansible.cfg

control\_path = /var/tmp/.ansible/cp/%%h-%%p-%%r

Things did not work until I manually created the .ansible/cp inside the /var/tmp/ directory.

Any reason Ansible doesn’t securely create the control\_path?

My old control\_path

control\_path = %(directory)s/%%h-%%p-%%r

I do not recall making the (effectively) $HOME/.ansible/cp/ directory so what changes when moving it to /var/tmp?

Running ansible with “-vvvv” and taking that command and executing it by hand.

$ ssh -C -vvv -o ControlMaster=auto -o ControlPersist=600s -o ForwardAgent=yes -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/var/tmp/.ansible/cp/%h-%p-%r [verylonghostname.longsubdomain.real-time.com](http://verylonghostname.longsubdomain.real-time.com) LANG=C LC\_ALL=C LC\_MESSAGES=C /usr/bin/python

debug3: muxserver\_listen: temporary control path /var/tmp/.ansible/cp/verylonghostname.longsubdomain.real-time.com-22-ansible.e36VI5Uh9JoNL2x2  
bind: No such file or directory  
unix\_listener: cannot bind to path: /var/tmp/.ansible/cp/verylonghostname.longsubdomain.real-time.com-22-ansible.e36VI5Uh9JoNL2x2

$ mkdir /var/tmp/.ansible

$ ssh -C -vvv -o ControlMaster=auto -o ControlPersist=600s -o ForwardAgent=yes -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/var/tmp/.ansible/cp/%h-%p-%r [verylonghostname.longsubdomain.real-time.com](http://verylonghostname.longsubdomain.real-time.com) LANG=C LC\_ALL=C LC\_MESSAGES=C /usr/bin/python

debug3: muxserver\_listen: temporary control path /var/tmp/.ansible/cp/verylonghostname.longsubdomain.real-time.com-22-ansible.e36VI5Uh9JoNL2x2  
bind: No such file or directory  
unix\_listener: cannot bind to path: /var/tmp/.ansible/cp/verylonghostname.longsubdomain.real-time.com-22-ansible.e36VI5Uh9JoNL2x2

$ mkdir /var/tmp/.ansible/cp

$ ssh -C -vvv -o ControlMaster=auto -o ControlPersist=600s -o ForwardAgent=yes -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/var/tmp/.ansible/cp/%h-%p-%r [verylonghostname.longsubdomain.real-time.com](http://verylonghostname.longsubdomain.real-time.com) LANG=C LC\_ALL=C LC\_MESSAGES=C /usr/bin/python

Now things work.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 9, 2015, 5:33pm UTC](https://forum.ansible.com/t/ansible-2-0-0-ansible-cfg-and-changing-the-control-path/19713/2 "2015-11-09T17:33:42Z")

</div>

IIRC ansible only creates the last dir for control path /cp/ in this  
case, other parts of ansible normally create the ~/.ansible for use of  
temprary files. I'm not sure we want the controlpath code to create  
the full tree above the controlpath dir.

---

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [November 9, 2015, 6:00pm UTC](https://forum.ansible.com/t/ansible-2-0-0-ansible-cfg-and-changing-the-control-path/19713/3 "2015-11-09T18:00:54Z")

</div>

Fully understand and appreciate the security ramifications related to the control\_path and creating the directory path. Maybe just a doc change inside the ansible.cfg? Stating what you just posted?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 9, 2015, 6:13pm UTC](https://forum.ansible.com/t/ansible-2-0-0-ansible-cfg-and-changing-the-control-path/19713/4 "2015-11-09T18:13:43Z")

</div>

I was thinking we can add the path expansion to the jsonfile plugin  
itself, as it is the one 'knowingly' overloading the config item.

---

<div class="post-metadata">

**Author:** ![willthames](https://avatars.discourse-cdn.com/v4/letter/w/8dc957/32.png) [@willthames](https://forum.ansible.com/u/willthames)\
**Post date:** [November 20, 2015, 5:55am UTC](https://forum.ansible.com/t/ansible-2-0-0-ansible-cfg-and-changing-the-control-path/19713/5 "2015-11-20T05:55:07Z")

</div>

Fun and games. I’ve found that

control\_path = %(directory)s/%%C

can be really helpful in such circumstances (%C is just a hash of %l%h%p%r, so should keep below the limit)

I’m not sure in what version of openssh %C became available (seems to be on Fedora 22 but not RHEL7.1, for example) but it’s great if you have it.

---

<div class="post-metadata">

**Author:** ![Bob\_Tanner](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Bob\_Tanner](https://forum.ansible.com/u/Bob_Tanner)\
**Post date:** [November 22, 2015, 8:57pm UTC](https://forum.ansible.com/t/ansible-2-0-0-ansible-cfg-and-changing-the-control-path/19713/6 "2015-11-22T20:57:20Z")

</div>

Nice find! Thanks!
