<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>RHEL | A DevOps Blog</title><link>https://blog.bsdserver.nl/tag/rhel/</link><description>Hands-on DevOps and homelab content: Kubernetes clusters, self-hosted services, CI/CD pipelines and infrastructure as code, by Patrick de Ruiter of We Build Your Cloud.</description><language>en</language><image><url>https://blog.bsdserver.nl/images/app-icon.svg</url><title>A DevOps Blog</title><link>https://blog.bsdserver.nl/</link></image><lastBuildDate>Wed, 18 Nov 2026 09:00:00 +0100</lastBuildDate><atom:link href="https://blog.bsdserver.nl/tag/rhel/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title>Automatic Disk Decryption with Tang</title><link>https://blog.bsdserver.nl/automatic-disk-decryption-with-tang/</link><guid isPermaLink="false">693b4fc079eb54000160a43d</guid><dc:creator>Patrick de Ruiter</dc:creator><pubDate>Thu, 11 Dec 2025 23:12:00 +0000</pubDate><description>If you're setting up disk encryption on your Red Hat Enterprise Linux 9 (RHEL9) servers, using a Tang server can be a smart choice to streamline the…</description><category>Linux</category><category>Security</category><category>Ansible</category><category>RHEL</category><category>Encryption</category><media:content url="https://blog.bsdserver.nl/content/images/2026/01/linux-tang-disk-decryption.png" medium="image"/><content:encoded><![CDATA[<p>If you&rsquo;re setting up disk encryption on your Red Hat Enterprise Linux 9 (RHEL9) servers, every reboot asks for a passphrase. In a server farm that means someone at a console for each reboot, which makes automated restarts and patching impractical.</p>
<p>This post deploys a Tang server with Ansible and configures RHEL9 clients through Kickstart, so encrypted volumes unlock automatically at boot as long as the Tang server is reachable.</p>
<h2 id="why-tang">Why Tang? <a class="anchor" data-pagefind-ignore href="#why-tang" aria-label="Link to this section">#</a></h2>
<p>Encryption at rest keeps data unreadable when a disk or server is stolen. Tang removes the operational cost of it:</p>
<ul>
<li><strong>Unattended reboots</strong> - Clients unlock their LUKS volumes over the network, no passphrase typed.</li>
<li><strong>Location-bound unlocking</strong> - A disk only unlocks while it can reach your Tang server. Taken out of the network, it stays locked.</li>
<li><strong>Lightweight</strong> - Tang is a small HTTP service with nothing to manage per client.</li>
<li><strong>Repeatable</strong> - Ansible sets up the server, Kickstart sets up the clients, so every machine is configured the same way.</li>
</ul>
<h3 id="when-to-use-it">When to use it <a class="anchor" data-pagefind-ignore href="#when-to-use-it" aria-label="Link to this section">#</a></h3>
<ul>
<li><strong>Use it</strong> for encrypted servers in a data centre or edge location that must reboot without someone typing a passphrase.</li>
<li><strong>Skip it</strong> for a single machine you reboot by hand, or a machine that is not on a trusted network at boot (a laptop). A passphrase or TPM is simpler there.</li>
</ul>
<h2 id="how-it-works">How It Works <a class="anchor" data-pagefind-ignore href="#how-it-works" aria-label="Link to this section">#</a></h2>
<p>Tang works together with Clevis, the client-side tool that hooks into LUKS.</p>
<table>
	<thead>
			<tr>
					<th>Component</th>
					<th>Runs on</th>
					<th>Job</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>Tang (<code>tangd.socket</code>)</td>
					<td>Tang server</td>
					<td>Answers Clevis requests over HTTP so the client can recover its key.</td>
			</tr>
			<tr>
					<td>Clevis + <code>clevis-dracut</code></td>
					<td>Each encrypted client</td>
					<td>Binds the LUKS volume to Tang and contacts Tang from the initramfs at boot.</td>
			</tr>
			<tr>
					<td>LUKS</td>
					<td>Each encrypted client</td>
					<td>The disk encryption itself. The original passphrase keeps working as a fallback.</td>
			</tr>
	</tbody>
