<p dir="auto">On a solaris 10 target with ansible 1.9.3 using template or copy with become fails with <code class="notranslate">fatal: [rpm-zone3] =&gt; ssh connection closed waiting for a privilege escalation password prompt</code></p>
<p dir="auto">Full log from the failed section:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK: [web | Create CAM pasword file for agent install] ***********************
&lt;rpm-zone3&gt; ESTABLISH CONNECTION FOR USER: gillingh
&lt;rpm-zone3&gt; EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=&quot;/Users/gillingh/.ansible/cp/ansible-ssh-%h-%p-%r&quot; -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 rpm-zone3 /bin/sh -c 'sudo -k &amp;&amp; sudo -H -S -p &quot;[sudo via ansible, key=rcvzjadfoojvpwltuosfnxkbfmoztdvp] password: &quot; -u app-srv /bin/sh -c '&quot;'&quot;'echo BECOME-SUCCESS-rcvzjadfoojvpwltuosfnxkbfmoztdvp; rc=flag; [ -r /tmp/cam_agent_password ] || rc=2; [ -f /tmp/cam_agent_password ] || rc=1; [ -d /tmp/cam_agent_password ] &amp;&amp; rc=3; /tps/bin/python -V 2&gt;/dev/null || rc=4; [ x&quot;$rc&quot; != &quot;xflag&quot; ] &amp;&amp; echo &quot;${rc} &quot;/tmp/cam_agent_password &amp;&amp; exit 0; (/tps/bin/python -c '&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'import hashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1(); afile = open(&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'/tmp/cam_agent_password'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;, &quot;rb&quot;) buf = afile.read(BLOCKSIZE) while len(buf) &gt; 0: hasher.update(buf) buf = afile.read(BLOCKSIZE) afile.close() print(hasher.hexdigest())'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;' 2&gt;/dev/null) || (/tps/bin/python -c '&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'import sha; BLOCKSIZE = 65536; hasher = sha.sha(); afile = open(&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'/tmp/cam_agent_password'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;, &quot;rb&quot;) buf = afile.read(BLOCKSIZE) while len(buf) &gt; 0: hasher.update(buf) buf = afile.read(BLOCKSIZE) afile.close() print(hasher.hexdigest())'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;' 2&gt;/dev/null) || (echo '&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'0 '&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'/tmp/cam_agent_password)'&quot;'&quot;''"><pre class="notranslate"><code class="notranslate">TASK: [web | Create CAM pasword file for agent install] ***********************
&lt;rpm-zone3&gt; ESTABLISH CONNECTION FOR USER: gillingh
&lt;rpm-zone3&gt; EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/gillingh/.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 rpm-zone3 /bin/sh -c 'sudo -k &amp;&amp; sudo -H -S -p "[sudo via ansible, key=rcvzjadfoojvpwltuosfnxkbfmoztdvp] password: " -u app-srv /bin/sh -c '"'"'echo BECOME-SUCCESS-rcvzjadfoojvpwltuosfnxkbfmoztdvp; rc=flag; [ -r /tmp/cam_agent_password ] || rc=2; [ -f /tmp/cam_agent_password ] || rc=1; [ -d /tmp/cam_agent_password ] &amp;&amp; rc=3; /tps/bin/python -V 2&gt;/dev/null || rc=4; [ x"$rc" != "xflag" ] &amp;&amp; echo "${rc} "/tmp/cam_agent_password &amp;&amp; exit 0; (/tps/bin/python -c '"'"'"'"'"'"'"'"'import hashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1(); afile = open("'"'"'"'"'"'"'"'"'/tmp/cam_agent_password'"'"'"'"'"'"'"'"'", "rb") buf = afile.read(BLOCKSIZE) while len(buf) &gt; 0: hasher.update(buf) buf = afile.read(BLOCKSIZE) afile.close() print(hasher.hexdigest())'"'"'"'"'"'"'"'"' 2&gt;/dev/null) || (/tps/bin/python -c '"'"'"'"'"'"'"'"'import sha; BLOCKSIZE = 65536; hasher = sha.sha(); afile = open("'"'"'"'"'"'"'"'"'/tmp/cam_agent_password'"'"'"'"'"'"'"'"'", "rb") buf = afile.read(BLOCKSIZE) while len(buf) &gt; 0: hasher.update(buf) buf = afile.read(BLOCKSIZE) afile.close() print(hasher.hexdigest())'"'"'"'"'"'"'"'"' 2&gt;/dev/null) || (echo '"'"'"'"'"'"'"'"'0 '"'"'"'"'"'"'"'"'/tmp/cam_agent_password)'"'"''
</code></pre></div>
<p dir="auto">A sample copy task is:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- name: Create CAM pasword file for agent install
  become: yes
  become_user: app-srv
  when: agent_list.stdout.find('No configured agents') != -1
  copy: content=&quot;{{ CAM_agent_password }}&quot; dest=/tmp/cam_agent_password
          mode=0600 owner=app-srv group=app-adm
  register: cam_password_file"><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">Create CAM pasword file for agent install</span>
  <span class="pl-ent">become</span>: <span class="pl-s">yes</span>
  <span class="pl-ent">become_user</span>: <span class="pl-s">app-srv</span>
  <span class="pl-ent">when</span>: <span class="pl-s">agent_list.stdout.find('No configured agents') != -1</span>
  <span class="pl-ent">copy</span>: <span class="pl-s">content="{{ CAM_agent_password }}" dest=/tmp/cam_agent_password</span>
          <span class="pl-s">mode=0600 owner=app-srv group=app-adm</span>
  <span class="pl-ent">register</span>: <span class="pl-s">cam_password_file</span></pre></div>
<p dir="auto">The odd thing is, this seems to be specific to the template and copy modules, I use become in the same set of tasks with no issues prior with the command, lineinfile, and user modules.</p>
<h5 dir="auto">Issue Type: Bug Report</h5>
<h5 dir="auto">Ansible Version: 1.9.0.1</h5>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Both Cent OS 6 for source machine and target machine</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">The template module fails(err: <code class="notranslate">ssh connection closed waiting for password prompt</code>) at creating files that require sudo permission with password.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- name: create some init script
  template: src=tmpl.j2 dest=/etc/init.d/{{ item }}
  with_items: [1,2,3]
  sudo: yes"><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">create some init script</span>
  <span class="pl-ent">template</span>: <span class="pl-s">src=tmpl.j2 dest=/etc/init.d/{{ item }}</span>
  <span class="pl-ent">with_items</span>: <span class="pl-s">[1,2,3]</span>
  <span class="pl-ent">sudo</span>: <span class="pl-s">yes</span></pre></div>
<p dir="auto">with the command: <code class="notranslate">ansible-playbook -i inventory xxx.yml --ask-become-pass</code></p>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">Login as a normal user, sudo as a root user and create the init script under /etc/init.d.</p>
<h5 dir="auto">Actually Results:</h5>
<p dir="auto"><code class="notranslate">ssh connection closed waiting for password prompt</code></p>
<p dir="auto">However, I have tried other modules, for instance, <code class="notranslate">file</code> module, it's working fine with same setup.<br>
For your information, I have turned off the pipelining.</p>
<p dir="auto">Looking forward to your reply! Thanks.</p>