<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Knowledge Base (Posts about vault)</title><link>https://bgstack15.ddns.net/blog/</link><description></description><atom:link href="https://bgstack15.ddns.net/blog/categories/vault.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2022 &lt;a href="mailto:bgstack15@gmail.com"&gt;bgstack15&lt;/a&gt; 
&lt;a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/"&gt;
&lt;img alt="Creative Commons License BY-SA"
style="border-width:0; margin-bottom:12px;"
src="https://bgstack15.ddns.net/.images/l_by-sa_4.0_88x31.png"&gt;&lt;/a&gt;</copyright><lastBuildDate>Sun, 27 Feb 2022 04:05:20 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Verify ansible vault password</title><link>https://bgstack15.ddns.net/blog/posts/2018/09/22/verify-ansible-vault-password/</link><dc:creator>bgstack15</dc:creator><description>&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;# prepare vault password file
printf 'Vault password: ' ; read -se VAULT_PASS ; printf '\n' ;
echo "&lt;span class="cp"&gt;${&lt;/span&gt;&lt;span class="n"&gt;VAULT_PASS&lt;/span&gt;&lt;span class="cp"&gt;}&lt;/span&gt;" &amp;gt; "&lt;span class="cp"&gt;${&lt;/span&gt;&lt;span class="n"&gt;PWFILE&lt;/span&gt;&lt;span class="cp"&gt;}&lt;/span&gt;"
# fail out if password is incorrect
! ansible-vault view --vault-password-file "&lt;span class="cp"&gt;${&lt;/span&gt;&lt;span class="n"&gt;PWFILE&lt;/span&gt;&lt;span class="cp"&gt;}&lt;/span&gt;" "&lt;span class="cp"&gt;${&lt;/span&gt;&lt;span class="n"&gt;VAULTFILE&lt;/span&gt;&lt;span class="cp"&gt;}&lt;/span&gt;" 1&amp;gt;/dev/null &lt;span class="err"&gt;&amp;amp;&amp;amp;&lt;/span&gt; exit 1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can use shell to read in the password and save it to a file. Just remember
to clean it up at the end! I like to do this right before a shell loop that
calls ansible with vaulted values multiple times, so I'm not prompted multiple
times to enter the password.&lt;/p&gt;</description><category>ansible</category><category>password</category><category>shell</category><category>vault</category><guid>https://bgstack15.ddns.net/blog/posts/2018/09/22/verify-ansible-vault-password/</guid><pubDate>Sat, 22 Sep 2018 12:35:37 GMT</pubDate></item></channel></rss>