</table>
<p>The flow: client boots → initramfs brings up the network → Clevis contacts Tang → the LUKS key is recovered → the volume unlocks → boot continues.</p>
<h2 id="prerequisites">Prerequisites <a class="anchor" data-pagefind-ignore href="#prerequisites" aria-label="Link to this section">#</a></h2>
<ol>
<li><strong>Red Hat Enterprise Linux 9 (RHEL9) Server</strong>: This tutorial assumes that you are using RHEL9. Make sure the system is installed and configured.</li>
<li><strong>Root or Sudo Access</strong>: You will need root privileges to install packages and configure services.</li>
<li><strong>Ansible Installed</strong>: Ansible should be installed on the control node to automate the deployment process.</li>
<li><strong>FirewallD Installed and Configured</strong>: The playbook assumes you are using FirewallD for managing firewall rules.</li>
<li><strong>Network Connectivity</strong>: Ensure that the Tang server and any client machines can communicate over the network.</li>
<li><strong>Clevis Installed on Clients</strong>: If you plan to use Tang to automate decryption, Clevis must be installed on the client systems.</li>
</ol>
<h2 id="deploying-the-tang-server-with-ansible">Deploying the Tang Server with Ansible <a class="anchor" data-pagefind-ignore href="#deploying-the-tang-server-with-ansible" aria-label="Link to this section">#</a></h2>
<p>Setting up Tang by hand is quick, but you want more than one Tang server for redundancy. A playbook keeps them identical.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl">- <span class="nt">hosts</span><span class="p">:</span><span class="w"> </span><span class="l">tang_server</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">become</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">tasks</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="c"># Install packages required for Tang server</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">Install required packages for Tang server</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">ansible.builtin.package</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">name</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">          </span>- <span class="l">tang</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">          </span>- <span class="l">httpd</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">state</span><span class="p">:</span><span class="w"> </span><span class="l">present</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="c"># Configure firewall rules for Tang server</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">Configure firewall for Tang server</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">ansible.posix.firewalld</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">service</span><span class="p">:</span><span class="w"> </span><span class="l">http</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">permanent</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">state</span><span class="p">:</span><span class="w"> </span><span class="l">enabled</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">immediate</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="c"># Start and enable Tang server</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">Start and enable Tang server</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">ansible.builtin.systemd</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">tangd.socket</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">enabled</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">state</span><span class="p">:</span><span class="w"> </span><span class="l">started</span><span class="w">
</span></span></span></code></pre></div><p>What each task does:</p>
<ul>
<li><strong>Install packages</strong>: installs <code>tang</code> (and <code>httpd</code>).</li>
<li><strong>Firewall</strong>: Tang talks plain HTTP, so the <code>http</code> service (port 80) is opened. <code>immediate: true</code> applies the rule now as well as permanently, without a separate reload.</li>
<li><strong><code>tangd.socket</code></strong>: socket activation. systemd listens on the port and starts Tang per request; <code>enabled: true</code> makes it survive reboots.</li>
</ul>
<h2 id="configuring-the-clients-with-kickstart">Configuring the Clients with Kickstart <a class="anchor" data-pagefind-ignore href="#configuring-the-clients-with-kickstart" aria-label="Link to this section">#</a></h2>
<p>The client side is done at install time: encrypt the volume, install Clevis, and bind the volume to Tang.</p>
<h3 id="finding-the-luks-volume-uuid">Finding the LUKS Volume UUID <a class="anchor" data-pagefind-ignore href="#finding-the-luks-volume-uuid" aria-label="Link to this section">#</a></h3>
<p>You need to know which LUKS volume to bind. To look it up during the Kickstart installation:</p>
<ol>
<li><strong>Open a terminal</strong>: press <code>Ctrl+Alt+F2</code> during the installation.</li>
<li><strong>Find the partition</strong>: run <code>lsblk</code> and locate the encrypted device (e.g. <code>/dev/sda3</code>).</li>
<li><strong>Read its UUID</strong>:</li>
</ol>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo cryptsetup luksUUID /dev/sda3
</span></span></code></pre></div><p>Replace <code>/dev/sda3</code> with your device. The output is the <code>volume-UUID</code> of that LUKS partition, which identifies the volume in your Kickstart configuration.</p>
<h3 id="the-kickstart-snippet">The Kickstart Snippet <a class="anchor" data-pagefind-ignore href="#the-kickstart-snippet" aria-label="Link to this section">#</a></h3>
<p>This snippet installs Clevis, creates the encrypted volume and binds it to Tang in one installation run.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># Install Clevis for client-side automation</span>
</span></span><span class="line"><span class="cl">%packages
</span></span><span class="line"><span class="cl">@core
</span></span><span class="line"><span class="cl">clevis
</span></span><span class="line"><span class="cl">clevis-dracut
</span></span><span class="line"><span class="cl">%end
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Partition and encrypt the logical volume</span>
</span></span><span class="line"><span class="cl">part pv.01 --size<span class="o">=</span><span class="m">1</span> --grow --encrypted --passphrase<span class="o">=</span>&lt;dummy-passphrase&gt;
</span></span><span class="line"><span class="cl">volgroup vg01 pv.01
</span></span><span class="line"><span class="cl">logvol / --fstype<span class="o">=</span><span class="s2">&#34;ext4&#34;</span> --name<span class="o">=</span>root --vgname<span class="o">=</span>vg01 --size<span class="o">=</span><span class="m">20480</span> --encrypted --passphrase<span class="o">=</span>&lt;dummy-passphrase&gt;
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Set up Clevis to use Tang for decryption</span>
</span></span><span class="line"><span class="cl">%post
</span></span><span class="line"><span class="cl"><span class="c1"># Bind the LUKS volume to Tang server for automatic decryption</span>
</span></span><span class="line"><span class="cl">clevis luks <span class="nb">bind</span> -d /dev/mapper/vg01-root tang <span class="s1">&#39;{&#34;url&#34;: &#34;http://&lt;Tang-server-IP&gt;:80&#34;}&#39;</span>
</span></span><span class="line"><span class="cl">%end
</span></span></code></pre></div><table>
	<thead>
			<tr>
					<th>Section</th>
					<th>What it does</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td><code>%packages</code></td>
					<td><code>clevis</code> for binding, <code>clevis-dracut</code> so the initramfs can unlock at boot.</td>
			</tr>
			<tr>
					<td><code>part</code> / <code>volgroup</code> / <code>logvol</code></td>
					<td>Creates the encrypted volume with a temporary passphrase. Replace it after installation.</td>
			</tr>
			<tr>
					<td><code>%post</code></td>
					<td><code>clevis luks bind</code> adds a Tang-based key to the LUKS volume. From then on, boot unlocks it via Tang.</td>
			</tr>
	</tbody>
</table>
<h2 id="security-considerations">Security Considerations <a class="anchor" data-pagefind-ignore href="#security-considerations" aria-label="Link to this section">#</a></h2>
<ul>
<li><strong>Keep the passphrase.</strong> The <code>&lt;dummy-passphrase&gt;</code> stays a valid key. Change it to a strong one and store it safely; it is your fallback when Tang is unreachable.</li>
<li><strong>Tang reachable = disk unlockable.</strong> Anyone with the disk and network access to Tang can unlock it. Only expose Tang on the internal network where your servers boot.</li>
<li><strong>Run more than one Tang server.</strong> If the only Tang server is down, clients wait for the passphrase at boot.</li>
</ul>
<h2 id="conclusion">Conclusion <a class="anchor" data-pagefind-ignore href="#conclusion" aria-label="Link to this section">#</a></h2>
<p>With a few lines of Ansible you have a Tang server, and with a Kickstart snippet every new client binds to it at install time. Encrypted servers can then reboot unattended, whether you run a handful or hundreds.</p>
<p>Give this Ansible playbook a try, and let me know how it works for you! If you have any questions or run into any challenges, feel free to leave a comment.</p>
]]></content:encoded></item></channel></rss>