<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  
  <title>sol2lin</title>
  <subtitle>Case studies and scenario-based write-ups on Linux, AWS, Kubernetes and infrastructure automation by Yogish Baraskar.</subtitle>
  <link href="https://www.sol2lin.com/feed.xml" rel="self" />
  <link href="https://www.sol2lin.com/" />
  <updated>2026-11-14T00:00:00Z</updated>
  <id>https://www.sol2lin.com/</id>
  <author>
    <name>Yogish Baraskar</name>
  </author>
  <entry>
    <title>Disk full at 2 a.m.: a calm, systematic triage</title>
    <link href="https://www.sol2lin.com/blog/disk-full-at-2am/" />
    <updated>2026-11-14T00:00:00Z</updated>
    <id>https://www.sol2lin.com/blog/disk-full-at-2am/</id>
    <summary>/var hits 100% on a production app server. A repeatable sequence to find the cause, free space safely, and stop it happening again — without deleting the wrong thing.</summary>
    <content type="html">&lt;p&gt;Full filesystems are among the most common Linux incidents, and among the easiest to make worse. The instinct is to
start deleting. The goal of this runbook is to replace instinct with a short, safe sequence.&lt;/p&gt;
&lt;h2&gt;The whole triage in 40 seconds&lt;/h2&gt;
&lt;figure&gt;&lt;a href=&quot;https://www.sol2lin.com/assets/img/gifs/disk-full-triage.gif&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;img src=&quot;https://www.sol2lin.com/assets/img/gifs/disk-full-triage.gif&quot; alt=&quot;Animated terminal session showing df, du, find, lsof and truncate commands freeing space on /var&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;&gt;&lt;/a&gt;&lt;figcaption&gt;Recorded from a scripted, anonymised session — see the tools folder in this site&#39;s repository for how it&#39;s made.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Step 1 — confirm what is actually full&lt;/h2&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-hT&lt;/span&gt; /var        &lt;span class=&quot;token comment&quot;&gt;# space&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-i&lt;/span&gt;  /var        &lt;span class=&quot;token comment&quot;&gt;# inodes — a filesystem can be &quot;full&quot; with free space left&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If &lt;code&gt;IUse%&lt;/code&gt; is 100% and space is not, you’re hunting millions of small files (session files, mail queue, cache), not one
big one. That’s a different search: &lt;code&gt;sudo find /var -xdev -type f | cut -d/ -f2-4 | sort | uniq -c | sort -rn | head&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Step 2 — find where the space went&lt;/h2&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;du&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-xh&lt;/span&gt; --max-depth&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; /var &lt;span class=&quot;token operator&quot;&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;2&lt;/span&gt;&gt;&lt;/span&gt;/dev/null &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-rh&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;head&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;-x&lt;/code&gt; keeps &lt;code&gt;du&lt;/code&gt; on one filesystem, so a mounted &lt;code&gt;/var/lib/docker&lt;/code&gt; or NFS share doesn’t pollute the answer. Drill down one
level at a time until you reach the culprit, then list large files directly:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;find&lt;/span&gt; /var/log &lt;span class=&quot;token parameter variable&quot;&gt;-xdev&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-type&lt;/span&gt; f &lt;span class=&quot;token parameter variable&quot;&gt;-size&lt;/span&gt; +1G &lt;span class=&quot;token parameter variable&quot;&gt;-exec&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-lh&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; +&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Step 3 — check for deleted-but-open files&lt;/h2&gt;
&lt;p&gt;If &lt;code&gt;df&lt;/code&gt; says full but &lt;code&gt;du&lt;/code&gt; can’t find the space, a process is probably holding a deleted file open. The space isn’t
released until that file descriptor closes.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;lsof&lt;/span&gt; +L1            &lt;span class=&quot;token comment&quot;&gt;# open files with link count &amp;lt; 1, i.e. deleted&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The fix is to restart (or signal) the owning process — or, if you can’t restart it yet, truncate through its
descriptor: &lt;code&gt;: &amp;gt; /proc/&amp;lt;pid&amp;gt;/fd/&amp;lt;fd&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Step 4 — free space without destroying evidence&lt;/h2&gt;
&lt;aside class=&quot;callout callout-warning&quot;&gt;&lt;strong&gt;Warning&lt;/strong&gt;&lt;div&gt;&lt;p&gt;&lt;strong&gt;Don’t &lt;code&gt;rm&lt;/code&gt; a log file that a running process is writing to.&lt;/strong&gt; The process keeps writing to the now-invisible
file, the space is not freed, and you’ve just created the deleted-but-open problem from Step 3.&lt;/p&gt;
&lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Safer options, in order of preference:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Compress and move&lt;/strong&gt; the old part if you need it for the post-incident review:
&lt;code&gt;sudo sh -c &#39;tail -n 50000 app.log &amp;gt; /tmp/app.log.tail&#39;&lt;/code&gt; before truncating.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Truncate in place&lt;/strong&gt;: &lt;code&gt;sudo truncate -s 0 /var/log/app/app.log&lt;/code&gt; — the process keeps its file handle and carries on.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Extend the filesystem&lt;/strong&gt; if the data is legitimately needed and the volume group has space:
&lt;code&gt;sudo lvextend -r -L +5G /dev/vg00/var&lt;/code&gt; (&lt;code&gt;-r&lt;/code&gt; grows XFS online in the same step).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Step 5 — fix the cause, not the symptom&lt;/h2&gt;
&lt;p&gt;In this scenario the application wrote to a log that wasn’t covered by logrotate. The permanent fix was a policy file:&lt;/p&gt;
&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;# /etc/logrotate.d/app
/var/log/app/*.log {
    daily
    rotate 14
    maxsize 1G
    compress
    delaycompress
    missingok
    notifempty
    copytruncate
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;copytruncate&lt;/code&gt; is used because this application can’t reopen its log on a signal. If yours can, prefer &lt;code&gt;create&lt;/code&gt; plus a
&lt;code&gt;postrotate&lt;/code&gt; reload — &lt;code&gt;copytruncate&lt;/code&gt; can lose a few lines written during the copy.&lt;/p&gt;
&lt;p&gt;Validate before you walk away: &lt;code&gt;sudo logrotate -d /etc/logrotate.d/app&lt;/code&gt; (dry run) and then
&lt;code&gt;sudo logrotate -f /etc/logrotate.d/app&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Checklist&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;[ ] Space or inodes? (&lt;code&gt;df -h&lt;/code&gt;, &lt;code&gt;df -i&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;[ ] Where? (&lt;code&gt;du -x&lt;/code&gt;, &lt;code&gt;find -size&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;[ ] Deleted-but-open? (&lt;code&gt;lsof +L1&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;[ ] Free safely (truncate / move / extend — not &lt;code&gt;rm&lt;/code&gt; on open files)&lt;/li&gt;
&lt;li&gt;[ ] Root cause fixed and tested (logrotate dry run)&lt;/li&gt;
&lt;li&gt;[ ] Monitor tuned to warn on trend, not just threshold&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  <entry>
    <title>sudo stopped working, but the password is right: debugging PAM account expiry</title>
    <link href="https://www.sol2lin.com/blog/sudo-fails-after-password-expiry/" />
    <updated>2026-10-24T00:00:00Z</updated>
    <id>https://www.sol2lin.com/blog/sudo-fails-after-password-expiry/</id>
    <summary>An application admin can log in with an SSH key but sudo rejects them. The cause is in PAM&#39;s account phase, not authentication — here&#39;s how to prove it and fix it properly.</summary>
    <content type="html">&lt;p&gt;This is one of those tickets that sounds like “user forgot password” and isn’t. The user’s password is correct. Their SSH
key works. And yet:&lt;/p&gt;
&lt;pre class=&quot;language-console&quot;&gt;&lt;code class=&quot;language-console&quot;&gt;$ sudo -i
[sudo] password for appadmin:
You are required to change your password immediately (password expired)
sudo: Account or password is expired, reset your password and try again&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Why a correct password isn’t enough&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;sudo&lt;/code&gt; doesn’t check passwords itself — it hands the job to &lt;strong&gt;PAM&lt;/strong&gt; (Pluggable Authentication Modules), using the
service file &lt;code&gt;/etc/pam.d/sudo&lt;/code&gt;. PAM runs separate management groups, in order:&lt;/p&gt;
&lt;figure&gt;&lt;a href=&quot;https://www.sol2lin.com/assets/img/diagrams/pam-sudo-flow.svg&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;img src=&quot;https://www.sol2lin.com/assets/img/diagrams/pam-sudo-flow.svg&quot; alt=&quot;Diagram of sudo calling PAM: auth passes, account fails on password expiry, password and session are not reached&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;&gt;&lt;/a&gt;&lt;figcaption&gt;Authentication succeeds; the account phase fails. They are different questions.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;auth&lt;/strong&gt; — &lt;em&gt;is this really the user?&lt;/em&gt; (password correct → pass)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;account&lt;/strong&gt; — &lt;em&gt;is this account allowed right now?&lt;/em&gt; (expired, locked, outside allowed hours → fail)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;password&lt;/strong&gt; — used only when changing a password&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;session&lt;/strong&gt; — set-up and tear-down: limits, logging, home directory creation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;SSH key login skips the password check entirely, and depending on &lt;code&gt;UsePAM&lt;/code&gt; and the PAM stack for &lt;code&gt;sshd&lt;/code&gt;, may not trip
the same account checks. That’s why “SSH works” is not evidence the account is healthy.&lt;/p&gt;
&lt;h2&gt;Step 1 — read the account’s ageing data&lt;/h2&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; chage &lt;span class=&quot;token parameter variable&quot;&gt;-l&lt;/span&gt; appadmin&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Last password change                : Aug 01, 2026
Password expires                    : Oct 30, 2026
Password inactive                   : never
Account expires                     : never
Minimum number of days between password change : 1
Maximum number of days between password change : 90
Number of days of warning before password expires : 7&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;90-day maximum, last changed 1 August — expired on 30 October. Mystery solved for local accounts.&lt;/p&gt;
&lt;h2&gt;Step 2 — confirm it in the logs&lt;/h2&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; journalctl &lt;span class=&quot;token parameter variable&quot;&gt;-t&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--since&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;1 hour ago&quot;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-E&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;appadmin.*(expired|account)&#39;&lt;/span&gt; /var/log/secure &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;tail&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Look for &lt;code&gt;pam_unix(sudo:account): expired password&lt;/code&gt; — note &lt;strong&gt;account&lt;/strong&gt;, not &lt;strong&gt;auth&lt;/strong&gt;. On SSSD-backed hosts you’ll see
&lt;code&gt;pam_sss(sudo:account)&lt;/code&gt; instead, and the expiry comes from the directory, so the fix belongs there, not on the server.&lt;/p&gt;
&lt;h2&gt;Step 3 — fix it without weakening the policy&lt;/h2&gt;
&lt;aside class=&quot;callout callout-warning&quot;&gt;&lt;strong&gt;Warning&lt;/strong&gt;&lt;div&gt;&lt;p&gt;Resist &lt;code&gt;chage -M 99999&lt;/code&gt; (“never expire”) as a quick fix. It silently removes a security control and will be found in the
next audit. If an account genuinely shouldn’t expire (a non-interactive service account), make that a documented,
approved exception — and remove its password login entirely.&lt;/p&gt;
&lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;For a human admin account, the clean fix is a controlled reset that forces a change at next login:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;passwd&lt;/span&gt; appadmin          &lt;span class=&quot;token comment&quot;&gt;# set a temporary password via your approved channel&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; chage &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; appadmin      &lt;span class=&quot;token comment&quot;&gt;# force change on next login&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For a &lt;strong&gt;service&lt;/strong&gt; account that only runs automation, the better long-term fix is to remove password-based sudo
altogether: key-based login, a narrowly scoped &lt;code&gt;NOPASSWD&lt;/code&gt; rule for the specific commands it runs, and a locked password
(&lt;code&gt;passwd -l&lt;/code&gt;).&lt;/p&gt;
&lt;h2&gt;Step 4 — make sure nobody is surprised again&lt;/h2&gt;
&lt;p&gt;Expiry is predictable, so it should never be an incident. A small daily check, run from cron or your configuration
management tool, can report accounts expiring soon:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# expiring-accounts.sh — list local accounts whose password expires within N days.&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-euo&lt;/span&gt; pipefail
&lt;span class=&quot;token assign-left variable&quot;&gt;DAYS&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;${1&lt;span class=&quot;token operator&quot;&gt;:-&lt;/span&gt;14}&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;today&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$((&lt;/span&gt; $&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;date &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;%&lt;/span&gt;s&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;86400&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;))&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# /etc/shadow fields: 1=user 3=last change (days since epoch) 5=max age&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;awk&lt;/span&gt; -F: &lt;span class=&quot;token parameter variable&quot;&gt;-v&lt;/span&gt; &lt;span class=&quot;token assign-left variable&quot;&gt;today&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$today&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-v&lt;/span&gt; &lt;span class=&quot;token assign-left variable&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$DAYS&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;
  $2 !~ /^[!*]/ &amp;amp;&amp;amp; $5 != &quot;&quot; &amp;amp;&amp;amp; $5 &amp;lt; 99999 &amp;amp;&amp;amp; $3 != &quot;&quot; {
    left = ($3 + $5) - today
    if (left &amp;lt;= window) printf &quot;%-20s expires in %d day(s)&#92;n&quot;, $1, left
  }&#39;&lt;/span&gt; /etc/shadow&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Feed the output to your monitoring as a low-priority alert, or email the account owners. On SSSD/IdM, query expiry from
the directory instead.&lt;/p&gt;
&lt;h2&gt;Takeaways&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;sudo&lt;/code&gt; failures with a correct password usually live in PAM’s &lt;strong&gt;account&lt;/strong&gt; phase.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;chage -l&lt;/code&gt; and the &lt;code&gt;pam_*(&amp;lt;service&amp;gt;:account)&lt;/code&gt; log line give you the answer in under a minute.&lt;/li&gt;
&lt;li&gt;Fix with a controlled reset, not by disabling expiry; remove passwords from service accounts entirely.&lt;/li&gt;
&lt;li&gt;Predictable failures should be monitored, not discovered.&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  <entry>
    <title>Keeping 350 RHEL servers honest: Satellite registration and monthly licence hygiene</title>
    <link href="https://www.sol2lin.com/blog/satellite-registration-licence-hygiene/" />
    <updated>2026-10-03T00:00:00Z</updated>
    <id>https://www.sol2lin.com/blog/satellite-registration-licence-hygiene/</id>
    <summary>Registration drift is quiet until a licence true-up or an unpatched server finds it for you. A simple monthly routine with Red Hat Satellite and hammer keeps the inventory accurate.</summary>
    <content type="html">&lt;p&gt;In a large RHEL estate, registration drift happens quietly. A VM is rebuilt with the same hostname and now appears twice.
A server is decommissioned but never unregistered. A rushed build skips registration and never receives patches. None of
these break anything on the day — they surface later, during a licence true-up or when a vulnerability scan finds an
unpatched host nobody knew about.&lt;/p&gt;
&lt;h2&gt;The routine&lt;/h2&gt;
&lt;figure&gt;&lt;a href=&quot;https://www.sol2lin.com/assets/img/diagrams/satellite-registration.svg&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;img src=&quot;https://www.sol2lin.com/assets/img/diagrams/satellite-registration.svg&quot; alt=&quot;Flow from new RHEL host registering with an activation key to Satellite, monthly hammer export, and reconciliation against the CMDB&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;&gt;&lt;/a&gt;&lt;figcaption&gt;Register consistently, export monthly, reconcile against what should exist.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3&gt;1. Register consistently — always with an activation key&lt;/h3&gt;
&lt;p&gt;Activation keys bind a host to the right organisation, lifecycle environment and content view in one step, so builds
don’t depend on someone remembering the right options.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# Install the Satellite CA/consumer package, then register (run on the new host)&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;rpm&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-Uvh&lt;/span&gt; https://satellite.example.internal/pub/katello-ca-consumer-latest.noarch.rpm
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; subscription-manager register &lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;
    &lt;span class=&quot;token parameter variable&quot;&gt;--org&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;EXAMPLE_ORG&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;
    &lt;span class=&quot;token parameter variable&quot;&gt;--activationkey&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;rhel9-prod&quot;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; subscription-manager identity    &lt;span class=&quot;token comment&quot;&gt;# confirm registration&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Put this in your build template or provisioning playbook so it isn’t optional. On newer Satellite versions, the
&lt;strong&gt;global registration&lt;/strong&gt; command generated from the web UI does the same job with a single &lt;code&gt;curl | bash&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;2. Export the inventory monthly&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;hammer&lt;/code&gt;, Satellite’s CLI, makes the export scriptable:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;hammer &lt;span class=&quot;token parameter variable&quot;&gt;--output&lt;/span&gt; csv &lt;span class=&quot;token function&quot;&gt;host&lt;/span&gt; list &lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;
    &lt;span class=&quot;token parameter variable&quot;&gt;--organization&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;EXAMPLE_ORG&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;
    &lt;span class=&quot;token parameter variable&quot;&gt;--fields&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Name,Operating System,Lifecycle Environment,Content View,Last Checkin&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;satellite-hosts-&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;date&lt;/span&gt; +%Y-%m&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;.csv&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Keeping one CSV per month gives you a simple history: you can diff months to see what was added and removed.&lt;/p&gt;
&lt;h3&gt;3. Reconcile against what &lt;em&gt;should&lt;/em&gt; exist&lt;/h3&gt;
&lt;p&gt;Compare the Satellite list with your source of truth (CMDB export, VMware inventory, or &lt;code&gt;aws ec2 describe-instances&lt;/code&gt;).
A few lines of shell are enough to find the gaps:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# reconcile.sh &amp;lt;satellite.csv&gt; &amp;lt;cmdb_hosts.txt&gt;  — hostnames one per line in the second file&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-euo&lt;/span&gt; pipefail
&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$#&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-eq&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;usage: &lt;span class=&quot;token variable&quot;&gt;$0&lt;/span&gt; satellite.csv cmdb_hosts.txt&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;&amp;amp;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;exit&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;tail&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-n&lt;/span&gt; +2 &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$1&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;cut&lt;/span&gt; -d, &lt;span class=&quot;token parameter variable&quot;&gt;-f1&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;s/&#92;..*//&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;A-Z&#39;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;a-z&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-u&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; /tmp/sat.txt
&lt;span class=&quot;token function&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;s/&#92;..*//&#39;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$2&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;A-Z&#39;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;a-z&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-u&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; /tmp/cmdb.txt

