<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">vault</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="devel"><pre class="notranslate"><code class="notranslate">devel
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<h5 dir="auto">OS / ENVIRONMENT</h5>

<h5 dir="auto">SUMMARY</h5>
<p dir="auto">A single vault encrypted value does not get decrypted in a jinja2 pipeline.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>

<p dir="auto">Don't worry the below vault data is just useless strings.</p>

<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- hosts: localhost
  gather_facts: false
  vars:
    the_password: !vault |
          $ANSIBLE_VAULT;1.1;AES256
          66653436353263336535316333313533666563386463623562396234313064643430323066626538
          3234393066313964393861613431313832306439383633340a653361636537303033313137613933
          33653333633139353736636332333237613761636430356665383839663164363739323337643333
          6466313434306462370a663539346162623836626165343830666536646631616165636438646639
          6134
  tasks:
    - command: 'echo {{ the_password|string|type_debug }}'"><pre class="notranslate">---
- <span class="pl-ent">hosts</span>: <span class="pl-s">localhost</span>
  <span class="pl-ent">gather_facts</span>: <span class="pl-c1">false</span>
  <span class="pl-ent">vars</span>:
    <span class="pl-ent">the_password</span>: <span class="pl-k">!vault</span> <span class="pl-s">|</span>
<span class="pl-s">          $ANSIBLE_VAULT;1.1;AES256</span>
<span class="pl-s">          66653436353263336535316333313533666563386463623562396234313064643430323066626538</span>
<span class="pl-s">          3234393066313964393861613431313832306439383633340a653361636537303033313137613933</span>
<span class="pl-s">          33653333633139353736636332333237613761636430356665383839663164363739323337643333</span>
<span class="pl-s">          6466313434306462370a663539346162623836626165343830666536646631616165636438646639</span>
<span class="pl-s">          6134</span>
<span class="pl-s"></span>  <span class="pl-ent">tasks</span>:
    - <span class="pl-ent">command</span>: <span class="pl-s"><span class="pl-pds">'</span>echo {{ the_password|string|type_debug }}<span class="pl-pds">'</span></span></pre></div>
<p dir="auto">This outputs:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;stdout&quot;: &quot;AnsibleVaultEncryptedUnicode&quot;"><pre class="notranslate"><code class="notranslate">"stdout": "AnsibleVaultEncryptedUnicode"
</code></pre></div>
<p dir="auto">This is a little bit of a contrived example, but what it shows, is that if you want to do something like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- command: &quot;some_command {{ the_password|quote }}&quot;"><pre class="notranslate"><code class="notranslate">- command: "some_command {{ the_password|quote }}"
</code></pre></div>
<p dir="auto">You will end up with the <code class="notranslate">$ANSIBLE_VAULT;...</code> string instead of the decrypted value</p>

<h5 dir="auto">EXPECTED RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"><code class="notranslate"></code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"><code class="notranslate">
</code></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">script module</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible --version
ansible 2.3.0 (devel 7018aa3316) last updated 2017/03/03 14:22:37 (GMT -500)
  config file =
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">$ ansible --version
ansible 2.3.0 (devel 7018aa3316) last updated 2017/03/03 14:22:37 (GMT -500)
  config file =
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<p dir="auto">ansible.cfg from git pull</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">Management host: macOS 10.12.3<br>
Managemed host: Windows Server 2008 R2 Standard</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">The script module reports managed hosts as UNREACHABLE</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: install chocolatey
  script: 'InstallChocolatey.ps1'
  register: choco
  failed_when: choco.rc != 0
  changed_when: False"><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">install chocolatey</span>
  <span class="pl-ent">script</span>: <span class="pl-s"><span class="pl-pds">'</span>InstallChocolatey.ps1<span class="pl-pds">'</span></span>
  <span class="pl-ent">register</span>: <span class="pl-s">choco</span>
  <span class="pl-ent">failed_when</span>: <span class="pl-s">choco.rc != 0</span>
  <span class="pl-ent">changed_when</span>: <span class="pl-c1">False</span></pre></div>
