<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">ansible 1.7.2</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Management: Mac OS X<br>
Target: Debian stable</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">I have a SSL certificate stored in a vault file, one of my task copies it to a file (using the copy module) on the remote server.<br>
This worked perfectly on 1.7.1, on 1.7.2 it adds an extra newline after every line which causes my webserver to fail.</p>
<p dir="auto">Summary: copy module using content from ansible-vault variable -&gt; extra newlines in target file. Bug is not present in 1.7.1. Possibly unrelated to ansible-vault.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<ol dir="auto">
<li>Create a vault file</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ssl_crt: |
  -----BEGIN CERTIFICATE-----
  Content goes here
  -----END CERTIFICATE-----"><pre class="notranslate"><code class="notranslate">ssl_crt: |
  -----BEGIN CERTIFICATE-----
  Content goes here
  -----END CERTIFICATE-----
</code></pre></div>
<ol dir="auto">
<li>Have a task using vault (include the vault vars file)</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: Copy the SSL certificate to the remote server
  copy: content=&quot;{{ ssl_crt }}&quot; dest=/etc/ssl/mycert.crt"><pre class="notranslate"><code class="notranslate">- name: Copy the SSL certificate to the remote server
  copy: content="{{ ssl_crt }}" dest=/etc/ssl/mycert.crt
</code></pre></div>
<h5 dir="auto">Expected Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/etc/ssl# cat -e mycert.crt
-----BEGIN CERTIFICATE-----$
Content goes here$
-----END CERTIFICATE-----$"><pre class="notranslate"><code class="notranslate">/etc/ssl# cat -e mycert.crt
-----BEGIN CERTIFICATE-----$
Content goes here$
-----END CERTIFICATE-----$
</code></pre></div>
<h5 dir="auto">Actual Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/etc/ssl# cat -e mycert.crt
-----BEGIN CERTIFICATE-----$
$
Content goes here$
$
-----END CERTIFICATE-----$"><pre class="notranslate"><code class="notranslate">/etc/ssl# cat -e mycert.crt
-----BEGIN CERTIFICATE-----$
$
Content goes here$
$
-----END CERTIFICATE-----$
</code></pre></div>
<p dir="auto">I'm in Melbourne, Australia and I'm using ansible to set up a VM on Rackspace in their DFW location.</p>
<p dir="auto">Ansible runs take a very, very long time mainly because paramiko sets up a new connection for every task.</p>
<p dir="auto">I'm aware that I can switch to using "vanilla" ssh and thus gain the benefit of a ControlMaster/ControlPersist type arrangement but it seems to me that a better approach would be for ansible to cache connections in order to avoid having to wear the connection and authentication cost once per task.</p>
<p dir="auto">I'm currently looking at refactoring the Connection classes to look more like ConnectionManager classes from which one requests a connection, thus allowing them to hand out cached connections on a (host, user) basis.</p>
<p dir="auto">Is this an acceptable approach?</p>