<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>ansible on CLOSED-WONTFIX</title>
    <link>https://stage.closedwontfix.it/tags/ansible/</link>
    <description>Recent content in ansible on CLOSED-WONTFIX</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <copyright>torture_harps</copyright><atom:link href="https://stage.closedwontfix.it/tags/ansible/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Easily view Ansible-vault secrets with yq</title>
      <link>https://stage.closedwontfix.it/posts/ansible-vault-yq/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>https://stage.closedwontfix.it/posts/ansible-vault-yq/</guid>
      <description>Easily view Ansible-vault secrets with yq As you probably know, ansible-vault is a good way to keep your secrets&amp;hellip;secret.
There&amp;rsquo;s at least two ways to handle vault secrets in your ansible roles:
Put them in a separate file, such as &amp;lsquo;secrets.yml&amp;rsquo;. This makes it easy to encrypt/decrypt as needed, but hides the keys as well as the values. Encrypt the secrets in-line, which reveals the keys, but makes it a bit of a pain to decrypt the individual secrets.</description>
      <content>&lt;h1 id=&#34;easily-view-ansible-vault-secrets-with-yq&#34;&gt;Easily view Ansible-vault secrets with yq&lt;/h1&gt;
&lt;p&gt;As you probably know, ansible-vault is a good way to keep your secrets&amp;hellip;secret.&lt;/p&gt;
&lt;p&gt;There&amp;rsquo;s at least two ways to handle vault secrets in your ansible roles:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Put them in a separate file, such as &amp;lsquo;secrets.yml&amp;rsquo;. This makes it easy to
encrypt/decrypt as needed, but hides the keys as well as the values.&lt;/li&gt;
&lt;li&gt;Encrypt the secrets in-line, which reveals the keys, but makes it a bit
of a pain to decrypt the individual secrets.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this site, we&amp;rsquo;ve chosen the latter approach. So how best to decrypt
individual secrets? Let&amp;rsquo;s try &lt;code&gt;yq&lt;/code&gt;!&lt;/p&gt;
&lt;h2 id=&#34;ok-but-whats-yq&#34;&gt;OK, but what&amp;rsquo;s &amp;ldquo;yq&amp;rdquo;?&lt;/h2&gt;
&lt;p&gt;In &lt;a href=&#34;https://mikefarah.gitbook.io/yq/&#34;&gt;the words of its developer&lt;/a&gt;, yq is &amp;ldquo;a lightweight and portable command-line YAML processor.&amp;rdquo; As you may have guessed
by the name, it is inspired by &lt;code&gt;jq&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;por-ejemplo&#34;&gt;Por Ejemplo&lt;/h2&gt;
&lt;p&gt;Given the defaults file as below:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;cat grafana/defaults/main.yml&lt;/code&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;grafana_admin_pass: !vault |
                            $ANSIBLE_VAULT;1.2;AES256;mir
                            34643432656563306237616661336566646362316632636561326532303662303635323336336461
                            3639663532313635373161316132656434393763373964390a343462326466336138663734393630
                            65633633353032613632313730656463383237616230393532656230316161623333633234666364
                            6435366464306161300a656261323733326432396638623264333633366339353362316532633836
                            64393737303039326530373431623433326161316564646631393439663639383734643934666536
                            6337646663393136383237306461376535316663373965666539
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can easily decrypt the secret using the following command:
&lt;code&gt;cat grafana/defaults/main.yml | yq -r &amp;quot;.grafana_admin_pass&amp;quot; | ansible-vault decrypt&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Which returns:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Decryption successful
6C0F6611-62D7-43E6-B0DD-1E174A3329E7
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As Stan the Man might say&amp;hellip;Excelsior!&lt;/p&gt;
</content>
    </item>
    
  </channel>
</rss>