<div class="highlight highlight-source-powershell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="try 
{
    if ($PSVersionTable.psversion.Major -ge 3)
    {
        Write-Verbose &quot;Powershell 3+&quot;
        $env:chocolateyUseWindowsCompression = 'false'
        iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
        exit $LASTEXITCODE
    }
    else 
    {
        Write-Verbose &quot;Powershell 3 or lower&quot;
        iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
        exit $LASTEXITCODE
    }
}
catch
{
    $ErrorMessage = $_.Exception.Message
    $FailedItem = $_.Exception.ItemName
    Write-Host &quot;Error: $ErrorMessage&quot;
    exit -1
}"><pre class="notranslate"><span class="pl-k">try</span> 
{
    <span class="pl-k">if</span> (<span class="pl-c1">$PSVersionTable<span class="pl-smi">.psversion.Major</span></span> <span class="pl-k">-ge</span> <span class="pl-c1">3</span>)
    {
        <span class="pl-c1">Write-Verbose</span> <span class="pl-s"><span class="pl-pds">"</span>Powershell 3+<span class="pl-pds">"</span></span>
        <span class="pl-smi">$<span class="pl-c1">env:</span>chocolateyUseWindowsCompression</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>false<span class="pl-pds">'</span></span>
        iwr https:<span class="pl-k">//</span>chocolatey.org<span class="pl-k">/</span>install.ps1 <span class="pl-k">-</span>UseBasicParsing <span class="pl-k">|</span> iex
        <span class="pl-k">exit</span> <span class="pl-c1">$LASTEXITCODE</span>
    }
    <span class="pl-k">else</span> 
    {
        <span class="pl-c1">Write-Verbose</span> <span class="pl-s"><span class="pl-pds">"</span>Powershell 3 or lower<span class="pl-pds">"</span></span>
        iex ((<span class="pl-c1">New-Object</span> System.Net.WebClient).DownloadString(<span class="pl-s"><span class="pl-pds">'</span>https://chocolatey.org/install.ps1<span class="pl-pds">'</span></span>))
        <span class="pl-k">exit</span> <span class="pl-c1">$LASTEXITCODE</span>
    }
}
<span class="pl-k">catch</span>
{
    <span class="pl-smi">$ErrorMessage</span> <span class="pl-k">=</span> <span class="pl-c1">$_<span class="pl-smi">.Exception.Message</span></span>
    <span class="pl-smi">$FailedItem</span> <span class="pl-k">=</span> <span class="pl-c1">$_<span class="pl-smi">.Exception.ItemName</span></span>
    <span class="pl-c1">Write-Host</span> <span class="pl-s"><span class="pl-pds">"</span>Error: <span class="pl-smi">$ErrorMessage</span><span class="pl-pds">"</span></span>
    <span class="pl-k">exit</span> <span class="pl-c1">-1</span>
}</pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">Latest version of chocolatey would be installed</p>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto">Running the powershell script interactively works as expected, failure only occurs when run via the script module.</p>
<p dir="auto">The same script tasks functions correctly on Windows7, Windows8, and Windows10.</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK [win_chocolatey : install chocolatey] *************************************
task path: /Users/tanner/projects/ansible.git/playbooks.git/roles/win_chocolatey/tasks/main.yml:22
&lt;vconsole.igi.com&gt; ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO vconsole.local
EXEC (via pipeline wrapper)
EXEC (via pipeline wrapper)
fatal: [vconsole.local]: UNREACHABLE! =&gt; {
    &quot;changed&quot;: false,
    &quot;msg&quot;: &quot;Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in \&quot;/tmp\&quot;. Failed command was: PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UwBlAHQALQBTAHQAcgBpAGMAdABNAG8AZABlACAALQBWAGUAcgBzAGkAbwBuACAATABhAHQAZQBzAHQACgAoAE4AZQB3AC0ASQB0AGUAbQAgAC0AVAB5AHAAZQAgAEQAaQByAGUAYwB0AG8AcgB5ACAALQBQAGEAdABoACAAJABlAG4AdgA6AHQAZQBtAHAAIAAtAE4AYQBtAGUAIAAiAGEAbgBzAGkAYgBsAGUALQB0AG0AcAAtADEANAA4ADgANQA3ADYANwA2ADAALgAxADcALQAxADIAMwA5ADgANQA3ADgANwA0ADkANwA0ADcAMgAiACkALgBGAHUAbABsAE4AYQBtAGUAIAB8ACAAVwByAGkAdABlAC0ASABvAHMAdAAgAC0AUwBlAHAAYQByAGEAdABvAHIAIAAnACcAOwAKAEkAZgAgACgALQBuAG8AdAAgACQAPwApACAAewAgAEkAZgAgACgARwBlAHQALQBWAGEAcgBpAGEAYgBsAGUAIABMAEEAUwBUAEUAWABJAFQAQwBPAEQARQAgAC0ARQByAHIAbwByAEEAYwB0AGkAbwBuACAAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQApACAAewAgAGUAeABpAHQAIAAkAEwAQQBTAFQARQBYAEkAVABDAE8ARABFACAAfQAgAEUAbABzAGUAIAB7ACAAZQB4AGkAdAAgADEAIAB9ACAAfQA=, exited with result 1: C:\\Users\\Administrator\\AppData\\Local\\Temp\\ansible-tmp-1488576760.17-123985787497472\r\n&quot;,
    &quot;unreachable&quot;: true
}```

Running with ANSIBLE_KEEP_REMOTE_FILES=1 I find the temp directory C:\\Users\\Administrator\\AppData\\Local\\Temp\\ansible-tmp-xxxx-xxxxx but I do not find anything inside the directory. 

Maybe that's because the script is encoded and passed as the -EncodedCommand, just making note of it here."><pre class="notranslate"><code class="notranslate">TASK [win_chocolatey : install chocolatey] *************************************
task path: /Users/tanner/projects/ansible.git/playbooks.git/roles/win_chocolatey/tasks/main.yml:22
&lt;vconsole.igi.com&gt; ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO vconsole.local
EXEC (via pipeline wrapper)
EXEC (via pipeline wrapper)
fatal: [vconsole.local]: UNREACHABLE! =&gt; {
    "changed": false,
    "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UwBlAHQALQBTAHQAcgBpAGMAdABNAG8AZABlACAALQBWAGUAcgBzAGkAbwBuACAATABhAHQAZQBzAHQACgAoAE4AZQB3AC0ASQB0AGUAbQAgAC0AVAB5AHAAZQAgAEQAaQByAGUAYwB0AG8AcgB5ACAALQBQAGEAdABoACAAJABlAG4AdgA6AHQAZQBtAHAAIAAtAE4AYQBtAGUAIAAiAGEAbgBzAGkAYgBsAGUALQB0AG0AcAAtADEANAA4ADgANQA3ADYANwA2ADAALgAxADcALQAxADIAMwA5ADgANQA3ADgANwA0ADkANwA0ADcAMgAiACkALgBGAHUAbABsAE4AYQBtAGUAIAB8ACAAVwByAGkAdABlAC0ASABvAHMAdAAgAC0AUwBlAHAAYQByAGEAdABvAHIAIAAnACcAOwAKAEkAZgAgACgALQBuAG8AdAAgACQAPwApACAAewAgAEkAZgAgACgARwBlAHQALQBWAGEAcgBpAGEAYgBsAGUAIABMAEEAUwBUAEUAWABJAFQAQwBPAEQARQAgAC0ARQByAHIAbwByAEEAYwB0AGkAbwBuACAAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQApACAAewAgAGUAeABpAHQAIAAkAEwAQQBTAFQARQBYAEkAVABDAE8ARABFACAAfQAgAEUAbABzAGUAIAB7ACAAZQB4AGkAdAAgADEAIAB9ACAAfQA=, exited with result 1: C:\\Users\\Administrator\\AppData\\Local\\Temp\\ansible-tmp-1488576760.17-123985787497472\r\n",
    "unreachable": true
}```

Running with ANSIBLE_KEEP_REMOTE_FILES=1 I find the temp directory C:\\Users\\Administrator\\AppData\\Local\\Temp\\ansible-tmp-xxxx-xxxxx but I do not find anything inside the directory. 

Maybe that's because the script is encoded and passed as the -EncodedCommand, just making note of it here.
</code></pre></div>