&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;== Running but NOT registered (no patches, no entitlement) ==&quot;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;comm&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-13&lt;/span&gt; /tmp/sat.txt /tmp/cmdb.txt
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;== Registered but NOT in CMDB (decommissioned? paying for nothing) ==&quot;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;comm&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-23&lt;/span&gt; /tmp/sat.txt /tmp/cmdb.txt&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Short hostnames are compared, lower-cased, so &lt;code&gt;APP01.example.internal&lt;/code&gt; and &lt;code&gt;app01&lt;/code&gt; match.&lt;/p&gt;
&lt;h3&gt;4. Act on the findings&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Finding&lt;/th&gt;
&lt;th&gt;Typical cause&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;No check-in for 30+ days&lt;/td&gt;
&lt;td&gt;Host decommissioned or powered off&lt;/td&gt;
&lt;td&gt;Confirm, then &lt;code&gt;hammer host delete&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Same name registered twice&lt;/td&gt;
&lt;td&gt;Rebuilt from template&lt;/td&gt;
&lt;td&gt;Remove the older record&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Running but unregistered&lt;/td&gt;
&lt;td&gt;Build skipped registration&lt;/td&gt;
&lt;td&gt;Register with the correct activation key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wrong lifecycle environment&lt;/td&gt;
&lt;td&gt;Built with the wrong key&lt;/td&gt;
&lt;td&gt;Move it before the next patch cycle&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;aside class=&quot;callout callout-tip&quot;&gt;&lt;strong&gt;Tip&lt;/strong&gt;&lt;div&gt;&lt;p&gt;Cloud hosts change fastest. If part of your estate is on AWS, run the reconcile against &lt;code&gt;describe-instances&lt;/code&gt;
output filtered by your RHEL AMIs and tags, not against a CMDB that may lag behind autoscaling.&lt;/p&gt;
&lt;/div&gt;&lt;/aside&gt;
&lt;h2&gt;Why bother?&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Licensing&lt;/strong&gt;: the registered-host count is what you’ll be asked to justify.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security&lt;/strong&gt;: an unregistered host doesn’t get content-view updates — it’s effectively unpatched.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Trust&lt;/strong&gt;: when the inventory is right, every other report built on it (patch compliance, vulnerability exposure) is
right too.&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
</feed>