<h5 dir="auto">ISSUE TYPE</h5>

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

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.4.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
"><pre class="notranslate"><code class="notranslate">ansible 2.4.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]

</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">DEFAULT_VAULT_PASSWORD_FILE(env: ANSIBLE_VAULT_PASSWORD_FILE) = /test</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">running in ubuntu 16.04<br>
not managing any os.</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">From the output of `ansible-vault --help decrypt</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  --output=OUTPUT_FILE  output file name for encrypt or decrypt; use - for
                        stdout"><pre class="notranslate"><code class="notranslate">  --output=OUTPUT_FILE  output file name for encrypt or decrypt; use - for
                        stdout
</code></pre></div>
<p dir="auto">When using <code class="notranslate">ansible-vault decrypt</code> with <code class="notranslate">--output=-</code> or <code class="notranslate">--output -</code> it decrypts to a file named <code class="notranslate">-</code> instead to stdout as expected.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<p dir="auto">Create  Dockerfile</p>
<div class="highlight highlight-source-dockerfile notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="FROM ubuntu:16.04

RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-add-repository ppa:ansible/ansible
RUN apt-get update
RUN apt-get install -y ansible

ENV ANSIBLE_VAULT_PASSWORD_FILE=test
RUN echo &quot;test&quot; &gt; test
RUN echo &quot;test&quot; &gt; test.txt
RUN ansible-vault encrypt test.txt
RUN ansible-vault decrypt test.txt --output -
RUN cat ./-"><pre class="notranslate"><span class="pl-k">FROM</span> ubuntu:16.04

<span class="pl-k">RUN</span> apt-get update
<span class="pl-k">RUN</span> apt-get install -y software-properties-common
<span class="pl-k">RUN</span> apt-add-repository ppa:ansible/ansible
<span class="pl-k">RUN</span> apt-get update
<span class="pl-k">RUN</span> apt-get install -y ansible

<span class="pl-k">ENV</span> ANSIBLE_VAULT_PASSWORD_FILE=test
<span class="pl-k">RUN</span> echo <span class="pl-s">"test"</span> &gt; test
<span class="pl-k">RUN</span> echo <span class="pl-s">"test"</span> &gt; test.txt
<span class="pl-k">RUN</span> ansible-vault encrypt test.txt
<span class="pl-k">RUN</span> ansible-vault decrypt test.txt --output -
<span class="pl-k">RUN</span> cat ./-</pre></div>
<p dir="auto">run:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="docker build -t ansible-vault-test .
docker run -it --rm ansible-vault-test ansible-vault decrypt --output - test.txt
docker run -it --rm ansible-vault-test  cat -- ./-"><pre class="notranslate">docker build -t ansible-vault-test <span class="pl-c1">.</span>
docker run -it --rm ansible-vault-test ansible-vault decrypt --output - test.txt
docker run -it --rm ansible-vault-test  cat -- ./-</pre></div>

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

<p dir="auto">Breefly:<br>
ansible-vault writes the decrypted file to stdout.</p>
<p dir="auto">TLDR:<br>
run:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="docker build -t ansible-vault-test .
docker run -it --rm ansible-vault-test ansible-vault decrypt --output - test.txt"><pre class="notranslate">docker build -t ansible-vault-test <span class="pl-c1">.</span>
docker run -it --rm ansible-vault-test ansible-vault decrypt --output - test.txt</pre></div>
<p dir="auto">expected result (f.e using ansible 2.3.x ):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="test
Decryption successful"><pre class="notranslate"><code class="notranslate">test
Decryption successful
</code></pre></div>
<p dir="auto">actual result:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Decryption successful"><pre class="notranslate"><code class="notranslate">Decryption successful
</code></pre></div>
<p dir="auto">run:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="docker run -it --rm ansible-vault-test  cat -- ./-"><pre class="notranslate">docker run -it --rm ansible-vault-test  cat -- ./-</pre></div>
<p dir="auto">expected result:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cat: ./-: No such file or directory"><pre class="notranslate"><code class="notranslate">cat: ./-: No such file or directory
</code></pre></div>
<p dir="auto">actual result</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="test"><pre class="notranslate"><code class="notranslate">test
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto">ansible-vault writes the decrypted file to a file named <code class="notranslate">-</code></p>

<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">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.4.0.0"><pre class="notranslate"><code class="notranslate">ansible 2.4.0.0
</code></pre></div>
<p dir="auto">In ansible 2.3.x, it was possible to do <code class="notranslate">ansible-vault decrypt example.txt --output -</code> to get the decrypted output into stdout. In fact, that is advertised in <code class="notranslate">ansible-vault decrypt --help</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  --output=OUTPUT_FILE  output file name for encrypt or decrypt; use - for stdout"><pre class="notranslate"><code class="notranslate">  --output=OUTPUT_FILE  output file name for encrypt or decrypt; use - for stdout
</code></pre></div>
<p dir="auto">In Ansible 2.4, this is bugged and results in a file named <code class="notranslate">-</code>.</p>