<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nnamdi Felix Ibe</title>
    <description>The latest articles on DEV Community by Nnamdi Felix Ibe (@ndcodes).</description>
    <link>https://dev.to/ndcodes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3994627%2F3c1e9fc3-98cd-45c4-9e34-3ef72ece6604.jpg</url>
      <title>DEV Community: Nnamdi Felix Ibe</title>
      <link>https://dev.to/ndcodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ndcodes"/>
    <language>en</language>
    <item>
      <title>Day 95: An Empty List That Is True and an Empty List That Is Not</title>
      <dc:creator>Nnamdi Felix Ibe</dc:creator>
      <pubDate>Sun, 29 Nov 2026 09:00:00 +0000</pubDate>
      <link>https://dev.to/ndcodes/day-95-an-empty-list-that-is-true-and-an-empty-list-that-is-not-1edd</link>
      <guid>https://dev.to/ndcodes/day-95-an-empty-list-that-is-true-and-an-empty-list-that-is-not-1edd</guid>
      <description>&lt;p&gt;Day 95 of DevOps, Day 45 of Azure. Both tasks printed an empty array, and the two mean opposite things. One is true, documented, and the reason the thing I built would not work. The other is false, and the resource it denied was running at the time.&lt;/p&gt;

&lt;p&gt;One Terraform task, one Azure task. A security group, then a private AKS cluster. The tasks come from the KodeKloud Engineer platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 1: A security group in Terraform
&lt;/h2&gt;

&lt;p&gt;Named &lt;code&gt;xfusion-sg&lt;/code&gt;, described as "Security group for Nautilus App Servers", with inbound TCP 22 and TCP 80.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The configuration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_security_group"&lt;/span&gt; &lt;span class="s2"&gt;"xfusion_sg"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"xfusion-sg"&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Security group for Nautilus App Servers"&lt;/span&gt;

  &lt;span class="n"&gt;ingress&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;from_port&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
    &lt;span class="n"&gt;to_port&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
    &lt;span class="n"&gt;protocol&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"tcp"&lt;/span&gt;
    &lt;span class="n"&gt;cidr_blocks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"0.0.0.0/0"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;ingress&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;from_port&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;
    &lt;span class="n"&gt;to_port&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;
    &lt;span class="n"&gt;protocol&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"tcp"&lt;/span&gt;
    &lt;span class="n"&gt;cidr_blocks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"0.0.0.0/0"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Apply and read it back
&lt;/h3&gt;

&lt;p&gt;Both ingress rules are present, and both the requested ports, name and description are exact. The task is done correctly.&lt;/p&gt;

&lt;p&gt;And then this, in the same response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"IpPermissionsEgress"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Finding out why
&lt;/h3&gt;

&lt;p&gt;That is not "the default is implied and not shown". It is genuinely empty, and it is the documented behaviour of the resource:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By default, AWS creates an &lt;code&gt;ALLOW ALL&lt;/code&gt; egress rule when creating a new Security Group inside of a VPC.&lt;/p&gt;

&lt;p&gt;When creating a new Security Group inside a VPC, Terraform will remove this default rule and require you to specifically re-create it if you desire that rule.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So AWS adds allow-all egress to every new security group, and the provider takes it away again unless the configuration asks for it back. A configuration with &lt;code&gt;ingress&lt;/code&gt; blocks and no &lt;code&gt;egress&lt;/code&gt; block does not mean leave egress alone. It means egress is exactly this list, and the list is empty.&lt;/p&gt;

&lt;p&gt;The consequence is not subtle. An EC2 instance whose only group is this one cannot open an outbound connection to anything at all: no package installs, no DNS to the VPC resolver, no SSM agent registration, no AWS API calls.&lt;/p&gt;

&lt;p&gt;The part that makes it nasty is that the instance still looks reachable. Security groups are stateful, so the response traffic to an allowed inbound flow is permitted regardless of egress rules. SSH in on port 22 works fine. Everything the machine tries to do from there times out.&lt;/p&gt;

&lt;p&gt;The fix is one block, and being explicit about it is the whole point:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;  &lt;span class="n"&gt;egress&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;from_port&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;to_port&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;protocol&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"-1"&lt;/span&gt;
    &lt;span class="n"&gt;cidr_blocks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"0.0.0.0/0"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Two more things from the same page, both of which change what my next Terraform task should look like.&lt;/p&gt;

&lt;p&gt;The provider recommends against the syntax this task uses: "Avoid using the &lt;code&gt;ingress&lt;/code&gt; and &lt;code&gt;egress&lt;/code&gt; arguments of the &lt;code&gt;aws_security_group&lt;/code&gt; resource to configure in-line rules." The current recommendation is one rule per resource with &lt;code&gt;aws_vpc_security_group_ingress_rule&lt;/code&gt; and &lt;code&gt;aws_vpc_security_group_egress_rule&lt;/code&gt;, one CIDR block each. And the two styles must not be mixed, because "Doing so may cause rule conflicts, perpetual differences, and result in rules being overwritten."&lt;/p&gt;

&lt;p&gt;The reason inline rules cause trouble is the same reason my egress list is empty: they are authoritative for the whole list. Anything that adds a rule outside Terraform gets removed on the next apply.&lt;/p&gt;

&lt;p&gt;The other thing is where this group ended up. I set no &lt;code&gt;vpc_id&lt;/code&gt;, and the docs say what that means: "VPC ID. Defaults to the region's default VPC." Which is fine here, but a security group's VPC is not cosmetic. A group can only attach to instances in its own VPC, so building the group in the default VPC and the workload in a custom one produces an error at attach time rather than at create time.&lt;/p&gt;

&lt;h3&gt;
  
  
  One thing I want to flag about my own file
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;    &lt;span class="n"&gt;cidr_blocks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"0.0.0.0/0"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;     &lt;span class="c1"&gt;# Replace with your IP or CIDR range&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The comment says to replace the range. I did not replace the range. SSH is open to the entire internet.&lt;/p&gt;

&lt;p&gt;The task specified both rules that way, and nothing real is exposed in a mock environment, so this is not a mistake so much as a habit worth not forming. A comment telling a future reader to change something is a much weaker control than simply not writing the permissive value. A variable with no default fails the plan until somebody supplies an answer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="n"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"ssh_cidr"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"CIDR allowed to reach SSH"&lt;/span&gt;
  &lt;span class="k"&gt;type&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Task 2: A private AKS cluster
&lt;/h2&gt;

&lt;p&gt;Kubernetes 1.36.x in Central US, Standard tier, private API server, one node pool called &lt;code&gt;agentpool&lt;/code&gt; autoscaling 1 to 2, all monitoring off, ready for workloads.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Choosing the version deliberately
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  1.37 ['1.37.0']
  1.36 ['1.36.0', '1.36.1', '1.36.2', '1.36.3', '1.36.4']   default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;1.37.0 exists, so any logic reaching for "latest" produces a version that fails the requirement. The minors also come back unordered, with 1.37 listed above 1.36, so taking the first entry would be wrong too.&lt;/p&gt;

&lt;p&gt;The patch list is lexically unsafe as well. On 1.34 it returns &lt;code&gt;['1.34.0', '1.34.1', '1.34.10', '1.34.11', '1.34.2', ...]&lt;/code&gt;, because &lt;code&gt;'10'&lt;/code&gt; sorts before &lt;code&gt;'2'&lt;/code&gt; as a string. For 1.36 the highest patch is 4 so &lt;code&gt;sorted()[-1]&lt;/code&gt; happens to work, and on 1.34 the same code picks &lt;code&gt;1.34.9&lt;/code&gt; over &lt;code&gt;1.34.11&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cands&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: The empty list
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=== node pools ===
[]
=== pool count ===
0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NAME                                STATUS   ROLES    AGE   VERSION
aks-agentpool-30092218-vmss000000   Ready    &amp;lt;none&amp;gt;   21m   v1.36.4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;az aks nodepool list&lt;/code&gt; returned an empty array with exit 0, next to a running node whose name contains the pool it belongs to. AKS names nodes &lt;code&gt;aks-&amp;lt;poolname&amp;gt;-&amp;lt;hash&amp;gt;-vmss&amp;lt;ordinal&amp;gt;&lt;/code&gt;, so that node name is proof a pool called &lt;code&gt;agentpool&lt;/code&gt; exists and is healthy.&lt;/p&gt;

&lt;p&gt;I did not find out why. The unfiltered list and &lt;code&gt;az aks nodepool show -n agentpool&lt;/code&gt; were queued when the lab expired, so the candidates stay candidates: an API version mismatch on the sub-resource, a read denial swallowed into an empty list, or a CLI defect.&lt;/p&gt;

&lt;p&gt;What is certain is that the cluster is fine and the command is wrong. &lt;code&gt;az aks show --query agentPoolProfiles&lt;/code&gt; reads the pool off the cluster object, which is the GET that demonstrably works and what the portal displays.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Why I noticed at all
&lt;/h3&gt;

&lt;p&gt;I had two independent views of the same fact. One ARM query and one &lt;code&gt;kubectl&lt;/code&gt; listing disagreed, and the disagreement is the entire signal. Reading only the ARM side would have produced the confident and wrong conclusion that the cluster had no node pool, followed by creating a second one.&lt;/p&gt;

&lt;p&gt;Which is why I wanted these two tasks in the same post. &lt;code&gt;IpPermissionsEgress: []&lt;/code&gt; and &lt;code&gt;nodepool list&lt;/code&gt; returning &lt;code&gt;[]&lt;/code&gt; are the same shape in a terminal, and they could not be more different. The first is true and is the reason an instance in that group would have no outbound connectivity. The second is false and the pool was serving at the time.&lt;/p&gt;

&lt;p&gt;Nothing about the empty array tells you which kind you have. The only thing that separated them was a second source: the provider documentation on one side, and a disagreeing command on the other.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Three notes, one of which corrects something I wrote earlier.&lt;/p&gt;

&lt;p&gt;The cluster came back with both a private and a public FQDN populated, which looks like the private setting failed. It did not, and this is documented: "When you create a private AKS cluster, AKS creates both private and public fully qualified domain names (FQDNs) with corresponding DNS zones by default", and the public one "is only a publicly resolvable DNS name, while API communication for private clusters still occurs through the private endpoint."&lt;/p&gt;

&lt;p&gt;My earlier note went a step further and said the public record resolves to the private IP. That is not on the page. What is documented is that it is publicly resolvable and that it "doesn't create a public API endpoint or remove the requirement for network connectivity to the private endpoint". What the record actually points at is left unstated, so I am marking that claim unverified rather than repeating it. The conclusion it supported survives on the documented wording anyway: no public endpoint, only public resolution.&lt;/p&gt;

&lt;p&gt;Second, &lt;code&gt;az aks command invoke&lt;/code&gt; is documented as the answer to exactly the problem a private cluster creates: "If you don't have direct network connectivity, use the &lt;code&gt;az aks command invoke&lt;/code&gt; command to run commands through the Azure API." AKS schedules a short-lived pod inside the cluster, runs the command, and returns output over ARM. EKS has no equivalent, which is why the comparable EKS task could only report &lt;code&gt;ACTIVE&lt;/code&gt; while this one could demonstrate a &lt;code&gt;Ready&lt;/code&gt; node.&lt;/p&gt;

&lt;p&gt;Its output format is worth recognising: the leading integer is the command's exit code, and the ARM operation reports &lt;code&gt;Succeeded&lt;/code&gt; even when the command inside the cluster failed. Two success signals in one line, and only the first is about kubectl.&lt;/p&gt;

&lt;p&gt;Third, &lt;code&gt;sku.name&lt;/code&gt; and &lt;code&gt;sku.tier&lt;/code&gt; are different fields. The cluster reports &lt;code&gt;skuName: Base&lt;/code&gt; and &lt;code&gt;skuTier: Standard&lt;/code&gt;, which reads like a contradiction and is not: the name is the product, &lt;code&gt;Base&lt;/code&gt; or &lt;code&gt;Automatic&lt;/code&gt;, and the tier is the control plane SLA. Checking "Standard" against the wrong one reports a failure that is not one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;Terraform removes the AWS default allow-all egress rule from every security group it creates. No &lt;code&gt;egress&lt;/code&gt; block means no egress at all, and the instance still answers inbound SSH while being unable to reach anything.&lt;/p&gt;

&lt;p&gt;The provider recommends against inline &lt;code&gt;ingress&lt;/code&gt; and &lt;code&gt;egress&lt;/code&gt; blocks, and against mixing them with the separate rule resources.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vpc_id&lt;/code&gt; defaults to the region's default VPC, and a group only attaches to instances in its own VPC.&lt;/p&gt;

&lt;p&gt;An empty list with exit 0 is not evidence of absence. Only a second, independent view tells a true empty from a false one.&lt;/p&gt;

&lt;p&gt;AKS node names encode their pool, so a node name proves a pool name.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;null&lt;/code&gt; is the pass condition for "monitoring disabled", and monitoring hides in three places, one of which is a different resource provider that never shows up on the cluster object at all.&lt;/p&gt;

&lt;p&gt;Check for newer minors before taking "latest", and sort version patches numerically.&lt;/p&gt;

&lt;p&gt;So here is the Day 95 question. The last time something returned you an empty list, what was your second source? I had one by accident on the Azure side, and by reading the documentation on the Terraform side, and without either, I would have believed both of them.&lt;/p&gt;

&lt;p&gt;Day 95 down. Five to go.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>terraform</category>
      <category>azure</category>
      <category>aws</category>
    </item>
    <item>
      <title>Day 94: A State File Is Not the Cloud and an Empty String That Deleted Something</title>
      <dc:creator>Nnamdi Felix Ibe</dc:creator>
      <pubDate>Sat, 28 Nov 2026 09:00:00 +0000</pubDate>
      <link>https://dev.to/ndcodes/day-94-a-state-file-is-not-the-cloud-and-an-empty-string-that-deleted-something-hia</link>
      <guid>https://dev.to/ndcodes/day-94-a-state-file-is-not-the-cloud-and-an-empty-string-that-deleted-something-hia</guid>
      <description>&lt;p&gt;Day 94 of DevOps, Day 44 of Azure. First Terraform task in the series, which closes the Ansible block at Days 82 to 93.&lt;/p&gt;

&lt;p&gt;Both halves ask the same question in different words: a command succeeded, so what did it actually prove? Terraform's own state listing proves something narrower than it looks. An Azure patch step reported success while quietly deleting the placeholder it was supposed to fill in.&lt;/p&gt;

&lt;p&gt;One Terraform task, one Azure task. A VPC, then a script on a VM that would not run. The tasks come from the KodeKloud Engineer platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 1: A VPC in Terraform
&lt;/h2&gt;

&lt;p&gt;A VPC named &lt;code&gt;devops-vpc&lt;/code&gt;, CIDR &lt;code&gt;10.0.0.0/16&lt;/code&gt;, in &lt;code&gt;us-east-1&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Reading what was already there
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;provider.tf&lt;/code&gt; and a README. The provider block and region were written for me, with a version constraint, so &lt;code&gt;terraform init&lt;/code&gt; installed &lt;code&gt;hashicorp/aws v5.91.0&lt;/code&gt; rather than whatever is newest. That makes the whole build pinned and repeatable, and &lt;code&gt;init&lt;/code&gt; writes &lt;code&gt;.terraform.lock.hcl&lt;/code&gt; recording the choice. That file belongs in version control.&lt;/p&gt;

&lt;p&gt;So &lt;code&gt;main.tf&lt;/code&gt; was the only new file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"aws_vpc"&lt;/span&gt; &lt;span class="s2"&gt;"devops-vpc"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;cidr_block&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"10.0.0.0/16"&lt;/span&gt;
  &lt;span class="n"&gt;tags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"devops-vpc"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Plan, then apply
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight terraform"&gt;&lt;code&gt;&lt;span class="nc"&gt;Plan&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;change&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;destroy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;aws_vpc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;devops&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;vpc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Creation&lt;/span&gt; &lt;span class="n"&gt;complete&lt;/span&gt; &lt;span class="n"&gt;after&lt;/span&gt; &lt;span class="mi"&gt;1s&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;vpc&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;be9b655843a531502&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Two checks that are not the same check
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform state list
&lt;span class="c"&gt;# aws_vpc.devops-vpc&lt;/span&gt;

aws ec2 describe-vpcs --filters &lt;span class="s2"&gt;"Name=tag:Name,Values=devops-vpc"&lt;/span&gt; --region us-east-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the bit I want to pull out, because it is easy to run both and think of them as one verification.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;terraform state list&lt;/code&gt; proves that Terraform's state file contains a resource called &lt;code&gt;aws_vpc.devops-vpc&lt;/code&gt;. It makes no network call. It asserts nothing whatsoever about AWS. Delete the VPC from the console a minute later and that command prints exactly the same line.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;describe-vpcs&lt;/code&gt; call is the one that asks AWS, and it is what establishes the VPC exists with the right CIDR, the right tag and the right region.&lt;/p&gt;

&lt;p&gt;Running both is correct and worth keeping as a habit. The Terraform-native version of the same idea is &lt;code&gt;terraform plan&lt;/code&gt; against existing state, which refreshes from the provider before comparing, so "No changes" is a much stronger statement than a state listing. A difference between the two is called drift, and the plan is the thing that finds it.&lt;/p&gt;

&lt;p&gt;Incidentally, the tag is not decoration. AWS has no name field on a VPC. The console's Name column is that tag, and the filter I verified with is a tag lookup. Without it, the only handle is a generated VPC ID, so the verification command could not have been written before the apply.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Terraform printed its own warning, and I walked past it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Note: You didn't use the -out option to save this plan, so Terraform
can't guarantee to take exactly these actions if you run "terraform
apply" now.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is not boilerplate. A bare &lt;code&gt;plan&lt;/code&gt; followed by a bare &lt;code&gt;apply&lt;/code&gt; runs the planning step twice, against whatever the world looks like at each moment. The plan I reviewed is not the plan that executes.&lt;/p&gt;

&lt;p&gt;On one resource in a lab, the difference is nothing. The habit is still the wrong one, because the shape that matters in a pipeline is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform plan -out=tfplan
terraform apply tfplan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;apply&lt;/code&gt; with a saved plan executes exactly what was reviewed and does not prompt, because the approval happened at review time.&lt;/p&gt;

&lt;p&gt;Two sub-second gates were missing too, and they are the same pattern I used on an ARM template a day earlier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform fmt -check
terraform validate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;validate&lt;/code&gt; checks syntax and internal consistency without contacting a provider.&lt;/p&gt;

&lt;p&gt;And two defaults got accepted rather than chosen. The provider docs give them: &lt;code&gt;enable_dns_support&lt;/code&gt; "Defaults to &lt;code&gt;true&lt;/code&gt;", &lt;code&gt;enable_dns_hostnames&lt;/code&gt; "Defaults to &lt;code&gt;false&lt;/code&gt;". The second has a consequence that surfaces much later. Instances in this VPC get a private DNS name and no public DNS hostname, which is different from the account's default VPC, where hostnames are on. It shows up as a missing &lt;code&gt;PublicDnsName&lt;/code&gt; weeks after the VPC was built, and the fix is one line at creation time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;  &lt;span class="n"&gt;enable_dns_hostnames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  One honest note about the environment
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"OwnerId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"000000000000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;"DhcpOptionsId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An all-zero account ID, and a DHCP options ID that is the literal word &lt;code&gt;default&lt;/code&gt; where real AWS returns &lt;code&gt;dopt-&lt;/code&gt; and an identifier. I am reading that as a mock AWS endpoint rather than the real thing, from those two fields.&lt;/p&gt;

&lt;p&gt;Which changes what can be learned here. The Terraform configuration and the provider's behaviour are real. The API responses are approximations, so a field that looks odd in this output is not necessarily odd in AWS. Worth holding on to, because the Terraform block runs to Day 100.&lt;/p&gt;




&lt;h2&gt;
  
  
  Task 2: Getting a script on a VM to send to Event Hubs
&lt;/h2&gt;

&lt;p&gt;A namespace with auto-inflate, an event hub, and a provided script run enough times that events show up in metrics.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Reading the script first
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;connection_str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;your_event_hub_connection_string&amp;gt;"&lt;/span&gt;
&lt;span class="n"&gt;event_hub_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"nautilus-hub"&lt;/span&gt;
&lt;span class="n"&gt;producer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;EventHubProducerClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_connection_string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three decisions came out of one &lt;code&gt;cat&lt;/code&gt;. It wants a connection string, not a managed identity, and &lt;code&gt;az vm show&lt;/code&gt; confirmed &lt;code&gt;identity: null&lt;/code&gt;, so SAS was the only route. The hub name is hardcoded. And &lt;code&gt;from_connection_string&lt;/code&gt; with a separate &lt;code&gt;eventhub_name&lt;/code&gt; means the string must not carry an &lt;code&gt;EntityPath&lt;/code&gt;, so a namespace-level rule is right and a hub-level one would conflict.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: A required argument reported missing on a line that contains it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;az eventhubs namespace authorization-rule keys list -g &lt;span class="s2"&gt;"$RG"&lt;/span&gt; \
  --namespace-name nautilus-namespace -n RootManageSharedAccessKey
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ERROR: the following arguments are required: --name/--authorization-rule-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this command group &lt;code&gt;-n&lt;/code&gt; is short for &lt;code&gt;--namespace-name&lt;/code&gt;, not &lt;code&gt;--name&lt;/code&gt;. So I set the namespace twice, the second time to the rule's name, and left the rule unset. The error is accurate and reads as nonsense.&lt;/p&gt;

&lt;p&gt;The short alias binds to the command group's noun, not the leaf command's. Use long flags once an &lt;code&gt;az&lt;/code&gt; command gets more than two levels deep, because the deeper it goes the more likely &lt;code&gt;-n&lt;/code&gt; means an ancestor.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: The failure I actually want to write down
&lt;/h3&gt;

&lt;p&gt;That failed fetch cascaded through four steps, each reporting success:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;CONN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;                              &lt;span class="c1"&gt;# the failed command assigned nothing&lt;/span&gt;
&lt;span class="no"&gt;CONN_B64&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;                          &lt;span class="c1"&gt;# base64 of empty is empty, and valid&lt;/span&gt;
&lt;span class="n"&gt;base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;b64decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;         &lt;span class="c1"&gt;# valid base64, no error&lt;/span&gt;
&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;placeholder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;           &lt;span class="c1"&gt;# SUCCEEDS, and deletes the placeholder&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="n"&gt;placeholder_removed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;True&lt;/span&gt;
&lt;span class="n"&gt;endpoint_present&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;str.replace&lt;/code&gt; with an empty replacement is a legitimate operation. Nothing threw. The patch truthfully reported the placeholder removed, and left the file holding &lt;code&gt;connection_str = ""&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Two things make this worse than an ordinary unset-variable bug. It produced a successful destructive write rather than an error. And the write removed the marker the patch depended on, so a naive retry would find nothing to replace and report success a second time.&lt;/p&gt;

&lt;p&gt;Empty-string propagation through base64 is particularly quiet, because base64 has no concept of too short. Every stage of that pipeline is total.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: The check was in the output and I ran the next command anyway
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;endpoint_present: False&lt;/code&gt; was printed immediately above three failed runs. The check worked. It just was not load-bearing, because both blocks went out in the same message and the second did not depend on the first.&lt;/p&gt;

&lt;p&gt;Printing a diagnostic and gating on it are different things, and only one of them stops a bad run.&lt;/p&gt;

&lt;p&gt;The replacement gate checks content rather than presence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"$CONN"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
  &lt;span class="nv"&gt;Endpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;sb://nautilus-namespace*&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"GATE PASS"&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  *&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"GATE FAIL: do not continue"&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;esac&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;[ -z "$CONN" ]&lt;/code&gt; only catches empty. A truncated or wrong-namespace value passes an emptiness test and fails at the far end, where the error names a parser rather than a credential.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Three notes from the Event Hubs documentation, and one of them corrects something I wrote earlier.&lt;/p&gt;

&lt;p&gt;I had recorded auto-inflate as available on "Standard and above". It is narrower: "The Auto inflate feature is currently supported only in the standard tier." Premium and Dedicated size capacity in processing units and capacity units rather than throughput units, so the feature does not extend upward at all.&lt;/p&gt;

&lt;p&gt;The scale direction I had right, and the exact wording is worth keeping: "Auto inflate doesn't automatically scale down the number of TUs when ingress or egress rates drop below the limits." It is protection against throttling, not cost control.&lt;/p&gt;

&lt;p&gt;On partitions I had "immutable on Basic and Standard", which is right, and the docs add the other half: "For an event hub in a premium or dedicated tier, you can increase the partition count after its creation, but you can't decrease them." So it never goes down anywhere. The same page warns that increasing it changes how partition keys map to partitions, so ordering within a key is not preserved across the change. And a detail that makes the four-partition default easy to live with: "It doesn't matter how many partitions are in an event hub when it comes to pricing." The default costs nothing. It only caps how wide the consumer side can ever go.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Verifying with arithmetic rather than a glance
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"metric"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"IncomingMessages"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;30.0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;30 is not "greater than zero". It is exactly 3 runs times 10 events. A non-zero count would be satisfied by one successful run and two failures, by retries counted twice, or by leftovers from an earlier attempt. An exact match rules all of that out in one reading.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SuccessfulRequests&lt;/code&gt; came back at 37, which is a different unit rather than seven stray messages: it counts AMQP service operations, including connection and link setup once per producer block.&lt;/p&gt;

&lt;p&gt;And because Event Hubs emits metrics at the namespace level, a plain total is the sum across every hub in the namespace. Splitting on &lt;code&gt;EntityName&lt;/code&gt; is what keeps the destination in evidence instead of assumed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"entity"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"nautilus-hub"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;30.0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;terraform state list&lt;/code&gt; reads the state file and contacts nothing. It proves what Terraform believes, not what the cloud holds, and the second check has to come from the provider's own API.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;terraform plan&lt;/code&gt; without &lt;code&gt;-out&lt;/code&gt; re-plans at apply time, as its own output warns. In a pipeline, save the plan and apply the file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;enable_dns_hostnames&lt;/code&gt; defaults to false on a VPC you create, which is not how the default VPC behaves.&lt;/p&gt;

&lt;p&gt;A VPC has no name field, so the tag is the handle every verification uses.&lt;/p&gt;

&lt;p&gt;In a nested &lt;code&gt;az&lt;/code&gt; command group, &lt;code&gt;-n&lt;/code&gt; binds to the group's noun.&lt;/p&gt;

&lt;p&gt;An empty variable can produce a destructive operation that reports success, and base64 will carry an empty string through the whole pipeline without complaining once.&lt;/p&gt;

&lt;p&gt;Printing a check is not gating on it. Gate on content, not on emptiness.&lt;/p&gt;

&lt;p&gt;Compute the number you expect before you read the metric.&lt;/p&gt;

&lt;p&gt;So here is the Day 94 question. Which of your verification commands actually leave the machine they run on? I had two checks on that VPC and only one of them was asking anybody anything.&lt;/p&gt;

&lt;p&gt;Day 94 down. Six to go.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>terraform</category>
      <category>azure</category>
      <category>aws</category>
    </item>
    <item>
      <title>Day 93: A Condition That Can Skip Everything and a Flag That Rewrites What It Names</title>
      <dc:creator>Nnamdi Felix Ibe</dc:creator>
      <pubDate>Fri, 27 Nov 2026 18:00:00 +0000</pubDate>
      <link>https://dev.to/ndcodes/day-93-a-condition-that-can-skip-everything-and-a-flag-that-rewrites-what-it-names-h1e</link>
      <guid>https://dev.to/ndcodes/day-93-a-condition-that-can-skip-everything-and-a-flag-that-rewrites-what-it-names-h1e</guid>
      <description>&lt;p&gt;Day 93 of DevOps, Day 43 of Azure. Both tasks produced a wrong answer that looked like a right one. The Ansible playbook has a failure mode where every task skips and the recap says success. The Azure task gave me an empty array in the middle of a diagnosis, and it read as a finding.&lt;/p&gt;

&lt;p&gt;One Ansible task, one Azure task. Conditionals that route files to hosts, then an Application Gateway the CLI could not build. The tasks come from the KodeKloud Engineer platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 1: Copying a different file to each server with conditionals
&lt;/h2&gt;

&lt;p&gt;Three app servers, three files, each going to exactly one server. Owned by the connecting user, mode &lt;code&gt;0655&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The playbook
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hosts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;all&lt;/span&gt;
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;yes&lt;/span&gt;
  &lt;span class="na"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Copy blog.txt file from jump host to App Server 1&lt;/span&gt;
      &lt;span class="na"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/usr/src/dba/blog.txt&lt;/span&gt;
        &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/dba/blog.txt&lt;/span&gt;
        &lt;span class="na"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{ ansible_user }}"&lt;/span&gt;
        &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{ ansible_user }}"&lt;/span&gt;
        &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0655'&lt;/span&gt;
      &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ansible_nodename == "stapp01"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three of those, differing in the filename and the host in the condition.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Checking all three servers first
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;/opt/dba&lt;/code&gt; existed on each one and was empty. Which is what makes the next output worth reading.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Running it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TASK [Copy blog.txt file from jump host to App Server 1] ***************
skipping: [stapp02]
skipping: [stapp03]
changed: [stapp01]

PLAY RECAP ***************
stapp01 : ok=2  changed=1  skipped=2
stapp02 : ok=2  changed=1  skipped=2
stapp03 : ok=2  changed=1  skipped=2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;-rw-r-xr-x 1 tony   tony   35 blog.txt
-rw-r-xr-x 1 steve  steve  27 story.txt
-rw-r-xr-x 1 banner banner 22 media.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three different byte counts on three different hosts. Each matches its source exactly, character count with no trailing newline. That is the strongest single piece of evidence the routing worked, because a condition matching the wrong host would have put the wrong size in the wrong place.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: The thing I went looking for afterwards
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ansible_nodename&lt;/code&gt; is not the inventory name.&lt;/p&gt;

&lt;p&gt;It does not appear on Ansible's special variables page at all, because it is not a magic variable. It is a gathered fact, and in Ansible's fact collection code it is set directly from Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;platform_facts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'nodename'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So it is what the target machine calls itself, read off the target after &lt;code&gt;setup&lt;/code&gt; runs. &lt;code&gt;inventory_hostname&lt;/code&gt;, which yesterday's template used, is documented as "The inventory name for the 'current' host being iterated over in the play", and the controller knows it before contacting anything.&lt;/p&gt;

&lt;p&gt;Here they agree, because the inventory line is &lt;code&gt;stapp01 ansible_host=stapp01&lt;/code&gt; and the machine's hostname is also &lt;code&gt;stapp01&lt;/code&gt;. Nothing requires that. The entire point of &lt;code&gt;ansible_host=&lt;/code&gt; is to let an inventory alias differ from the thing it points at, and real inventories are full of names like &lt;code&gt;web1&lt;/code&gt; and &lt;code&gt;db-primary&lt;/code&gt; on machines whose hostname is something else.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: What happens if they disagree
&lt;/h3&gt;

&lt;p&gt;Every condition is false on every host. All three tasks skip everywhere. The recap reads:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stapp01 : ok=1  changed=0  skipped=3  failed=0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No error, no warning, &lt;code&gt;failed=0&lt;/code&gt;. A playbook that copied nothing reports a clean run. The only signal is a &lt;code&gt;changed=0&lt;/code&gt; that somebody has to notice and interpret.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;when&lt;/code&gt; has no concept of "should have matched something". There is nothing in Ansible that fails a play because a condition was never true anywhere.&lt;/p&gt;

&lt;p&gt;So the number to read in this playbook is &lt;code&gt;skipped&lt;/code&gt;. Mine was 2 per host, meaning exactly one task ran on each. Nine would have meant the conditions matched nobody.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;The one-word fix is to use the variable that means what the task means:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;      &lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;inventory_hostname == "stapp01"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That also makes &lt;code&gt;gather_facts: no&lt;/code&gt; possible. As written, the play gathers facts on three servers purely to read back a name the inventory already knew, and fact gathering is the slowest step in a play this small.&lt;/p&gt;

&lt;p&gt;The better shape drops the conditionals, because three near-identical tasks differing in one value are a loop wearing a disguise:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;vars&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;file_for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;stapp01&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;blog.txt&lt;/span&gt;
      &lt;span class="na"&gt;stapp02&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;story.txt&lt;/span&gt;
      &lt;span class="na"&gt;stapp03&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;media.txt&lt;/span&gt;
  &lt;span class="na"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Copy this host's file from the jump host&lt;/span&gt;
      &lt;span class="na"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/usr/src/dba/{{ file_for[inventory_hostname] }}"&lt;/span&gt;
        &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/opt/dba/{{ file_for[inventory_hostname] }}"&lt;/span&gt;
        &lt;span class="na"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{ ansible_user }}"&lt;/span&gt;
        &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{ ansible_user }}"&lt;/span&gt;
        &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0655'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One task instead of three. A host missing from the dictionary fails loudly with an undefined-key error instead of skipping quietly, which inverts the failure mode, and that is the whole argument. The original runs nine task-host evaluations to perform three copies.&lt;/p&gt;

&lt;p&gt;The task asked for conditionals, so the playbook uses them. Knowing what they cost is a separate thing from knowing how to write them.&lt;/p&gt;

&lt;p&gt;One small note on the result: &lt;code&gt;/opt/dba&lt;/code&gt; is still owned by root on all three servers. The tasks set ownership on the files and never touch the directory, so &lt;code&gt;tony&lt;/code&gt; owns &lt;code&gt;blog.txt&lt;/code&gt; and cannot create a second file next to it. &lt;code&gt;copy&lt;/code&gt; sets the mode of what it writes, not of the path it writes into.&lt;/p&gt;




&lt;h2&gt;
  
  
  Task 2: An Application Gateway in front of a VM
&lt;/h2&gt;

&lt;p&gt;An NSG with an HTTP rule, a VM running nginx from user data, and a gateway with four named sub-resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The CLI could not send the only allowed value
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RequestDisallowedByPolicy: Only the Basic SKU is allowed for Azure Application Gateway.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;--sku : Allowed values: Standard_Medium, Standard_Small, Standard_v2,
        WAF_Large, WAF_Medium, WAF_v2.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Six values the CLI can emit, one the subscription accepts, no overlap. Not permissions, not quota, not fixable with a flag.&lt;/p&gt;

&lt;p&gt;A CLI enum can be narrower than the API behind it. That list is hard-coded in the command definition, and &lt;code&gt;Basic&lt;/code&gt; became generally available after it was written. The REST API takes the value; the CLI will not send it. Checking &lt;code&gt;--help&lt;/code&gt; cost two seconds, and it is worth doing whenever something is rejected without a round trip to Azure, because a client-side enum error and a server-side rejection look identical in a terminal and have nothing in common.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: The constraint turned out to be a better route
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;az network application-gateway create&lt;/code&gt; cannot name its own sub-resources. It always produces &lt;code&gt;appGatewayBackendPool&lt;/code&gt;, &lt;code&gt;appGatewayHttpListener&lt;/code&gt; and &lt;code&gt;rule1&lt;/code&gt;. This task names four of them. Doing that through the CLI means nine separate writes, each a full PUT of one to three minutes, on top of a fifteen-minute create. Deleting the default rule first does not help, because a gateway with zero routing rules fails validation.&lt;/p&gt;

&lt;p&gt;An ARM template did all of it in one deployment, because it declares the final state instead of mutating toward it. The sub-resources reference each other by composed ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"variables"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"agwId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"[resourceId('Microsoft.Network/applicationGateways','nautilus-agw')]"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;"frontendPort"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"[concat(variables('agwId'),'/frontendPorts/port_80')]"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;resourceId()&lt;/code&gt; builds an ID from names without the resource existing, which is what makes a self-referential template legal.&lt;/p&gt;

&lt;p&gt;Two gates in front of the deploy, both returning in seconds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 -m json.tool /tmp/agw.json &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null
az deployment group validate -g &lt;span class="s2"&gt;"$RG"&lt;/span&gt; --template-file /tmp/agw.json --parameters &lt;span class="nv"&gt;vmPrivateIp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$VMIP"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second earned its place. &lt;code&gt;validate&lt;/code&gt; runs schema checks, reference resolution and policy evaluation server-side, so &lt;code&gt;Basic&lt;/code&gt; was confirmed acceptable before anything was built. Finding a rejected SKU after a fifteen-minute wait on a one-hour lab clock is a different afternoon.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Something deleted my NSG rule
&lt;/h3&gt;

&lt;p&gt;The NSG and its rule went in first, successfully. After &lt;code&gt;az vm create ... --nsg nautilus-nsg&lt;/code&gt;, the NSG held one rule, and not the one I had put there:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"default-allow-ssh"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"dport"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"22"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"pri"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Allow-HTTP&lt;/code&gt; was gone, so port 80 fell through to &lt;code&gt;DenyAllInBound&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The documentation describes &lt;code&gt;--nsg&lt;/code&gt; as "the name to use when creating a new Network Security Group (default) or referencing an existing one", which reads as reuse. What I observed is that the NSG ended up holding only the SSH rule &lt;code&gt;az vm create&lt;/code&gt; adds by default. It is a write, not a reference.&lt;/p&gt;

&lt;p&gt;That puts it in a family I keep running into, as the worst member so far. &lt;code&gt;az resource tag&lt;/code&gt; replaces all tags. &lt;code&gt;management-policy create&lt;/code&gt; replaces all lifecycle rules. &lt;code&gt;set-policy --key-permissions&lt;/code&gt; replaces that category. All three replace something you were explicitly setting. This one replaces a resource you only mentioned in passing, while creating something else.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;The diagnostic I ran during that fault returned an empty array, and I nearly believed it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;--query &lt;span class="s2"&gt;"value[].securityRules[]..."&lt;/span&gt;          &lt;span class="c"&gt;# []&lt;/span&gt;
--query &lt;span class="s2"&gt;"value[].effectiveSecurityRules[]..."&lt;/span&gt; &lt;span class="c"&gt;# the rules&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;az network nic list-effective-nsg&lt;/code&gt; puts them under &lt;code&gt;effectiveSecurityRules&lt;/code&gt;. &lt;code&gt;securityRules&lt;/code&gt; does not exist on that object. Same mistake as yesterday's &lt;code&gt;properties.leaseState&lt;/code&gt;, and worse here because of when it happened. &lt;code&gt;[]&lt;/code&gt; reads as "the NSG has no rules", which was accidentally adjacent to the truth. A plausible wrong answer ends an investigation. An obviously wrong one does not.&lt;/p&gt;

&lt;p&gt;The fix is two lines and no guessing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;az network nic list-effective-nsg --ids &lt;span class="s2"&gt;"$NICID"&lt;/span&gt; -o json \
  &lt;span class="o"&gt;|&lt;/span&gt; python3 -c &lt;span class="s2"&gt;"import sys,json;d=json.load(sys.stdin);print(list(d['value'][0].keys()))"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'association'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'effectiveSecurityRules'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'networkSecurityGroup'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'tagMap'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And a correction to something I wrote in an earlier note. I had recorded that both v2 and Basic gateways need inbound from the &lt;code&gt;GatewayManager&lt;/code&gt; service tag on ports 65200 to 65535. The documentation gives two ranges and does not mention Basic at all: 65200-65535 for v2, 65503-65534 for v1. What it does say is the general rule that the range "differs based on SKU and is required for communicating the status of the backend health". Leaving the gateway subnet without an NSG, which is what I did, sidesteps the question entirely and remains the right call.&lt;/p&gt;

&lt;p&gt;Two more things from that page worth carrying: platform health monitoring uses TCP 65502 and 54321 and UDP 12345, separately from the GatewayManager range, and the gateway subnet is exclusive, so you cannot put anything else in it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ansible_nodename&lt;/code&gt; is a gathered fact set from &lt;code&gt;platform.node()&lt;/code&gt;, the target's own name. &lt;code&gt;inventory_hostname&lt;/code&gt; is the inventory's name for it. Not the same variable, and not required to agree.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;when&lt;/code&gt; that is false everywhere skips every task and reports &lt;code&gt;failed=0&lt;/code&gt;. Read &lt;code&gt;skipped&lt;/code&gt;, not just &lt;code&gt;changed&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Three near-identical tasks differing by one value are a loop. A dictionary keyed by host fails loudly on a missing key instead of skipping quietly.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;copy&lt;/code&gt; sets the mode of the file it writes, not of the directory it writes into.&lt;/p&gt;

&lt;p&gt;A CLI enum can be narrower than the API behind it, and policy can require a value the CLI will not send.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;az vm create --nsg &amp;lt;name&amp;gt;&lt;/code&gt; writes that NSG rather than referencing it, and replaces its rule set.&lt;/p&gt;

&lt;p&gt;Print a response's top-level keys before writing a query against it, especially during a diagnosis.&lt;/p&gt;

&lt;p&gt;So here is the Day 93 question. When your automation does nothing at all, what does it print? Mine prints a clean recap with &lt;code&gt;failed=0&lt;/code&gt;, and I would have to be paying attention to the one number that changed to notice.&lt;/p&gt;

&lt;p&gt;Day 93 down. Seven to go.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>ansible</category>
      <category>azure</category>
      <category>automation</category>
    </item>
    <item>
      <title>Day 92: A Name the Inventory Chose and a Check Before the Delete</title>
      <dc:creator>Nnamdi Felix Ibe</dc:creator>
      <pubDate>Wed, 25 Nov 2026 18:00:00 +0000</pubDate>
      <link>https://dev.to/ndcodes/day-92-a-name-the-inventory-chose-and-a-check-before-the-delete-4081</link>
      <guid>https://dev.to/ndcodes/day-92-a-name-the-inventory-chose-and-a-check-before-the-delete-4081</guid>
      <description>&lt;p&gt;Day 92 of DevOps, Day 42 of Azure. Both tasks are about sequence. The Ansible one renders a file from a variable that is resolved before the target machine is contacted at all. The Azure one is a copy and a delete, where writing them in the natural order destroys the thing you were copying.&lt;/p&gt;

&lt;p&gt;One Ansible task, one Azure task. A template in a role, then a container that had to be backed up before it could be removed. The tasks come from the KodeKloud Engineer platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 1: Deploying a file from a Jinja2 template
&lt;/h2&gt;

&lt;p&gt;Install and start httpd on one app server through a role, then write &lt;code&gt;/var/www/html/index.html&lt;/code&gt; from a template carrying the host's name. Mode &lt;code&gt;0744&lt;/code&gt;, owned by the connecting user.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Reading what was already there
&lt;/h3&gt;

&lt;p&gt;The role existed with two tasks in it, install and start. The playbook had an empty &lt;code&gt;hosts:&lt;/code&gt; line. So the work was three edits rather than a new playbook, and the first thing worth doing was finding out which three.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: The template
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jinja"&gt;&lt;code&gt;This file was created using Ansible on &lt;span class="cp"&gt;{{&lt;/span&gt; &lt;span class="n"&gt;inventory_hostname&lt;/span&gt; &lt;span class="cp"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy index.html template&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;index.html.j2&lt;/span&gt;
    &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/var/www/html/index.html&lt;/span&gt;
    &lt;span class="na"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{ ansible_user }}"&lt;/span&gt;
    &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{ ansible_user }}"&lt;/span&gt;
    &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0744'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;src&lt;/code&gt; has no directory on it. The file lives at &lt;code&gt;role/httpd/templates/index.html.j2&lt;/code&gt;, and the bare filename finds it because of the role layout, not because of anything in the module. Ansible's roles documentation says that copy, script, template and include tasks in a role "can reference files in roles/x/{files,templates,tasks}/" "without having to path them relatively or absolutely".&lt;/p&gt;

&lt;p&gt;That is worth knowing as the mechanism rather than as a convenience. Move the template out of &lt;code&gt;templates/&lt;/code&gt; and the same task fails with a path error.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Checking before running it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;steve@stapp02 ~&lt;span class="o"&gt;]&lt;/span&gt;$ sudo systemctl status httpd
Unit httpd.service could not be found.
&lt;span class="o"&gt;[&lt;/span&gt;steve@stapp02 ~&lt;span class="o"&gt;]&lt;/span&gt;$ ls /var/www/html
ls: cannot access &lt;span class="s1"&gt;'/var/www/html'&lt;/span&gt;: No such file or directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not ceremony. This is what makes the three &lt;code&gt;changed&lt;/code&gt; results afterwards attributable to this run instead of to how the lab happened to start. I skipped this on Day 88 and it cost me the ability to say anything firm about that playbook's output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Running it and checking again
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PLAY RECAP ***************
stapp02 : ok=4  changed=3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;steve@stapp02 ~&lt;span class="o"&gt;]&lt;/span&gt;$ cat /var/www/html/index.html
This file was created using Ansible on stapp02

&lt;span class="o"&gt;[&lt;/span&gt;steve@stapp02 ~&lt;span class="o"&gt;]&lt;/span&gt;$ ls -la /var/www/html/index.html
-rwxr--r-- 1 steve steve 47 May 25 10:48 /var/www/html/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;47 bytes is the rendered line: 46 characters plus a newline. Worth computing, because a template that rendered the wrong variable would still produce a file that looked fine at a glance.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Three things from the documentation that this task either got right or got away with.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mode: '0744'&lt;/code&gt; is quoted, and the &lt;code&gt;template&lt;/code&gt; documentation asks for that: "For consistent results, quote octal numbers (for example, &lt;code&gt;'644'&lt;/code&gt; or &lt;code&gt;'1777'&lt;/code&gt;)." Unquoted octal is read as decimal.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;become_user: root&lt;/code&gt; in the playbook is redundant. The privilege escalation page says plainly: "The default value is &lt;code&gt;root&lt;/code&gt;." Harmless, and the related trap is worth carrying: the same page notes &lt;code&gt;become_user&lt;/code&gt; "Does NOT imply &lt;code&gt;become: true&lt;/code&gt;", so a playbook that sets only the user escalates nothing at all.&lt;/p&gt;

&lt;p&gt;And there is an idempotence note this template dodges by luck. The documentation warns that "Including a string that uses a date in the template will result in the template being marked 'changed' each time." &lt;code&gt;{{ inventory_hostname }}&lt;/code&gt; is stable, so this task really is idempotent. Swap in a timestamp and you have Day 85's always-changed problem, in a module that looks like it should not have it.&lt;/p&gt;

&lt;h3&gt;
  
  
  One thing to flag for tomorrow
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;inventory_hostname&lt;/code&gt; is documented as "The inventory name for the 'current' host being iterated over in the play." It comes from the inventory file. The controller knows it before it contacts anything.&lt;/p&gt;

&lt;p&gt;I am noting that because the next task uses &lt;code&gt;ansible_nodename&lt;/code&gt;, which looks like it means the same thing and does not. Here they agree, because the inventory line reads &lt;code&gt;stapp02 ansible_host=stapp02&lt;/code&gt;. Nothing requires them to.&lt;/p&gt;




&lt;h2&gt;
  
  
  Task 2: Backing up and deleting a blob container
&lt;/h2&gt;

&lt;p&gt;Copy a container's contents to &lt;code&gt;/opt&lt;/code&gt; on the client host, then delete the container and confirm it is gone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The order, which is the entire task
&lt;/h3&gt;

&lt;p&gt;The natural way to write this is the wrong way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;az storage blob download-batch ... --destination /opt
az storage container delete ...
&lt;span class="c"&gt;# now check /opt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three commands that all succeed, with the check in the one position where it cannot do anything. A truncated download would be discovered after the source was destroyed.&lt;/p&gt;

&lt;p&gt;So I checked the retention policies first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"blobDelete"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"allowPermanentDelete"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"days"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"enabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;"containerDelete"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both off. No soft delete, no recovery window, nothing to undo with. That turned "this is probably fine" into a known quantity, and it is only useful before the delete.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Verifying the copy against a digest I did not compute
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OK  devops.txt bytes=33 md5=Lu7zilatbGguzSz2Ecn5IQ==
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;download-batch&lt;/code&gt; exiting zero says the client believed it finished. The check recomputes MD5 from the bytes on disk and compares it to &lt;code&gt;contentMd5&lt;/code&gt;, which Azure recorded when somebody uploaded the blob, before this task existed.&lt;/p&gt;

&lt;p&gt;That independence is the point. On Day 38 I compared an upload response's digest against the file I had just sent, which only confirmed the service had faithfully recorded my own claim.&lt;/p&gt;

&lt;p&gt;I also baselined &lt;code&gt;/opt&lt;/code&gt; first, which already held &lt;code&gt;creds.json&lt;/code&gt;, &lt;code&gt;showcreds&lt;/code&gt; and a &lt;code&gt;.init/&lt;/code&gt; directory. Without that, "I see files in /opt, the copy worked" is a guess. It also would have been the only warning if the container had held a &lt;code&gt;creds.json&lt;/code&gt; of its own, since &lt;code&gt;download-batch&lt;/code&gt; overwrites without asking.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Confirming the deletion four ways
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;th&gt;What it proves&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;container delete&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;{"deleted": true}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The request was accepted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;container exists&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;exists: false&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The service says it is gone&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;container list&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Nothing else went with it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;container list --include-deleted&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No soft-deleted copy exists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;blob list -c &amp;lt;container&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ContainerNotFound&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A read actively refuses&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;--include-deleted&lt;/code&gt; is the one that separates deleted from deleted permanently. With container soft delete on, the first four would look exactly the same and the container would still be recoverable.&lt;/p&gt;

&lt;p&gt;And the error class carries as much as the failure. &lt;code&gt;ContainerNotFound&lt;/code&gt; means gone. &lt;code&gt;BlobNotFound&lt;/code&gt; would have meant the container still exists and is empty, which is a different end state entirely.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Two notes on reading responses, and one of them caught me out.&lt;/p&gt;

&lt;p&gt;The container inspection included a lease check, because a container with an active lease cannot be deleted and the error, &lt;code&gt;LeaseIdMissing&lt;/code&gt;, reads like a credential problem. It returned:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"lease"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"devops-blob-324286988"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"publicAccess"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I read &lt;code&gt;lease: null&lt;/code&gt; as no lease held. It means nothing of the sort. The real path is &lt;code&gt;properties.lease.state&lt;/code&gt;. &lt;code&gt;properties.leaseState&lt;/code&gt;, which is what I wrote, does not exist, so JMESPath returned null for a field I invented. &lt;code&gt;publicAccess: null&lt;/code&gt; on the same line is a real null meaning private. One legitimate null and one phantom null, printed together, impossible to tell apart.&lt;/p&gt;

&lt;p&gt;The delete worked, so there was no lease. But I learned that from the delete, not from the check I wrote specifically to learn it.&lt;/p&gt;

&lt;p&gt;The second note is smaller and worth stealing. Asking for a possibly-absent field directly prints an empty line under &lt;code&gt;-o json&lt;/code&gt;, which is indistinguishable from a command that produced no output. Wrapping it in an object forces the absence to print as a value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;--query &lt;span class="s2"&gt;"{containerDelete:containerDeleteRetentionPolicy,blobDelete:deleteRetentionPolicy}"&lt;/span&gt; -o json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which is how I found that both soft-delete features were off while being spelled differently: one as an object saying &lt;code&gt;enabled: false&lt;/code&gt;, the other as plain &lt;code&gt;null&lt;/code&gt;. Same state, two encodings, and only one of them reachable by the obvious query.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;In an Ansible role, a bare &lt;code&gt;src: file.j2&lt;/code&gt; resolves against that role's &lt;code&gt;templates/&lt;/code&gt; directory, and the &lt;code&gt;template&lt;/code&gt; module reads and renders on the controller rather than the target.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;become_user&lt;/code&gt; defaults to root, so writing it alongside &lt;code&gt;become: yes&lt;/code&gt; is noise. Writing it without &lt;code&gt;become&lt;/code&gt; escalates nothing.&lt;/p&gt;

&lt;p&gt;A template containing a date is marked changed on every run. One containing only stable variables is idempotent.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;inventory_hostname&lt;/code&gt; is the inventory's name for a host, resolved without gathering any facts.&lt;/p&gt;

&lt;p&gt;Check the retention policies before deleting anything, because they tell you whether a mistake is recoverable and they only tell you in time if you ask first.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--include-deleted&lt;/code&gt; is what distinguishes deleted from soft-deleted.&lt;/p&gt;

&lt;p&gt;A null from your own &lt;code&gt;--query&lt;/code&gt; may mean the field does not exist rather than that the value is absent.&lt;/p&gt;

&lt;p&gt;Baseline the destination before a bulk copy. It identifies what you copied and shows you what you would have overwritten.&lt;/p&gt;

&lt;p&gt;So here is the Day 92 question. For every check in your script, is there a version of the failure it is meant to catch that it would report as a pass? My lease check had one. It returned null for a healthy container and it would have returned null for a leased one too.&lt;/p&gt;

&lt;p&gt;Day 92 down. Eight to go.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>ansible</category>
      <category>azure</category>
      <category>automation</category>
    </item>
    <item>
      <title>Part 7: What Reading the Code Could Never Find</title>
      <dc:creator>Nnamdi Felix Ibe</dc:creator>
      <pubDate>Wed, 25 Nov 2026 06:38:30 +0000</pubDate>
      <link>https://dev.to/ndcodes/part-7-what-reading-the-code-could-never-find-8c1</link>
      <guid>https://dev.to/ndcodes/part-7-what-reading-the-code-could-never-find-8c1</guid>
      <description>&lt;p&gt;This is the last part of a series on building an HL7 v2-to-FHIR R4 interoperability service in public. The repository is &lt;a href="https://github.com/ND-codes/nhs-interop-platform" rel="noopener noreferrer"&gt;ND-codes/nhs-interop-platform&lt;/a&gt;, and the code as it stood for this article is tagged &lt;code&gt;part-7&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you are new here, the short version. Many hospital systems send patient events as HL7 version 2, an older plain-text format. National NHS services are moving to FHIR, a newer web format. Something in between has to translate each message, check the patient against national records, and tell someone when it breaks. This repository is a small, working version of that layer. It runs on a laptop with synthetic test data, and you can fork it and follow along.&lt;/p&gt;

&lt;p&gt;I built this with Claude Code, and said so in Parts 4, 5 and 6. This part is the accounting.&lt;/p&gt;

&lt;p&gt;Most writing about AI and code argues from impressions. I have seven weeks of dated evidence instead: every defect in this project, and how each one was actually found. The answer turned out to be more specific than "it helps with boilerplate" and more useful than "always review the output".&lt;/p&gt;

&lt;h2&gt;
  
  
  The accounting
&lt;/h2&gt;

&lt;p&gt;Sorting every defect by discovery route.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl5cwgqu30jqe5kctkuh0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl5cwgqu30jqe5kctkuh0.png" alt="Bar chart of seven weeks of defects by how each was found: reading the code 10, running the system 3, me running it for real 7, readers asking questions 12, the assistant's own tests before shipping 1" width="800" height="576"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Found by reading the code against a specific question
&lt;/h3&gt;

&lt;p&gt;A Terraform &lt;code&gt;default_tags&lt;/code&gt; block that was commented out while the compliance documentation described its benefit in the present tense. Four NHS numbers in &lt;code&gt;pds-client&lt;/code&gt; log lines, plus the same identifier used as an outbound &lt;code&gt;X-Request-ID&lt;/code&gt;. A &lt;code&gt;cygpath&lt;/code&gt; call that scoped &lt;code&gt;make test&lt;/code&gt; to Git Bash on Windows. &lt;code&gt;make integration&lt;/code&gt; installing into a PEP 668 interpreter. A &lt;code&gt;terraform.tfvars.example&lt;/code&gt; the quickstart told you to copy and which did not exist. Eight runbook links that had never resolved. Ten false claims in &lt;br&gt;
&lt;code&gt;docs/security.md&lt;/code&gt; and four more in &lt;code&gt;docs/architecture.md&lt;/code&gt;. The complete absence of any S3 client in a project whose compliance table cited an S3 lifecycle rule as its retention control.&lt;/p&gt;

&lt;p&gt;That is a long list, and it is the strongest mode. Reading forty files and checking whether each cited thing exists is tedious, mechanical, and exactly the work that gets skipped at the end of a week. Most of Parts 5 and 6 came from one question each: which rows of this document are false, and which steps of this quickstart fail on a machine that is not mine.&lt;/p&gt;
&lt;h3&gt;
  
  
  Found by running the system
&lt;/h3&gt;

&lt;p&gt;The circuit breaker gauge that no service exported, found by starting&lt;br&gt;
transform and reading &lt;code&gt;/metrics&lt;/code&gt; instead of reading the code. A timing claim about &lt;code&gt;for: 2m&lt;/code&gt; against a 30-second &lt;code&gt;reset_timeout&lt;/code&gt; that turned out to be wrong when measured. A fuzzing run over 28,000 mutated messages confirming no patient value reached an exception message.&lt;/p&gt;
&lt;h3&gt;
  
  
  Found by me running the real thing
&lt;/h3&gt;

&lt;p&gt;The longest list, and the one that matters.&lt;/p&gt;

&lt;p&gt;The PDS circuit breaker was applied as a decorator to a coroutine function. pybreaker counted the returned coroutine object as a success, the real failure raised later on await, outside the breaker, and the breaker never opened. The fix Part 4 shipped for an alert that could never fire therefore still could not fire. The test passed because it drove the breaker synchronously.&lt;/p&gt;

&lt;p&gt;A dead-letter volume owned by root while the container runs as uid 10001, so every dead-letter write failed with &lt;code&gt;PermissionError&lt;/code&gt;, and the message was lost.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;hl7_dlq_oldest_seconds&lt;/code&gt; set only when pruning ran, so it froze below its own threshold and the alert built to watch it could never fire.&lt;/p&gt;

&lt;p&gt;A raw &lt;code&gt;|&lt;/code&gt; in a FHIR query, which RFC 3986 does not permit in a query and Tomcat rejects with a 400 that &lt;code&gt;curl -sf&lt;/code&gt; then swallowed, so the walkthrough reported a missing Patient that was there.&lt;/p&gt;

&lt;p&gt;Two zlib CVEs that broke every image job until the base stage applied Debian security updates.&lt;/p&gt;

&lt;p&gt;And then alerts actually reached a person. &lt;code&gt;IngestNoTraffic&lt;/code&gt; emailed me six times in two days about a demo stack nobody was using, which is the rule doing its job on a stack left idle. None of the alerts ever told me they were over, because &lt;code&gt;send_resolved&lt;/code&gt; defaults to false for &lt;code&gt;email_configs&lt;/code&gt;, so from an inbox an incident that has ended looks exactly like one still running.&lt;/p&gt;
&lt;h3&gt;
  
  
  Found by readers
&lt;/h3&gt;

&lt;p&gt;Kevin Mayfield on CHI numbers arriving in the NHS Number field, and on the number changing when a patient moves between the Scottish and English NHS, which makes keying patient identity on it unsafe. Mustafa Erbay on PV1-19 for encounter identity. Readers of Part 1 on conditional update against conditional create, the PID-8 concept map, partial birth dates, PID-3 assigning authorities. Nan on the alerts reaching nobody. Amorizz and upordown.online on the absence of &lt;code&gt;absent()&lt;/code&gt; and &lt;code&gt;up&lt;/code&gt; alerts, which became most of this week's code. Kartik on &lt;code&gt;make break-pds&lt;/code&gt; not running in CI. Paul Lovelace on whether &lt;code&gt;make walkthrough&lt;/code&gt; ran in CI. It did not. It does now.&lt;/p&gt;
&lt;h3&gt;
  
  
  Found by the assistant's own tests, before shipping
&lt;/h3&gt;

&lt;p&gt;One. A pybreaker listener reading &lt;code&gt;new_state.state&lt;/code&gt; where the attribute is &lt;code&gt;new_state.name&lt;/code&gt;. &lt;code&gt;getattr&lt;/code&gt; with a default does not raise, so the gauge would have sat at zero while the breaker was open: a fix leaving the alert unfireable while adding a green dashboard panel.&lt;/p&gt;

&lt;p&gt;One, out of all of them.&lt;/p&gt;
&lt;h3&gt;
  
  
  A mistake in the other direction
&lt;/h3&gt;

&lt;p&gt;Part 6 said &lt;code&gt;make restore-pds&lt;/code&gt; left the alert firing and the script should be fixed to send traffic. It already sent traffic, and had since Part 4. The assistant described the script from what the dashboard showed, without reading it, and I published that. Running the full script again this week closed the breaker in under a minute. Part 6 now carries a correction.&lt;/p&gt;

&lt;p&gt;And one that nearly shipped this week. The first draft of this part's code quieted those overnight emails by only alerting if traffic had arrived in the last 24 hours. It read well and passed its tests. Evaluated against my live stack while it sat idle, it fired anyway, because the demo had carried traffic earlier that day. Worse, it would have gone silent once an outage passed a day.&lt;br&gt;
It was dropped, and two tests now hold that line.&lt;/p&gt;

&lt;p&gt;So the lesson is not "running beats reading". Each catches what the other misses, and skipping either one is how a wrong claim gets out.&lt;/p&gt;
&lt;h2&gt;
  
  
  The one that belongs on its own
&lt;/h2&gt;

&lt;p&gt;In Part 5 I had the assistant fix a patient identifier leak. It wrote eight tests asserting the NHS number never reaches stdout, deliberately asserting against the formatter's serialised output rather than the log record, because the defect lived in serialisation and &lt;code&gt;caplog&lt;/code&gt; would have passed.&lt;/p&gt;

&lt;p&gt;Good tests. They covered &lt;code&gt;pds-client&lt;/code&gt;, the service being edited.&lt;/p&gt;

&lt;p&gt;The identical leak existed in &lt;code&gt;transform&lt;/code&gt;, through a completely different mechanism. &lt;code&gt;transform&lt;/code&gt; logs &lt;code&gt;str(exc)&lt;/code&gt; when a PDS lookup fails, and a &lt;code&gt;HTTPStatusError&lt;/code&gt; builds its message from the request URL, and the URL is &lt;code&gt;PDS_CLIENT_URL/&amp;lt;nhs_number&amp;gt;&lt;/code&gt;. Every failed lookup logged the patient identifier.&lt;/p&gt;

&lt;p&gt;I found it by running a real PDS failure rather than the connection error the tests used, whose message contains no URL. The fix is&lt;br&gt;
&lt;code&gt;services/transform/tests/test_pds_privacy.py&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The tests had been shaped around the instance that was found, not the property that was claimed. The claim was "the NHS number never reaches our logs". What was tested was "these four call sites no longer pass it in &lt;code&gt;extra&lt;/code&gt;". Those look the same from inside the diff and are not the same thing at all.&lt;/p&gt;
&lt;h2&gt;
  
  
  The pattern
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fns5onpl5ps5caufpx2ch.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fns5onpl5ps5caufpx2ch.png" alt="Six absence-shaped problems, including an S3 bucket nothing writes to and an Alertmanager config with no Alertmanager. Reading found two, because a document pointed at them; the rest took running it or a person asking" width="800" height="592"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Look again at the deepest problems in this project. An S3 bucket with perfect retention controls that nothing writes to. An alert rule watching a metric no service exports. A runbook link pointing at an anchor that was never created. An Alertmanager configuration with no Alertmanager. A retention window with no measurement. A resolution email that never sends.&lt;/p&gt;

&lt;p&gt;Every one of them is absence-shaped. And from inside the repository, absence looks exactly like everything being fine. There is no red line in a diff for a file that does not exist, no failing test for a notification nobody receives, no warning for a rule whose series was never created. The code reads correctly because the code is correct. What is missing is the part that would have made it matter.&lt;/p&gt;

&lt;p&gt;Reading did find some of them, and the way it found them is the useful part. The empty bucket came to light because the security table cited a lifecycle rule, so there was something to check: what writes to this bucket? The dead runbook links came to light because each alert named an anchor, so there was something to check: does it resolve? Reading finds a missing thing when a document points at where it should be.&lt;/p&gt;

&lt;p&gt;When nothing written down names the missing thing, reading has nothing to check against. No file said "an Alertmanager runs here", so no amount of reading noticed there was not one. That was found by a person asking who gets told. The unexported gauge was found by starting the service and looking.&lt;/p&gt;

&lt;p&gt;An assistant reads. It reads very well and very patiently, and it has no inbox and no on-call rotation. It notices a missing thing when a document points at it. It cannot notice that nothing arrived.&lt;/p&gt;

&lt;p&gt;That is not a limitation you fix with a better prompt. It is a consequence of where the thing sits. It does suggest a cheap habit, though: write down what should exist, so reading has something to check.&lt;/p&gt;
&lt;h2&gt;
  
  
  What that changed in the code
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8voszze9hqsjww6tesuw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8voszze9hqsjww6tesuw.png" alt="Three alert rules, each catching what the one above cannot: ServiceDown for up == 0, ServiceTargetMissing for absent(up), and BreakerMetricAbsent for absent(pybreaker_state)" width="800" height="544"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Three parts of this repository exist because of that pattern, and they are the parts most worth copying.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;make walkthrough&lt;/code&gt; runs the documented tour as eight assertions and stops on the first step that does not hold. Since this week it runs in CI on every pull request, starting all nine services from nothing, so the quickstart and the behaviour cannot drift apart quietly. A failed check now says which HTTP status it got, so the Part 6 bug would have reported itself in two seconds rather than hiding behind a thirty-second wait.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;scripts/break-pds.sh&lt;/code&gt; and &lt;code&gt;scripts/break-fhir.sh&lt;/code&gt; drive real failures on purpose. An alert proved only by a unit test is not proved. Those scripts found the root-owned dead-letter volume in their first week.&lt;/p&gt;

&lt;p&gt;And this week's change, which is the general case. Every alert in this repository watched a rate, a ratio or a gauge. All of them share one blind spot: a service that is down exports none of those, so the rules testing for too much of something go quiet precisely when things are worst. There are now three rules that watch for absence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ServiceTargetMissing&lt;/span&gt;
  &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;absent(up{job="ingest"})&lt;/span&gt;
    &lt;span class="s"&gt;or absent(up{job="transform"})&lt;/span&gt;
    &lt;span class="s"&gt;or absent(up{job="pds-client"})&lt;/span&gt;

&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;BreakerMetricAbsent&lt;/span&gt;
  &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;absent(pybreaker_state{name="pds"})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second is the literal guard against the Part 4 defect recurring.&lt;br&gt;
&lt;code&gt;PDSCircuitOpen&lt;/code&gt; watched &lt;code&gt;pybreaker_state&lt;/code&gt; for two months while nothing exported it, and a rule that cannot fire is indistinguishable from a rule that is never needed. If that gauge disappears again, something says so.&lt;/p&gt;

&lt;p&gt;A useful detail: given a selector, &lt;code&gt;absent()&lt;/code&gt; derives the output labels from that selector, so the alert names the missing job without any templating. That only holds for a selector argument; wrap it in an aggregation and the labels are gone. I confirmed the selector behaviour with promtool rather than assuming it, after a test failed on exactly that point. There are twenty promtool cases behind these now, including one asserting that a fully healthy stack fires nothing at all, which matters because a false alarm on a working system is worse than no alarm.&lt;/p&gt;
&lt;h2&gt;
  
  
  Where it genuinely helped
&lt;/h2&gt;

&lt;p&gt;I want to be as specific about this as about the failures, because "AI is bad at X" is as lazy as the marketing.&lt;/p&gt;

&lt;p&gt;The sweep is real, and it is worth a lot. Checking every row of a control table against the filesystem, every documented command against what the Makefile does, every external claim against the primary source. That is work I would not have done by hand, and skipping it is how the documentation got into the state Part 5 found.&lt;/p&gt;

&lt;p&gt;Verification against primary sources, when you insist on it, is reliable. HL7 v2.5.1 escape sequences, the FHIR R4 rules on partial dates and nulls, NHS Modulus 11, Terraform's &lt;code&gt;default_tags&lt;/code&gt; syntax, PEP 668, Alertmanager's &lt;code&gt;send_resolved&lt;/code&gt; defaults: all checked against the specification rather than recalled. That rule exists because of a specific failure, a Trivy flag in Part 2 taken from memory, that broke CI and that I had to fix.&lt;/p&gt;

&lt;p&gt;Writing a test that fails against the previous commit before it passes against the new one is a discipline it will follow consistently once it is the standing rule, and it caught the one defect in the list above that was caught before shipping.&lt;/p&gt;

&lt;p&gt;And the writing. Seven articles, the runbook, the security model, this changelog.&lt;/p&gt;
&lt;h2&gt;
  
  
  What I would tell someone starting
&lt;/h2&gt;

&lt;p&gt;Put the assistant where reading pays and put yourself where running pays. They are different jobs, not different quality levels of the same job.&lt;/p&gt;

&lt;p&gt;Make it state what it could not check. The single most useful habit in seven weeks was a standing rule that any unverifiable claim gets said out loud rather than hedged into the prose. That is how &lt;code&gt;docs/security.md&lt;/code&gt; ended up with a "Claimed, not built" section instead of a table of confident sentences.&lt;/p&gt;

&lt;p&gt;Be suspicious of a test written in the same pass as the fix. It will encode the shape of the bug that was found. Ask separately what property you are claiming, and whether anything tests that property rather than that instance.&lt;/p&gt;

&lt;p&gt;Run the thing. Then break it on purpose. Then wait for the email.&lt;/p&gt;
&lt;h2&gt;
  
  
  If you want to try this yourself
&lt;/h2&gt;

&lt;p&gt;You need Docker and &lt;code&gt;make&lt;/code&gt;, about 4 GB free for Docker, and no NHS or cloud account. Everything uses synthetic test data, and the national lookup is stubbed by default.&lt;/p&gt;

&lt;p&gt;Fork the repository, then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;make demo
make walkthrough
make break-pds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first two start nine services and prove each step of the tour works. The third breaks the national patient lookup on purpose. Watch the pipeline keep accepting messages, the alert fire about two minutes later, and the email land in a local inbox at &lt;code&gt;localhost:8025&lt;/code&gt;. Then &lt;code&gt;make restore-pds&lt;/code&gt; puts it back.&lt;/p&gt;

&lt;p&gt;If you are switching careers, into tech or into health tech, that exercise is the one worth being able to explain out loud: what failed, what kept working, who got told, and how you know. Most of the interview questions in Part 6 come down to those four.&lt;/p&gt;

&lt;p&gt;Then pick one item from the known limitations in &lt;code&gt;CHANGELOG.md&lt;/code&gt; and build it. Authentication on &lt;code&gt;POST /hl7&lt;/code&gt; is a good first one. That is the step from following someone else's project to owning a piece of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you fund or buy health tech
&lt;/h2&gt;

&lt;p&gt;Every finding in this series has a question behind it that you can ask a vendor, and none of them needs you to read code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When did an alert last reach a person, and what did it say? A rule that fires into nothing looks identical to one that works.&lt;/li&gt;
&lt;li&gt;Which controls in your security document can you show me in the code? Ten of mine could not be shown when I checked.&lt;/li&gt;
&lt;li&gt;What happens to a message when a system you depend on is down? Where does it wait, and for how long?&lt;/li&gt;
&lt;li&gt;How do you match a patient whose NHS number changes, or arrives as a Scottish CHI number? Mine does not yet, and says so.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A team that answers those with specifics, including what is not built yet, is telling you more than a feature list can.&lt;/p&gt;

&lt;h2&gt;
  
  
  The series in numbers
&lt;/h2&gt;

&lt;p&gt;Over a hundred commits and more than thirty pull requests. About half the commits, and most of the pull requests, came during the seven weeks of the series. Ninety-two tests. Twelve alert rules with twenty promtool cases behind them, each with a runbook section whose link now resolves. Seven articles.&lt;/p&gt;

&lt;p&gt;Roughly a dozen defects found by readers, which is the number I would most want someone starting a build-in-public series to notice.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is still not built
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;POST /hl7&lt;/code&gt; has no authentication. No part of the AWS configuration has ever been applied. The dead-letter path does not survive a pod restart, and the bucket with the correct controls still has nothing writing to it. There is no Alertmanager in the Helm charts, so Kubernetes alert delivery does not exist. Patient identity is keyed on the NHS number alone, which is unsafe for exactly the cases Kevin described.&lt;/p&gt;

&lt;p&gt;All of it is in &lt;code&gt;docs/security.md&lt;/code&gt; under "Claimed, not built", and in&lt;br&gt;
&lt;code&gt;CHANGELOG.md&lt;/code&gt; under the 1.0.0 known limitations. A tool that is good at producing confident prose is a reason to be stricter about that list, not looser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[Prometheus query functions (&lt;a href="https://prometheus.io/docs/prometheus/latest/querying/functions/" rel="noopener noreferrer"&gt;https://prometheus.io/docs/prometheus/latest/querying/functions/&lt;/a&gt;), for &lt;code&gt;absent()&lt;/code&gt; and its label derivation&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://prometheus.io/docs/alerting/latest/configuration/" rel="noopener noreferrer"&gt;Alertmanager configuration&lt;/a&gt;, for the &lt;code&gt;send_resolved&lt;/code&gt; defaults&lt;/li&gt;
&lt;li&gt;&lt;a href="https://keepachangelog.com/en/1.1.0/" rel="noopener noreferrer"&gt;Keep a Changelog 1.1.0&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://peps.python.org/pep-0668/" rel="noopener noreferrer"&gt;PEP 668&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.rfc%20editor.org/rfc/rfc3986#section-3.4" rel="noopener noreferrer"&gt;RFC 3986, section 3.4&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The alert rules in this article were checked with &lt;code&gt;promtool check rules&lt;/code&gt; and exercised with &lt;code&gt;promtool test rules&lt;/code&gt;; the Alertmanager configuration with &lt;code&gt;amtool check-config&lt;/code&gt; 0.34.1&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;docs/ai-usage.md&lt;/code&gt; in the repository holds the same accounting, maintained with the code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Thank you
&lt;/h2&gt;

&lt;p&gt;To everyone who read a part and told me something was wrong: Kevin Mayfield, Mustafa Erbay, Nan, Amorizz, upordown.online, Kartik, Paul Lovelace, and the Part 1 commenters who found the mapping defects. Roughly a dozen real problems in this repository exist in fixed form because somebody asked a question I had thought to ask.&lt;/p&gt;

&lt;p&gt;That is the actual finding of this series, and it is not about AI at all. The assistant read the code tirelessly and found what was wrong with it. Running the system found what was broken. Other people found what was missing.&lt;/p&gt;

&lt;p&gt;Which of those three is weakest in how you work right now?&lt;/p&gt;




&lt;p&gt;This is a personal project. It is not affiliated with or endorsed by NHS England or any NHS organisation. It uses the public PDS FHIR sandbox and synthetic test data only. Views are my own.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>ai</category>
      <category>programming</category>
      <category>testing</category>
    </item>
    <item>
      <title>Day 91: A Playbook That Undoes Itself and a Test That Could Fail</title>
      <dc:creator>Nnamdi Felix Ibe</dc:creator>
      <pubDate>Mon, 23 Nov 2026 18:00:00 +0000</pubDate>
      <link>https://dev.to/ndcodes/day-91-a-playbook-that-undoes-itself-and-a-test-that-could-fail-47b7</link>
      <guid>https://dev.to/ndcodes/day-91-a-playbook-that-undoes-itself-and-a-test-that-could-fail-47b7</guid>
      <description>&lt;p&gt;Day 91 of DevOps, Day 41 of Azure. Both tasks today were about verification, from opposite ends. The Azure half is the best verification I have written in this series. The Ansible half ran clean, reported success, and had already undone half its own work in a way the first run could not show me.&lt;/p&gt;

&lt;p&gt;One Ansible task, one Azure task. A playbook that fights itself, then a test designed so it could fail. The tasks come from the KodeKloud Engineer platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 1: Putting a line at the top of a file with Ansible
&lt;/h2&gt;

&lt;p&gt;Install httpd on three app servers, start it, create &lt;code&gt;/var/www/html/index.html&lt;/code&gt; with one line of content, then put a second line above it. Mode &lt;code&gt;0655&lt;/code&gt;, owned by &lt;code&gt;apache&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The playbook
&lt;/h3&gt;

&lt;p&gt;The last three tasks had taught me the pattern, so this one wrote itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Create index.html with initial content&lt;/span&gt;
      &lt;span class="na"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/var/www/html/index.html&lt;/span&gt;
        &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;This is a Nautilus sample file, created using Ansible!&lt;/span&gt;

    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Add welcome line at the top of file&lt;/span&gt;
      &lt;span class="na"&gt;lineinfile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/var/www/html/index.html&lt;/span&gt;
        &lt;span class="na"&gt;line&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Welcome to Nautilus Group!&lt;/span&gt;
        &lt;span class="na"&gt;insertbefore&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;BOF&lt;/span&gt;
        &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0655'&lt;/span&gt;
        &lt;span class="na"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"apache"&lt;/span&gt;
        &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"apache"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;insertbefore: BOF&lt;/code&gt; is the documented way to put a line at the top. The documentation for &lt;code&gt;lineinfile&lt;/code&gt; lists it directly: "A value is available; &lt;code&gt;BOF&lt;/code&gt; for inserting the line at the beginning of the file." No regular expression needed, no counting lines.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Running it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PLAY RECAP ***************
stapp01 : ok=5  changed=4
stapp02 : ok=5  changed=4
stapp03 : ok=5  changed=4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Checking it properly
&lt;/h3&gt;

&lt;p&gt;This is the part I got right today, and the part I skipped two days ago:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;tony@stapp01 ~&lt;span class="o"&gt;]&lt;/span&gt;$ cat /var/www/html/index.html
Welcome to Nautilus Group!
This is a Nautilus sample file, created using Ansible!

&lt;span class="o"&gt;[&lt;/span&gt;tony@stapp01 ~&lt;span class="o"&gt;]&lt;/span&gt;$ ls -la /var/www/html/index.html
-rw-r-xr-x 1 apache apache 82 May 25 10:22 /var/www/html/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Content, order, mode and ownership, on all three servers. All four requirements met, all four confirmed. 82 bytes checks out as 27 plus 55, which is a small thing to notice and is exactly the kind of small thing that catches a truncated write.&lt;/p&gt;

&lt;p&gt;So the task was done. The next bit is what I found when I asked what a second run would do.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: The two tasks undo each other
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;copy&lt;/code&gt; with &lt;code&gt;content&lt;/code&gt; is idempotent by comparison. It reads the destination, compares it to what the playbook says the file should contain, and does nothing if they already match. &lt;code&gt;lineinfile&lt;/code&gt; inserts its line when the line is not present.&lt;/p&gt;

&lt;p&gt;Put those two behaviours together and trace a second run against the file that exists at the end of the first:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;File before&lt;/th&gt;
&lt;th&gt;What the module decides&lt;/th&gt;
&lt;th&gt;File after&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;copy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;welcome line, then sample line&lt;/td&gt;
&lt;td&gt;Does not match &lt;code&gt;content&lt;/code&gt;, which is the sample line alone. Rewrite.&lt;/td&gt;
&lt;td&gt;sample line only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lineinfile&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;sample line only&lt;/td&gt;
&lt;td&gt;Welcome line is absent. Insert at BOF.&lt;/td&gt;
&lt;td&gt;welcome line, then sample line&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;copy&lt;/code&gt; task deletes the line the &lt;code&gt;lineinfile&lt;/code&gt; task added. The &lt;code&gt;lineinfile&lt;/code&gt; task puts it back. Every run. Forever.&lt;/p&gt;

&lt;p&gt;The file is correct when the playbook finishes, which is why this hides. But two things follow from it.&lt;/p&gt;

&lt;p&gt;The recap never settles. Every subsequent run reports &lt;code&gt;changed=2&lt;/code&gt;, so the &lt;code&gt;changed&lt;/code&gt; count stops carrying information. If I ran this playbook weekly I would learn to ignore those two, and the day a real change appeared I would ignore that too.&lt;/p&gt;

&lt;p&gt;And there is a window where the served page is wrong. Between the &lt;code&gt;copy&lt;/code&gt; task finishing and the &lt;code&gt;lineinfile&lt;/code&gt; task finishing, that file is missing its first line, and Apache is serving it to anyone who asks. The window is short. It is also real, and it opens on every single run.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;The fix is to stop using two tasks to describe one file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Create index.html with its full content&lt;/span&gt;
      &lt;span class="na"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;dest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/var/www/html/index.html&lt;/span&gt;
        &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;Welcome to Nautilus Group!&lt;/span&gt;
          &lt;span class="s"&gt;This is a Nautilus sample file, created using Ansible!&lt;/span&gt;
        &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0655'&lt;/span&gt;
        &lt;span class="na"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apache&lt;/span&gt;
        &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apache&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One task. Idempotent. No window. &lt;code&gt;changed=0&lt;/code&gt; on the second run.&lt;/p&gt;

&lt;p&gt;The Ansible documentation points the same way without quite saying why. &lt;code&gt;lineinfile&lt;/code&gt; "is primarily useful when you want to change a single line in a file only", and then: "For other cases, see the &lt;code&gt;ansible.builtin.copy&lt;/code&gt; or &lt;code&gt;ansible.builtin.template&lt;/code&gt; modules." A file whose entire contents you are specifying is one of those other cases. I was using a line editor to write a two-line file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;blockinfile&lt;/code&gt;, which I used two days ago, is the other answer and the one to reach for when something else also writes to the file. It owns a marked region and leaves the rest alone. Here nothing else writes to the file, so &lt;code&gt;copy&lt;/code&gt; is simpler.&lt;/p&gt;

&lt;p&gt;The task asked for the two-step approach, so the playbook follows the instructions and the instructions produce a playbook that cannot be run twice without churn. Worth knowing which of those two facts you are being graded on.&lt;/p&gt;

&lt;h3&gt;
  
  
  One more thing, on ownership
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;mode&lt;/code&gt;, &lt;code&gt;owner&lt;/code&gt; and &lt;code&gt;group&lt;/code&gt; are on the second task, not the first. So &lt;code&gt;copy&lt;/code&gt; creates the file as root, because the play runs with &lt;code&gt;become: yes&lt;/code&gt;, and &lt;code&gt;lineinfile&lt;/code&gt; is what makes it &lt;code&gt;apache:apache&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Remove that second task, or reorder the two, and you get a root-owned file in a web root. That is the same bug I hit on Days 84 and 85, arriving through a different door: the permissions are not attached to the thing that creates the file.&lt;/p&gt;

&lt;p&gt;And &lt;code&gt;0655&lt;/code&gt; gives &lt;code&gt;-rw-r-xr-x&lt;/code&gt;. Group and other get execute on a static HTML file, where execute does nothing, and &lt;code&gt;apache&lt;/code&gt;, the owner, is the one principal that cannot execute it. &lt;code&gt;0644&lt;/code&gt; is the conventional answer. The task asked for &lt;code&gt;0655&lt;/code&gt;, so &lt;code&gt;0655&lt;/code&gt; is what I set. Two days ago, the same file was asked for at &lt;code&gt;0777&lt;/code&gt;. Neither is a permission a web server needs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Task 2: Azure Table Storage
&lt;/h2&gt;

&lt;p&gt;A table called &lt;code&gt;tasks&lt;/code&gt;, two entities in it, and the two statuses verified.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The account and the table
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;az storage account create -g &lt;span class="s2"&gt;"$RG"&lt;/span&gt; -n &lt;span class="s2"&gt;"$SA"&lt;/span&gt; -l eastus --sku Standard_LRS --kind StorageV2
&lt;span class="nv"&gt;KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;az storage account keys list -g &lt;span class="s2"&gt;"$RG"&lt;/span&gt; -n &lt;span class="s2"&gt;"$SA"&lt;/span&gt; --query &lt;span class="s2"&gt;"[0].value"&lt;/span&gt; -o tsv&lt;span class="o"&gt;)&lt;/span&gt;
az storage table create --name tasks --account-name &lt;span class="s2"&gt;"$SA"&lt;/span&gt; --account-key &lt;span class="s2"&gt;"$KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"created"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No wait, no provisioning state. The table was ready for writes immediately, which is not what I had got used to.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: The entities
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;az storage entity insert --table-name tasks --account-name &lt;span class="s2"&gt;"$SA"&lt;/span&gt; --account-key &lt;span class="s2"&gt;"$KEY"&lt;/span&gt; \
  --entity &lt;span class="nv"&gt;PartitionKey&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;tasks &lt;span class="nv"&gt;RowKey&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &lt;span class="nv"&gt;task&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Learn Table Storage"&lt;/span&gt; &lt;span class="nv"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;completed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And what came back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-10-21T03:29:38+00:00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"etag"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"W/\"datetime'2026-10-21T03%3A29%3A39.5133745Z'\""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2019-02-02"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No &lt;code&gt;PartitionKey&lt;/code&gt;. No &lt;code&gt;RowKey&lt;/code&gt;. None of the properties I sent. The insert response tells me the write was accepted and tells me nothing about what was written.&lt;/p&gt;

&lt;p&gt;I have come to prefer that. Day 38's blob upload returned a &lt;code&gt;content_md5&lt;/code&gt; that the client had computed, so the service reporting it back only confirmed the service had faithfully recorded my own claim about my own file. That looks like verification and is not. Here there is nothing to mistake for verification, so the question of whether the entity is correct stays open and visible, which is where it belongs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Making the service check it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;task1 completed -&amp;gt; 1
task2 in-progress -&amp;gt; 1
total rows -&amp;gt; 2
wrong-status control (expect 0) -&amp;gt; 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first three lines come from server-side filters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;--filter &lt;span class="s2"&gt;"PartitionKey eq 'tasks' and RowKey eq '1' and status eq 'completed'"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A count of 1 means a row exists with that partition, that key and that status. The service applied the predicate. I did not read any JSON and decide it looked right, which is the step where a transposed digit gets waved through.&lt;/p&gt;

&lt;p&gt;The fourth line is the one that makes the other three worth anything.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;RowKey eq '1' and status eq 'in-progress'&lt;/code&gt; is deliberately false. No such row exists. If I had only the three positive counts, they would look conclusive and prove very little: if a malformed filter were being ignored, or were matching everything, every filter I ran would return a positive count, and all three lines would read as success. Getting &lt;code&gt;0&lt;/code&gt; back from a filter that must not match is what proves the filters actually discriminate, and that is what licenses reading the other three as real matches.&lt;/p&gt;

&lt;p&gt;A test that cannot fail is not a test. I had used the same shape on Day 35, where the ping that failed before the peering and succeeded after was worth far more than a ping that only ever succeeded.&lt;/p&gt;

&lt;p&gt;Which is this day's other half turned inside out. Here the check was built so that a broken check would announce itself. Over on the Ansible side, four tasks ran, the recap said success, the file was correct, and two of those tasks had cancelled each other out in a way a single run was structurally incapable of revealing. The difference was not how carefully I looked at the end. It was whether the thing I built was capable of failing in the first place.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Two notes from the documentation that change how I would write this at any size.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;az storage entity query&lt;/code&gt; returns at most 1000 entities per request, and when there are more, &lt;code&gt;nextMarker&lt;/code&gt; carries a continuation token you feed back with &lt;code&gt;--marker&lt;/code&gt;. With two rows, mine came back as &lt;code&gt;{}&lt;/code&gt;, an empty object. So a script that treats "results, no error" as "all the results" is correct at two rows and silently wrong at 1001. The limit belongs to the service, so there is no page size to raise.&lt;/p&gt;

&lt;p&gt;And &lt;code&gt;PartitionKey&lt;/code&gt; is the unit of both distribution and transaction scope. The task puts both rows in one partition, which is fine for two rows and is not how you would build the application. One partition means entity group transactions work and scaling does not: a single partition cannot be split across servers, so its throughput is capped. For a real to-do app, the partition would be the user ID, with the task ID as RowKey.&lt;/p&gt;

&lt;p&gt;That also decides what a query costs. A filter naming both keys is a point query. A filter naming only &lt;code&gt;PartitionKey&lt;/code&gt; is a partition scan. A filter naming neither is a table scan, reading every partition. My two status checks named both keys. My negative control named only &lt;code&gt;RowKey&lt;/code&gt;, so the cheapest-looking line in that output was the most expensive command in the task. Against two rows, irrelevant. At scale, that is the query that quietly costs money.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;copy&lt;/code&gt; with &lt;code&gt;content&lt;/code&gt; and &lt;code&gt;lineinfile&lt;/code&gt; pointed at the same file undo each other on every run, because &lt;code&gt;copy&lt;/code&gt; restores its whole idea of the file and &lt;code&gt;lineinfile&lt;/code&gt; re-adds its line. One &lt;code&gt;copy&lt;/code&gt; with the full content fixes it, or &lt;code&gt;blockinfile&lt;/code&gt; if something else writes to the file too.&lt;/p&gt;

&lt;p&gt;Two tasks describing one file also open a window where the file is wrong, and on a served page that window is live every run.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;insertbefore: BOF&lt;/code&gt; puts a line at the top, and &lt;code&gt;mode&lt;/code&gt;, &lt;code&gt;owner&lt;/code&gt; and &lt;code&gt;group&lt;/code&gt; on that task are what set ownership, so removing it leaves a root-owned file in the web root.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;az storage entity insert&lt;/code&gt; returns a date, an etag and an API version. Verification is always a separate read.&lt;/p&gt;

&lt;p&gt;Verify with a server-side filter and count the matches, so the service does the comparing.&lt;/p&gt;

&lt;p&gt;Pair every positive filter with a deliberately false one. Three matches prove nothing if a broken filter would have matched them too.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;entity show&lt;/code&gt; returns the entity at the top level; &lt;code&gt;entity query&lt;/code&gt; nests it under &lt;code&gt;items&lt;/code&gt;. That is the eighth variation on this trap I have hit in the Azure track, and the fix is still to run the command plain and read the shape before writing a query.&lt;/p&gt;

&lt;p&gt;So here is the Day 91 question. When your check passes, do you know what it would have looked like if it had failed? I could answer that for the Azure half, because I had made it fail on purpose. I could not answer it for the Ansible half, and that is exactly where the bug was.&lt;/p&gt;

&lt;p&gt;Day 91 down. Nine to go.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>ansible</category>
      <category>azure</category>
      <category>automation</category>
    </item>
    <item>
      <title>Day 90: A Mask in the Way and a Policy Pointing at Nothing</title>
      <dc:creator>Nnamdi Felix Ibe</dc:creator>
      <pubDate>Sun, 22 Nov 2026 09:00:00 +0000</pubDate>
      <link>https://dev.to/ndcodes/day-90-a-mask-in-the-way-and-a-policy-pointing-at-nothing-390o</link>
      <guid>https://dev.to/ndcodes/day-90-a-mask-in-the-way-and-a-policy-pointing-at-nothing-390o</guid>
      <description>&lt;p&gt;Day 90 of DevOps, Day 40 of Azure. Both tasks today were about a permission that exists, reads back correctly, and grants nothing.&lt;/p&gt;

&lt;p&gt;On Linux, that is the ACL mask, which can clip an entry you just created down to nothing while &lt;code&gt;ls -l&lt;/code&gt; reports something else entirely. On Azure it is an access policy written against the wrong one of a principal's two GUIDs, which ARM accepts without complaint and which authorises nobody.&lt;/p&gt;

&lt;p&gt;One Ansible task, one Azure task. Set three different ACLs on three servers, then build a Key Vault and prove an encrypt and decrypt round trip. The tasks come from the KodeKloud Engineer platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 1: Three ACLs on three servers
&lt;/h2&gt;

&lt;p&gt;The task: a different file and a different ACL on each app server. Group &lt;code&gt;tony&lt;/code&gt; read on one, user &lt;code&gt;steve&lt;/code&gt; read and write on another, group &lt;code&gt;banner&lt;/code&gt; read and write on the third.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Three plays, not one
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hosts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;stapp01&lt;/span&gt;
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;yes&lt;/span&gt;
  &lt;span class="na"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Create empty file&lt;/span&gt;
      &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/security/blog.txt&lt;/span&gt;
        &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;touch&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Set ACL for group tony&lt;/span&gt;
      &lt;span class="na"&gt;acl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/opt/security/blog.txt&lt;/span&gt;
        &lt;span class="na"&gt;entity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;tony&lt;/span&gt;
        &lt;span class="na"&gt;etype&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;group&lt;/span&gt;
        &lt;span class="na"&gt;permissions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;r&lt;/span&gt;
        &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;present&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hosts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;stapp02&lt;/span&gt;
  &lt;span class="nn"&gt;...
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three plays in one playbook, each targeting one host. The alternative is one play with &lt;code&gt;when: inventory_hostname == ...&lt;/code&gt; on every task, which reads worse and runs every task against every host just to decide to skip it.&lt;/p&gt;

&lt;p&gt;Worth the contrast with Day 86, where one play served three hosts because the only thing varying was a value that &lt;code&gt;{{ ansible_user }}&lt;/code&gt; supplied per host. Here the filenames and the ACL types differ, so the plays differ.&lt;/p&gt;

&lt;p&gt;The output confirms plays run in sequence: &lt;code&gt;PLAY [stapp01]&lt;/code&gt; finishes before &lt;code&gt;PLAY [stapp02]&lt;/code&gt; starts. Within a play, Ansible parallelises across hosts, as Day 85 showed. Between plays it does not.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Two things the short module name hides
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;acl&lt;/code&gt; is &lt;code&gt;ansible.posix.acl&lt;/code&gt;, from the &lt;code&gt;ansible.posix&lt;/code&gt; collection. Not &lt;code&gt;ansible.builtin&lt;/code&gt;, and not shipped in &lt;code&gt;ansible-core&lt;/code&gt;, so it needs &lt;code&gt;ansible-galaxy collection install ansible.posix&lt;/code&gt; on a control node that does not already have it. The lab had it. A fresh one would fail at task resolution, which has nothing to do with ACLs and reads as it does.&lt;/p&gt;

&lt;p&gt;That is three naming patterns in one batch, none visible in the playbook. Day 87's &lt;code&gt;yum&lt;/code&gt; resolves to &lt;code&gt;ansible.builtin.yum&lt;/code&gt;, which is itself a redirect to the &lt;code&gt;dnf&lt;/code&gt; module. Day 89 used the fully qualified &lt;code&gt;ansible.builtin.blockinfile&lt;/code&gt;. This one resolves outside core entirely.&lt;/p&gt;

&lt;p&gt;And &lt;code&gt;state&lt;/code&gt; is doing real work. Its default is &lt;code&gt;query&lt;/code&gt;, which "gets the current ACL without changing it, for use in register operations". So a task that omits &lt;code&gt;state&lt;/code&gt; reads the ACL, changes nothing, reports no change, and looks like it worked. &lt;code&gt;state: present&lt;/code&gt; is not boilerplate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: The mask, and why &lt;code&gt;ls -l&lt;/code&gt; disagrees with &lt;code&gt;getfacl&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This is the finding worth keeping, and it is sitting in plain sight in the output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# stapp02
-rw-rw-r--+ 1 root root  story.txt

user:steve:rw-
group::r--
mask::rw-
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;getfacl&lt;/code&gt; says the owning group has &lt;code&gt;r--&lt;/code&gt;. &lt;code&gt;ls -l&lt;/code&gt; shows the group bits as &lt;code&gt;rw-&lt;/code&gt;. Those contradict each other, and both are correct.&lt;/p&gt;

&lt;p&gt;When a file has extended ACLs, the group permission bits in &lt;code&gt;ls -l&lt;/code&gt; are the mask, not the owning group's entry. The mask is a ceiling applied to every named user, every named group and the owning group, and &lt;code&gt;setfacl&lt;/code&gt; recalculates it by default to cover whatever those entries ask for. &lt;code&gt;steve&lt;/code&gt; asked for &lt;code&gt;rw&lt;/code&gt;, the mask widened to &lt;code&gt;rw-&lt;/code&gt;, and &lt;code&gt;ls -l&lt;/code&gt; now reports &lt;code&gt;rw-&lt;/code&gt; in the group field while the owning group still has only &lt;code&gt;r--&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;+&lt;/code&gt; at the end of the mode string is the only clue any of this is happening. One character.&lt;/p&gt;

&lt;p&gt;Two consequences, and the second is the one that catches people.&lt;/p&gt;

&lt;p&gt;Reading &lt;code&gt;ls -l&lt;/code&gt; on a file with an ACL tells you the ceiling, not the group's access. On this file, it looks like "group can write", which is wrong in two different ways at once.&lt;/p&gt;

&lt;p&gt;And an ACL entry can exist and grant nothing. A &lt;code&gt;mask::r--&lt;/code&gt; with a &lt;code&gt;user:steve:rw-&lt;/code&gt; entry means &lt;code&gt;steve&lt;/code&gt; has the entry and cannot write, because the mask clips it. &lt;code&gt;getfacl&lt;/code&gt; flags that with an &lt;code&gt;#effective:&lt;/code&gt; comment. It did not happen here, because the module's &lt;code&gt;recalculate_mask&lt;/code&gt; defaults to &lt;code&gt;default&lt;/code&gt; and &lt;code&gt;setfacl&lt;/code&gt; widened the mask to fit. Set the mask explicitly, or pass &lt;code&gt;recalculate_mask: no_mask&lt;/code&gt;, and you can produce exactly that: a permission present, correct in intent, and ineffective.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Verify ACLs with &lt;code&gt;getfacl&lt;/code&gt;, which is what this task did on all three servers.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ls -la&lt;/code&gt; alone would have shown the &lt;code&gt;+&lt;/code&gt; and the mask and none of the entries, which on stapp02 would have read as "group can write" and been wrong. The task asked for an ACL, and &lt;code&gt;getfacl&lt;/code&gt; is the only command that shows one.&lt;/p&gt;

&lt;p&gt;Worth saying because yesterday's verification checked content and skipped the mode and ownership the task also named. This one checked the thing that was genuinely hard to get right, with the command that shows it.&lt;/p&gt;

&lt;p&gt;One other thing to fix: &lt;code&gt;state: touch&lt;/code&gt; on the file tasks means this playbook reports &lt;code&gt;changed&lt;/code&gt; on every run forever, for Day 84's reason. The ACL tasks are idempotent. The file creation is not, unless &lt;code&gt;modification_time: preserve&lt;/code&gt; and &lt;code&gt;access_time: preserve&lt;/code&gt; are added.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 2: A Key Vault and a round trip
&lt;/h2&gt;

&lt;p&gt;The task: a vault, an RSA-4096 key, an access policy granting exactly Get, List, Encrypt and Decrypt, and an encrypt and decrypt of a file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The whole task was one GUID
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az account show --query user.name -o tsv   -&amp;gt;  a1107d7d-9373-4903-a81c-21b8d7531bce
token "oid" claim                          -&amp;gt;  18970e52-5cf3-4f58-ad2c-7fbffab9e2b8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The lab identity is a service principal, and for a service principal &lt;code&gt;user.name&lt;/code&gt; is the application ID. &lt;code&gt;az keyvault set-policy --object-id&lt;/code&gt; wants the object ID, which is the identifier of the service principal object in the directory. Two different GUIDs for the same principal.&lt;/p&gt;

&lt;p&gt;Pass the app ID to &lt;code&gt;--object-id&lt;/code&gt;, and ARM accepts it. It creates a policy entry pointing at nothing. The vault then reports an access policy that looks entirely correct, grants access to nobody, and every crypto call returns &lt;code&gt;Forbidden&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Both values appear in one &lt;code&gt;az keyvault show&lt;/code&gt; response, which makes it concrete:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"accessPolicies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"objectId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"18970e52-..."&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nl"&gt;"systemData"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"createdBy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"a1107d7d-..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"createdByType"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Application"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ARM's audit trail records the app ID. The access policy records the object ID. Same principal, same JSON document, two values you cannot substitute for each other.&lt;/p&gt;

&lt;p&gt;Which is this morning's ACL mask at a different scale. An entry clipped by the mask is present and ineffective. A vault policy written against the app ID is present and ineffective. Both read back fine, and the only way to find out is to attempt the operation it was supposed to permit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Getting the object ID when Graph is closed
&lt;/h3&gt;

&lt;p&gt;Every obvious route goes through Microsoft Graph, and the lab identity cannot read it. &lt;code&gt;az ad sp show&lt;/code&gt; is denied. &lt;code&gt;az keyvault set-policy --spn&lt;/code&gt; resolves the app ID through Graph. &lt;code&gt;az role assignment list --all&lt;/code&gt; returned &lt;code&gt;[]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The access token already contains the answer. Its &lt;code&gt;oid&lt;/code&gt; claim is the object ID of the authenticated principal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;OID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;az account get-access-token --query accessToken -o tsv \
  &lt;span class="o"&gt;|&lt;/span&gt; python3 -c &lt;span class="s2"&gt;"import sys,base64,json; p=sys.stdin.read().strip().split('.')[1]; p+='='*(-len(p)%4); print(json.loads(base64.urlsafe_b64decode(p))['oid'])"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The padding line matters. JWTs use base64url with the padding stripped, so &lt;code&gt;b64decode&lt;/code&gt; fails on most tokens without &lt;code&gt;'='*(-len(p)%4)&lt;/code&gt; added back.&lt;/p&gt;

&lt;p&gt;Worth keeping for any Azure task that needs "the object ID of whoever I am" with Graph closed. The payload also carries &lt;code&gt;appid&lt;/code&gt;, &lt;code&gt;tid&lt;/code&gt; and &lt;code&gt;sub&lt;/code&gt;, which covers most identity questions a script will ask.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--no-self-perms&lt;/code&gt; on the create solves the same problem from the other end, because by default &lt;code&gt;az keyvault create&lt;/code&gt; writes a policy for the caller, which means resolving the caller's object ID, which means Graph. Without the flag, that step either warns and produces a vault with no policies or fails the create outright and leaves half a vault behind.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: The order of operations is forced
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set-policy --key-permissions get list create encrypt decrypt   # then create the key
set-policy --key-permissions get list encrypt decrypt          # then narrow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;set-policy --key-permissions&lt;/code&gt; replaces that category's permission array. It does not add to it.&lt;/p&gt;

&lt;p&gt;The task asks for exactly Get, List, Encrypt and Decrypt, and none of those four permits creating a key. So grant &lt;code&gt;create&lt;/code&gt; temporarily, create the key, then narrow. The other order gives &lt;code&gt;Forbidden&lt;/code&gt; on &lt;code&gt;keyvault key create&lt;/code&gt;, and the error names the operation rather than the policy, which sends you off looking at RBAC.&lt;/p&gt;

&lt;p&gt;Fourth command in this challenge that replaces rather than merges, after &lt;code&gt;az resource tag&lt;/code&gt;, the S3 notification configuration and the lifecycle policy. With one mercy: &lt;code&gt;set-policy&lt;/code&gt; is scoped per object ID and per category, so it replaces one cell of the matrix rather than the whole table.&lt;/p&gt;

&lt;p&gt;And then re-verify, because the round trip was first proven while &lt;code&gt;create&lt;/code&gt; was still in the policy, which proves nothing about the state being left behind. That is the AWS Day 38 lesson with the terms swapped: there, configuration was right and behaviour untested. Here, behaviour was tested against a configuration that no longer existed.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Two corrections to my own notes on soft delete, and both matter more than the thing I got right.&lt;/p&gt;

&lt;p&gt;I wrote that soft delete "cannot be disabled; it has been mandatory since 2020". The first half is documented: "Once soft-delete is enabled on a key vault, it can't be disabled." The 2020 date is not on that page, which instead says it is on by default for new vaults and that customers are "strongly encouraged to turn on soft delete enforcement for their vaults via Azure Policy". That reads as a default rather than an absolute, so I am recording the date as unverified.&lt;/p&gt;

&lt;p&gt;The default retention is 90 days, not 7: "You can set it anywhere from 7 to 90 days, with 90 days being the default." So &lt;code&gt;--retention-days 7&lt;/code&gt; was necessary to meet the requirement rather than a restatement of the default, which I had backwards on.&lt;/p&gt;

&lt;p&gt;And it is permanent: "The retention interval can only be configured during key vault creation and can't be changed afterwards." That vault has a seven-day window for its entire life, and changing it means a different vault.&lt;/p&gt;

&lt;p&gt;The name reservation I flagged is confirmed and broader than I stated: the name cannot be reused until retention expires, a vault with the same name can't be created in the same location, and "The DNS record corresponding to the vault is also retained during the retention interval." Which is why the discovery step ran &lt;code&gt;az keyvault list-deleted&lt;/code&gt; before creating anything.&lt;/p&gt;

&lt;p&gt;One last thing that is worth knowing before using this pattern for real. RSA cannot encrypt more than its modulus allows, and for a 4096-bit key with RSA-OAEP the ceiling is 470 bytes of plaintext. The file here was 26 bytes. Beyond the limit, the answer is &lt;code&gt;wrapKey&lt;/code&gt; and envelope encryption, encrypting a symmetric data key in the vault and the actual file locally with AES, which is how Azure Disk Encryption works and why "encrypted with Key Vault" rarely means the bytes went to Key Vault.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;Both halves are the same failure in two systems: a permission that is syntactically fine, visible when you look, and does nothing.&lt;/p&gt;

&lt;p&gt;The ACL mask is the more elegant one, because the system is actively telling you something misleading. &lt;code&gt;ls -l&lt;/code&gt; reports the mask in the group field, so a file where the group has read-only displays as read-write, and the only signal that the number you are reading is not the number you think is a single &lt;code&gt;+&lt;/code&gt; at the end of the mode string.&lt;/p&gt;

&lt;p&gt;The Key Vault GUID is the more expensive one. ARM takes the wrong identifier without complaint, the vault displays a policy that looks correct, and every operation fails with &lt;code&gt;Forbidden&lt;/code&gt;, which points at permissions in general rather than at one wrong field. Two GUIDs, same principal, both in the same response, and the hint the task gives you points at the wrong one.&lt;/p&gt;

&lt;p&gt;The thing both have in common is that reading the configuration back is not a check. In both cases, it reads back exactly as intended. The only test is attempting the operation the permission was supposed to allow, which is what I eventually did in one case and what the mask happened to spare me in the other.&lt;/p&gt;

&lt;p&gt;So here is the Day 90 question. Which of your access rules have you confirmed by reading them, rather than by watching someone successfully use them?&lt;/p&gt;

&lt;p&gt;Day 90 down. Ten to go.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>ansible</category>
      <category>azure</category>
      <category>automation</category>
    </item>
    <item>
      <title>Day 89: A Dead Service and a Private Container That Serves</title>
      <dc:creator>Nnamdi Felix Ibe</dc:creator>
      <pubDate>Sat, 21 Nov 2026 09:00:00 +0000</pubDate>
      <link>https://dev.to/ndcodes/day-89-a-marker-in-the-file-and-a-grant-somewhere-else-1deo</link>
      <guid>https://dev.to/ndcodes/day-89-a-marker-in-the-file-and-a-grant-somewhere-else-1deo</guid>
      <description>&lt;p&gt;Day 89 of DevOps, Day 39 of Azure. Both tasks today produced something that reads as broken and is documented as correct.&lt;/p&gt;

&lt;p&gt;A service came back &lt;code&gt;inactive (dead)&lt;/code&gt;, and that was the right result, one day after an identical command had to say &lt;code&gt;active (running)&lt;/code&gt;. And an Azure storage container holding a live website is private, returns 404 to anonymous requests, and the website serves anyway.&lt;/p&gt;

&lt;p&gt;One Ansible task, one Azure task. Install logrotate on three servers, then host a static site on a storage account. The tasks come from the KodeKloud Engineer platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 1: Install logrotate
&lt;/h2&gt;

&lt;p&gt;The task: a playbook that installs &lt;code&gt;logrotate&lt;/code&gt; on all three app servers. One package, no service requirement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hosts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;app_servers&lt;/span&gt;
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;yes&lt;/span&gt;

  &lt;span class="na"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install logrotate package.&lt;/span&gt;
      &lt;span class="na"&gt;yum&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;logrotate&lt;/span&gt;
        &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;present&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stapp01 : ok=2  changed=1   stapp02 : ok=2  changed=1   stapp03 : ok=2  changed=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 1: Then the verification that looks like a failure
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;tony@stapp01 ~&lt;span class="o"&gt;]&lt;/span&gt;$ sudo systemctl status logrotate
○ logrotate.service - Rotate log files
     Loaded: loaded &lt;span class="o"&gt;(&lt;/span&gt;/usr/lib/systemd/system/logrotate.service&lt;span class="o"&gt;;&lt;/span&gt; static&lt;span class="o"&gt;)&lt;/span&gt;
     Active: inactive &lt;span class="o"&gt;(&lt;/span&gt;dead&lt;span class="o"&gt;)&lt;/span&gt;
TriggeredBy: ○ logrotate.timer
       Docs: man:logrotate&lt;span class="o"&gt;(&lt;/span&gt;8&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;inactive (dead)&lt;/code&gt;. Yesterday the same command on &lt;code&gt;vsftpd&lt;/code&gt; had to say &lt;code&gt;active (running)&lt;/code&gt; for the task to be done, and here the opposite is correct.&lt;/p&gt;

&lt;p&gt;Three details in that output explain why.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;TriggeredBy: logrotate.timer&lt;/code&gt; is the mechanism. logrotate is not a daemon. It is a batch job that systemd runs on a schedule, so being inactive almost all the time is exactly what it does. The question "will this run" is answered by the timer, not the service.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;static&lt;/code&gt; in the Loaded line means the unit has no &lt;code&gt;[Install]&lt;/code&gt; section, so it cannot be enabled or disabled at all. Which is also why the playbook correctly has no &lt;code&gt;service&lt;/code&gt; task. There is nothing to start and nothing to enable, and had the task asked for &lt;code&gt;state: started&lt;/code&gt;, the right move would have been to question the task rather than write it.&lt;/p&gt;

&lt;p&gt;And the unit exists, which is what the install produced. Before the playbook, the same command said &lt;code&gt;Unit logrotate.service could not be found.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So two consecutive days, one command, opposite right answers:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Day&lt;/th&gt;
&lt;th&gt;Package&lt;/th&gt;
&lt;th&gt;Correct state&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;87&lt;/td&gt;
&lt;td&gt;vsftpd&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;enabled&lt;/code&gt;, &lt;code&gt;active (running)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;88&lt;/td&gt;
&lt;td&gt;logrotate&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;static&lt;/code&gt;, &lt;code&gt;inactive (dead)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The habit worth having is working out which kind of unit you are looking at before deciding what success looks like. And the check that actually answers the question for a timer is &lt;code&gt;systemctl list-timers logrotate.timer&lt;/code&gt;, which is the one command neither the task nor I ran.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Installing logrotate gives you the binary, the unit, the timer, and &lt;code&gt;/etc/logrotate.conf&lt;/code&gt; with its &lt;code&gt;include /etc/logrotate.d&lt;/code&gt; line. It does not give you a rotation policy for anything.&lt;/p&gt;

&lt;p&gt;So the task is satisfied, and nothing is being rotated that was not already. A playbook doing useful work would drop a file into &lt;code&gt;/etc/logrotate.d/&lt;/code&gt; saying which logs to rotate and how often, which is one more task using &lt;code&gt;copy&lt;/code&gt; or &lt;code&gt;template&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Worth saying because "logrotate is installed" and "logs are being rotated" are different claims. It is Day 76's backup-with-no-tables pattern in a milder form: the thing that was asked for is in place, and the outcome anyone actually wants is a step further on.&lt;/p&gt;

&lt;p&gt;One small thing to fix in my own notes. I wrote the playbook path as &lt;code&gt;/home/thor/ansible/playbook.yml&lt;/code&gt; and then ran it from &lt;code&gt;~/playbook&lt;/code&gt;. The transcript shows the run working, so &lt;code&gt;~/playbook&lt;/code&gt; is the real location. Anyone following the stated path writes the file where the command will not find it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 2: A static site on a storage account
&lt;/h2&gt;

&lt;p&gt;The task: a storage account with static website hosting, serving an uploaded &lt;code&gt;index.html&lt;/code&gt; publicly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The container is private, and the site works
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;web_endpoint:  http=200    (https://...z13.web.core.windows.net/)
blob_endpoint: http=404    (https://...blob.core.windows.net/%24web/index.html)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same account, same blob, same anonymous caller. One endpoint serves it, the other denies it exists.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$web&lt;/code&gt; was never given a public access level. It was created implicitly by enabling static website hosting, and its &lt;code&gt;publicAccess&lt;/code&gt; is unset, which is why the blob endpoint 404s. Enabling hosting is the entire grant, and it has its own anonymous read path that does not go through container ACLs at all.&lt;/p&gt;

&lt;p&gt;Which is the morning's finding from the other side. There, the state that makes a task idempotent is two comment lines in the file being edited, not anything in the playbook. Here, the permission that makes a site public is a service property on the account, not an ACL on the container holding the content. Both times, the place you would reach for first is not where the answer is kept.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: The thing I left open is documented
&lt;/h3&gt;

&lt;p&gt;My notes ended that section honestly and incompletely:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Not tested: whether the site still serves with &lt;code&gt;allowBlobPublicAccess: false&lt;/code&gt;. Microsoft documents the static website endpoint as unaffected by that switch... that is currently an inference, not a result.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It is documented, in one sentence on the page about disallowing anonymous access:&lt;/p&gt;

&lt;p&gt;"Disallowing anonymous access for a storage account doesn't affect any static websites hosted in that storage account. The $web container is always publicly accessible."&lt;/p&gt;

&lt;p&gt;So the inference was right, and the documented claim is broader than the one I was reaching for. Not "unaffected by that switch" but "always publicly accessible", which is a statement about &lt;code&gt;$web&lt;/code&gt; itself rather than about two settings interacting.&lt;/p&gt;

&lt;p&gt;The useful consequence is the configuration I had guessed might exist. Static website hosting is the way to serve public content from a storage account with anonymous blob access completely disabled. Account-wide anonymous access off, so no container can ever be made public by accident, and the site still served. That is what a real deployment would want, and I had it as a maybe.&lt;/p&gt;

&lt;p&gt;Worth being precise that this still was not observed. The account was created with the switch on, because the task says "allow public access" and a grader reads that field. What changed is that the claim is documented rather than inferred, which is a different kind of support than a test.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Three things, and the first costs the most time when you get it wrong.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://xfusionwebst360856247.z13.web.core.windows.net/
                              ^^^^
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That &lt;code&gt;z13&lt;/code&gt; is a DNS zone partition assigned to the account. It is not derivable from the account name, the region, or anything else visible, and it varies between accounts. Every other storage endpoint is predictable from the account name. This one is not.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;WEB&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;az storage account show -g &lt;span class="s2"&gt;"$RG"&lt;/span&gt; -n &lt;span class="s2"&gt;"$SA"&lt;/span&gt; --query &lt;span class="s2"&gt;"primaryEndpoints.web"&lt;/span&gt; -o tsv&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Guessing the hostname gives a DNS failure, not an HTTP error, so the error points nowhere near the real cause, and you end up debugging a storage account that was correct the whole time. Same trap as the &lt;code&gt;s3-website-us-east-1&lt;/code&gt; hyphen on AWS Day 39.&lt;/p&gt;

&lt;p&gt;Second, set the content type explicitly even when the CLI would guess right:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;--content-type text/html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The failure mode is nasty. An &lt;code&gt;index.html&lt;/code&gt; stored as &lt;code&gt;application/octet-stream&lt;/code&gt; returns HTTP 200 and the browser downloads it instead of rendering it. The URL works, the bytes are correct, &lt;code&gt;curl&lt;/code&gt; is perfectly happy, and only a real browser shows the problem. A 200 with the wrong content type is harder to find than a 404. Read it back off the response header rather than the blob's metadata, so the check is end-to-end.&lt;/p&gt;

&lt;p&gt;Third, &lt;code&gt;$web&lt;/code&gt; needs single quotes in bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;-c &lt;span class="s1"&gt;'$web'&lt;/span&gt;      &lt;span class="c"&gt;# correct&lt;/span&gt;
-c &lt;span class="s2"&gt;"$web"&lt;/span&gt;      &lt;span class="c"&gt;# expands to empty string&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is a legal container name and a variable reference at the same time, and double quotes make bash substitute an undefined variable and pass an empty container name. It also appears as &lt;code&gt;%24web&lt;/code&gt; in anything URL-shaped, because &lt;code&gt;$&lt;/code&gt; is reserved in a URI path.&lt;/p&gt;

&lt;p&gt;Worth the comparison with S3 while it is fresh, because the two platforms are exactly inverted here. On S3, enabling website hosting turns on index document resolution and grants nothing, so public read needs a separate bucket policy with the access block off, and the objects then become readable through the REST endpoint as well. Azure keeps the blob endpoint shut and opens only the web one, which is a smaller exposed surface for the same outcome. And Azure's web endpoint does HTTPS, whereas an S3 website endpoint cannot do TLS at all, which is why CloudFront sits in front of essentially every real S3 static site.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;Both halves produced something that reads as broken and is documented as correct.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;inactive (dead)&lt;/code&gt; is the better of the two findings, because it is cheap and permanent. Some systemd units are daemons, and some are batch jobs with timers, and the same &lt;code&gt;systemctl status&lt;/code&gt; command is the right check for both with opposite correct answers. The tell is three words in the output: &lt;code&gt;static&lt;/code&gt; and &lt;code&gt;TriggeredBy&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The Azure half is the one I got a response to. I wrote down an open question and said plainly that my reasoning was suggestive and the evidence was absent. Going and looking turned it into a documented behaviour, and a stronger one than I was expecting: &lt;code&gt;$web&lt;/code&gt; is always publicly accessible, full stop, which makes a static website the way to serve public content from an account where anonymous blob access is switched off entirely.&lt;/p&gt;

&lt;p&gt;So here is the Day 89 question. How many of the alerts you would act on are firing on a state that something's own documentation calls correct?&lt;/p&gt;

&lt;p&gt;Day 89 down. Eleven to go.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>ansible</category>
      <category>azure</category>
      <category>automation</category>
    </item>
    <item>
      <title>Day 88: A Marker in the File and a Disputed Status Code</title>
      <dc:creator>Nnamdi Felix Ibe</dc:creator>
      <pubDate>Fri, 20 Nov 2026 18:00:00 +0000</pubDate>
      <link>https://dev.to/ndcodes/day-88-a-dead-service-and-a-disputed-status-code-48j5</link>
      <guid>https://dev.to/ndcodes/day-88-a-dead-service-and-a-disputed-status-code-48j5</guid>
      <description>&lt;p&gt;Day 88 of DevOps, Day 38 of Azure. Both tasks today put the thing that matters somewhere other than where I had recorded it.&lt;/p&gt;

&lt;p&gt;An Ansible module that is reliably idempotent turns out to store its entire record of what it did in two comment lines inside the file it edits. And an Azure error code I had written down as the answer turns out to be one of several the same condition produces, depending on the client.&lt;/p&gt;

&lt;p&gt;One Ansible task, one Azure task. Write a block of content into a web page on three servers, then upload a file from a VM into a private blob container. The tasks come from the KodeKloud Engineer platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 1: A block of content in a web page
&lt;/h2&gt;

&lt;p&gt;The task: install httpd, start it, and write a block into &lt;code&gt;/var/www/html/index.html&lt;/code&gt; with mode &lt;code&gt;0777&lt;/code&gt; owned by &lt;code&gt;apache&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Using the blockinfile module.&lt;/span&gt;
      &lt;span class="na"&gt;ansible.builtin.blockinfile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/var/www/html/index.html&lt;/span&gt;
        &lt;span class="na"&gt;create&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;yes&lt;/span&gt;
        &lt;span class="na"&gt;block&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;Welcome to XfusionCorp!&lt;/span&gt;

          &lt;span class="s"&gt;This is  Nautilus sample file, created using Ansible!&lt;/span&gt;

          &lt;span class="s"&gt;Please do not modify this file manually!&lt;/span&gt;
        &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0777'&lt;/span&gt;
        &lt;span class="na"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"apache"&lt;/span&gt;
        &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"apache"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 1: The markers are the state
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[tony@stapp01 ~]$ cat /var/www/html/index.html
# BEGIN ANSIBLE MANAGED BLOCK
Welcome to XfusionCorp!
...
# END ANSIBLE MANAGED BLOCK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those two comment lines are the whole reason this task is idempotent. The default marker is &lt;code&gt;"# {mark} ANSIBLE MANAGED BLOCK"&lt;/code&gt;, with &lt;code&gt;marker_begin&lt;/code&gt; defaulting to &lt;code&gt;BEGIN&lt;/code&gt; and &lt;code&gt;marker_end&lt;/code&gt; to &lt;code&gt;END&lt;/code&gt;. On the next run the module looks for those lines, finds the block between them, compares it to what the playbook says, and reports &lt;code&gt;ok&lt;/code&gt; if they match.&lt;/p&gt;

&lt;p&gt;So the module keeps no record anywhere of its own. The state lives in the target file, in two lines that look like decoration. Delete them by hand and the next run appends a second copy of the block, because there is nothing left to match against.&lt;/p&gt;

&lt;p&gt;Two documented ways to break that, both worth knowing before writing a custom marker. "Multi-line markers are not supported and will result in the block being repeatedly inserted on subsequent playbook runs." And a custom marker without &lt;code&gt;{mark}&lt;/code&gt; in it does the same thing, because the begin and end lines become identical.&lt;/p&gt;

&lt;p&gt;There is a constraint on managing two blocks in one file, too: the marker has to differ per task, since two tasks sharing the default fight over the same region.&lt;/p&gt;

&lt;p&gt;Worth setting against the rest of this fortnight, because blockinfile is the well-behaved one. Day 85's &lt;code&gt;file: state=touch&lt;/code&gt; reports a change on every run because its timestamps default to &lt;code&gt;now&lt;/code&gt;. Day 91's &lt;code&gt;copy&lt;/code&gt; plus &lt;code&gt;lineinfile&lt;/code&gt; pair actively undoes its own work. This module is idempotent, and the mechanism is visible in the file rather than hidden in the module.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;create: yes&lt;/code&gt; was necessary rather than defensive, by the way. The parameter "defaults to &lt;code&gt;false&lt;/code&gt;", and the before-check showed the file was absent, so without it the task would have failed on a missing path.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: The recap told me something I had not checked
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TASK [Install httpd package.] ***************  ok: [stapp01]
TASK [Starting the httpd service.] ***************  ok: [stapp01]
TASK [Using the blockinfile module.] ***************  changed: [stapp01]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two &lt;code&gt;ok&lt;/code&gt; and one &lt;code&gt;changed&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;My before-check was &lt;code&gt;cat /var/www/html/index.html&lt;/code&gt;, which came back "No such file or directory". That tested the file. It did not test the package.&lt;/p&gt;

&lt;p&gt;The recap did, for free. httpd was already installed and already running on all three servers before the playbook ran, which is why those two tasks report &lt;code&gt;ok&lt;/code&gt;. Day 91's run of a nearly identical playbook shows both as &lt;code&gt;changed&lt;/code&gt;, because that lab had no httpd. Same tasks, two labs, and the recap distinguishes them with nothing added.&lt;/p&gt;

&lt;p&gt;Which is worth drawing out, because a recap that is all &lt;code&gt;changed&lt;/code&gt; on a first run gets read as "it worked" and a mix gets read as "it worked, partly". The mix is the more informative of the two: it tells you what was already true.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Two things, and the first is the task's own fault rather than mine.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0777&lt;/code&gt; is world-writable. Any local user on those three servers, including whatever account a compromised process is running as, can rewrite the page Apache serves. The file's content says "Please do not modify this file manually!", which the permissions then cheerfully invite.&lt;/p&gt;

&lt;p&gt;For a static page that Apache reads, &lt;code&gt;0644&lt;/code&gt; owned by &lt;code&gt;apache&lt;/code&gt; is sufficient, and &lt;code&gt;0444&lt;/code&gt; is sufficient if nothing is meant to change it between deployments. Nothing about serving a file requires write permission for anybody. The task asked for &lt;code&gt;0777&lt;/code&gt;, so the playbook is right, and it is worth knowing what was asked for.&lt;/p&gt;

&lt;p&gt;The second is mine. My verification was &lt;code&gt;cat&lt;/code&gt; on the file, and that is it. The task named three things: the content, the mode, and the ownership. I checked one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la /var/www/html/index.html    &lt;span class="c"&gt;# expect -rwxrwxrwx 1 apache apache&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One command, never run, on any of the three servers. It is also the command that would have caught a typo in the mode string, which is exactly the kind of thing a quoted octal is prone to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 2: A file from a VM into a private container
&lt;/h2&gt;

&lt;p&gt;The task: a storage account, a private blob container, and a file uploaded into it from a VM using the account key.&lt;/p&gt;

&lt;p&gt;First, the title. "Running Containers on Azure Virtual Machines" reads as Docker, and nothing in the requirements involves a container runtime. It is a blob container.&lt;/p&gt;

&lt;p&gt;Third time in this challenge, after Day 14's "Create and Attach" with no VM to attach to and Day 32's "Synchronizing Containers" for a single file copy. The title names a topic area; the numbered requirements are the contract.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The code I got wrong
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;anon_list=409    anon_blob=409
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Days 17 and 19 recorded 404 for an anonymous request to a private container, on accounts where &lt;code&gt;allowBlobPublicAccess&lt;/code&gt; was &lt;code&gt;true&lt;/code&gt;. Here the account switch is &lt;code&gt;false&lt;/code&gt; and curl got 409 with &lt;code&gt;PublicAccessNotPermitted&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I wrote that up as a clean table: 404 means the container is private, 409 means the account forbids anonymous access. The error code and message are documented. The status code is not the one Microsoft gives:&lt;/p&gt;

&lt;p&gt;"After you disallow anonymous access for a storage account, clients that use the anonymous bearer challenge find that Azure Storage returns a 403 error (Forbidden) rather than a 401 error (Unauthorized)."&lt;/p&gt;

&lt;p&gt;403, with a qualifier that does the work: it applies to clients using the anonymous bearer challenge. &lt;code&gt;curl&lt;/code&gt; is not one. So the 409 I saw is real for that client and is not the number in the documentation.&lt;/p&gt;

&lt;p&gt;This is the second time in this series the same lesson has arrived. Two batches ago I corrected my Day 17 note, where the error code turned out to depend on the request's API version and the client's bearer-challenge support. Same thing again, in a different cell of the same table.&lt;/p&gt;

&lt;p&gt;The honest version:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Account setting&lt;/th&gt;
&lt;th&gt;Container&lt;/th&gt;
&lt;th&gt;Observed with curl&lt;/th&gt;
&lt;th&gt;Documented&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;allows&lt;/td&gt;
&lt;td&gt;private&lt;/td&gt;
&lt;td&gt;404&lt;/td&gt;
&lt;td&gt;not stated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;allows&lt;/td&gt;
&lt;td&gt;&lt;code&gt;container&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;disallows&lt;/td&gt;
&lt;td&gt;anything&lt;/td&gt;
&lt;td&gt;409&lt;/td&gt;
&lt;td&gt;403 for bearer-challenge clients&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The conclusion survives as an observation rather than a rule: the code tells you which layer refused, and a 409 is stronger evidence of an account-wide guardrail than a 404. The documentation supports the substance from another angle, which is the part I would actually rely on: "Disallowing anonymous access for the storage account overrides the access settings for all containers in that storage account", and once it is off "you can't configure the access setting for a container to permit anonymous access".&lt;/p&gt;

&lt;p&gt;Two details from the same page worth having. The change takes "up to 30 seconds before the change is fully propagated". And it does not touch authenticated requests: "if the request is passed with an &lt;code&gt;Authorization&lt;/code&gt; header, the service ignores anonymous access on the storage account and authorizes the request based on the provided credentials". Which is why the upload worked perfectly well against a container that refuses anonymous reads.&lt;/p&gt;

&lt;p&gt;Which pairs with the morning more neatly than I expected. &lt;code&gt;inactive (dead)&lt;/code&gt; looks like a failure and is correct. A 409 looks like a definitive answer and is one of several codes the same condition can produce. Both are a status that means nothing until you know what produced it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Field names with no convention at all
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"content_md5"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"QiHQAs6108npE35JXOqmRw=="&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"etag"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"\"0x8DF2D1DBDF9F49A\""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"lastModified"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-10-18T13:43:07+00:00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"request_server_encrypted"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;content_md5&lt;/code&gt; and &lt;code&gt;request_server_encrypted&lt;/code&gt; in snake_case. &lt;code&gt;lastModified&lt;/code&gt; in camelCase. In the same object.&lt;/p&gt;

&lt;p&gt;Day 32 found a whole response in snake_case, which was already an exception to the CLI's usual camelCase. This is worse, because there is no convention to learn, not even a per-command one. Sixth variant of this trap in the Azure track, and the fix has not changed: run the command with plain &lt;code&gt;-o json&lt;/code&gt; and read the shape before writing a &lt;code&gt;--query&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Two things from this task I would reuse.&lt;/p&gt;

&lt;p&gt;Verify an upload by downloading it and hashing locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VM:        4221d002ceb5d3c9e9137e495ceaa647
Azure:     QiHQAs6108npE35JXOqmRw==
Download:  4221d002ceb5d3c9e9137e495ceaa647
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The upload response returned &lt;code&gt;content_md5&lt;/code&gt;, but the client computed that digest, so the service reporting it back only confirms the service recorded my own claim. Only the download and local hash close the loop independently.&lt;/p&gt;

&lt;p&gt;And pick the channel by who needs to own the result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-rw-rw-r-- 1 azureuser azureuser 20 Oct 18 13:40 /home/azureuser/testfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run Command runs as root, so a file created that way lands owned by &lt;code&gt;root:root&lt;/code&gt; in &lt;code&gt;/home/azureuser&lt;/code&gt;, which is wrong even with the right content, because &lt;code&gt;azureuser&lt;/code&gt; could not then modify it. SSH as &lt;code&gt;azureuser&lt;/code&gt; produced correct ownership with no &lt;code&gt;chown&lt;/code&gt; step.&lt;/p&gt;

&lt;p&gt;Which is exactly the question Days 84 through 86 kept running into on the Ansible side, where &lt;code&gt;become: yes&lt;/code&gt; meant root owned every file until Day 86 set &lt;code&gt;owner&lt;/code&gt; explicitly. Same decision, two different tools.&lt;/p&gt;

&lt;p&gt;One liability worth naming. The account key was passed over SSH, so it now sits in two shell histories, and anyone holding it has full access to every container in the account with no expiry and no identity in the logs. A managed identity with the Storage Blob Data Contributor role removes the secret from the VM entirely, and rotating the key with &lt;code&gt;az storage account keys renew&lt;/code&gt; is the honest end to any task that has moved one around.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;Both halves kept the thing that matters somewhere other than where I had recorded it.&lt;/p&gt;

&lt;p&gt;blockinfile is the more surprising. A module with a reputation for being safe and repeatable turns out to have no memory at all: its entire record is two comment lines in your file, and anything that disturbs them, a tidy-up, a merge, another task sharing the default marker, makes the next run append a duplicate. Which is fine, as long as you know the comments are load-bearing rather than cosmetic.&lt;/p&gt;

&lt;p&gt;The small embarrassment on that half is that my own verification checked one of three requirements. The content was right. The mode and the owner were never looked at, on any of the three servers, and one &lt;code&gt;ls -la&lt;/code&gt; would have done it.&lt;/p&gt;

&lt;p&gt;The 409 is the more uncomfortable one, because I had written it down as the answer and put it in a table. It is the answer my client got. The documented answer for that condition is a different number, for a different kind of client, and the thing I should have recorded was the mechanism rather than the code.&lt;/p&gt;

&lt;p&gt;Which is twice now that an Azure error code I treated as a fact turned out to be client-dependent. The durable claim in both cases was the one about which layer refused, not the number it refused with.&lt;/p&gt;

&lt;p&gt;So here is the Day 88 question. Which green check or red error in your runbook is written down as a number rather than as the thing the number was telling you?&lt;/p&gt;

&lt;p&gt;Day 88 down. Twelve to go.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>ansible</category>
      <category>azure</category>
      <category>automation</category>
    </item>
    <item>
      <title>Day 87: A Redirected Module and a Renamed Publisher</title>
      <dc:creator>Nnamdi Felix Ibe</dc:creator>
      <pubDate>Thu, 19 Nov 2026 18:00:00 +0000</pubDate>
      <link>https://dev.to/ndcodes/day-87-a-redirected-module-and-a-renamed-publisher-1280</link>
      <guid>https://dev.to/ndcodes/day-87-a-redirected-module-and-a-renamed-publisher-1280</guid>
      <description>&lt;p&gt;Day 87 of DevOps, Day 37 of Azure. Both tasks today turned on a name that is not the name the system uses.&lt;/p&gt;

&lt;p&gt;An Ansible task that says &lt;code&gt;yum&lt;/code&gt; runs the &lt;code&gt;dnf&lt;/code&gt; module, because the first is now a redirect to the second. And an Azure image "published by Jetware" is published by &lt;code&gt;jetware-srl&lt;/code&gt;, which no amount of guessing gets you to.&lt;/p&gt;

&lt;p&gt;One Ansible task, one Azure task. Install and start a service on three servers, then put MySQL on a VM and prove a PHP page can reach it. The tasks come from the KodeKloud Engineer platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 1: Install vsftpd and start it
&lt;/h2&gt;

&lt;p&gt;The task: a playbook that installs &lt;code&gt;vsftpd&lt;/code&gt; on all three app servers and starts it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Check it isn't there
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;tony@stapp01 ~&lt;span class="o"&gt;]&lt;/span&gt;$ sudo systemctl status vsftpd
Unit vsftpd.service could not be found.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same discipline as the last batch, and it is what makes &lt;code&gt;changed: [stapp01]&lt;/code&gt; mean "installed" rather than "already fine".&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: The playbook
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hosts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;all&lt;/span&gt;
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;yes&lt;/span&gt;

  &lt;span class="na"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install vsftpd package.&lt;/span&gt;
      &lt;span class="na"&gt;yum&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;vsftpd&lt;/span&gt;
        &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;present&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Starting the vsftpd service.&lt;/span&gt;
      &lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;vsftpd&lt;/span&gt;
        &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;started&lt;/span&gt;
        &lt;span class="na"&gt;enabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stapp01 : ok=3  changed=2   stapp02 : ok=3  changed=2   stapp03 : ok=3  changed=2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both modules are idempotent, so a second run reports &lt;code&gt;changed=0&lt;/code&gt;. Which, after Day 84's &lt;code&gt;state: touch&lt;/code&gt; reporting a change forever, is worth saying out loud: &lt;code&gt;package&lt;/code&gt; and &lt;code&gt;service&lt;/code&gt; describe a desired state, and a system already in that state needs no action.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;enabled: yes&lt;/code&gt; alongside &lt;code&gt;state: started&lt;/code&gt; is two separate claims, and the verification shows both:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; preset: d&amp;gt;
     Active: active (running) since Sat 2026-05-23 14:43:50 UTC; 11s ago
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;enabled&lt;/code&gt; in the first line means it comes back after a reboot. &lt;code&gt;active (running)&lt;/code&gt; in the second means it is up now. Day 23 made the same point about &lt;code&gt;systemctl enable --now&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: The task says yum and the module is dnf
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ansible.builtin.yum&lt;/code&gt;'s documentation page now says one thing: "This is a redirect to the ansible.builtin.dnf module."&lt;/p&gt;

&lt;p&gt;So what executes is &lt;code&gt;dnf&lt;/code&gt;. The task name says yum, the playbook says yum, and the module doing the work is the dnf module. Which is correct for these servers, because Day 71 established the app servers are CentOS Stream 9, where &lt;code&gt;dnf&lt;/code&gt; is the package manager and &lt;code&gt;yum&lt;/code&gt; is a compatibility name.&lt;/p&gt;

&lt;p&gt;Three things follow, and they pull in different directions.&lt;/p&gt;

&lt;p&gt;The playbook is right as written. The redirect handles it, and nothing needs changing.&lt;/p&gt;

&lt;p&gt;It is misleading to read. Anyone debugging this is reading dnf's documentation whether they know it or not, and the two modules' parameters have not always matched.&lt;/p&gt;

&lt;p&gt;And it is not portable. Both &lt;code&gt;yum&lt;/code&gt; and &lt;code&gt;dnf&lt;/code&gt; commit the playbook to the RHEL family. &lt;code&gt;ansible.builtin.package&lt;/code&gt; dispatches to whatever the target actually uses, so the same playbook runs on Debian hosts too.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;For a lab that names yum, &lt;code&gt;yum&lt;/code&gt; is the right answer. For anything meant to outlive one distribution, &lt;code&gt;package&lt;/code&gt; is the module that does not need rewriting later.&lt;/p&gt;

&lt;p&gt;One other thing worth recording, and it is mildly annoying. The inventory for this task has &lt;code&gt;ansible_ssh_pass&lt;/code&gt; back in it, for all three hosts, in plain text. Day 82's whole task was removing exactly those, and Ansible's documentation says of &lt;code&gt;ansible_password&lt;/code&gt;, "never store this variable in plain text; always use a vault."&lt;/p&gt;

&lt;p&gt;Each lab starts fresh, so the plain-text passwords come back with it. The fix has to be redone every time, which is a reasonable description of security work generally.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 2: MySQL on one VM, PHP on another
&lt;/h2&gt;

&lt;p&gt;The task: a VM from a marketplace Percona image in Central US, a PHP VM in East US, and a page that connects across.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The publisher is not the brand
&lt;/h3&gt;

&lt;p&gt;The task said "published by Jetware".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;az vm image list --all --publisher jetware --location centralus
&lt;span class="o"&gt;(&lt;/span&gt;empty&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What I found was searching on a fragment rather than guessing the whole thing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;az vm image list-publishers --location centralus --query &lt;span class="s2"&gt;"[?contains(name,'etware')].name"&lt;/span&gt; -o tsv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;etware&lt;/code&gt;, without the leading letter, because marketplace publisher names are inconsistently capitalised and both spellings are plausible. The answer is &lt;code&gt;jetware-srl&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Image identity is a four-part URN, and none of the parts are derivable from the product name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jetware-srl : percona_mysql : percona_mysql57-ubuntu-1604 : 1.0.170503
publisher   : offer         : sku                         : version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Day 3 found the same for Canonical's Ubuntu offers, where the lesson was that offer names cannot be guessed. Here the publisher cannot either.&lt;/p&gt;

&lt;p&gt;Which is this morning's Ansible finding wearing different clothes. A module called &lt;code&gt;yum&lt;/code&gt; is a redirect to one called &lt;code&gt;dnf&lt;/code&gt;. A product called Jetware is published by &lt;code&gt;jetware-srl&lt;/code&gt;. Both times the name you are handed is not the name the system uses, and both times the cost of assuming is one lookup you did not do.&lt;/p&gt;

&lt;p&gt;Worth noting the image is from December 2017, on Ubuntu 16.04, with Percona 5.7.17. Marketplace images are frozen at publication, and this one has had no updates in nine years. Fine for a lab, a supply-chain problem anywhere else.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: A denial that told me nothing
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;az vm image terms accept --urn $URN
(AuthorizationFailed) ... does not have authorization to perform action
'...agreements/read'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Marketplace images carry legal terms that must be accepted per subscription before deployment, and the lab identity cannot read or accept them.&lt;/p&gt;

&lt;p&gt;The tempting conclusion is that the image cannot be deployed. That does not follow. The denial is on reading the agreement, which says nothing about whether the agreement is already accepted. My permission to query a setting and the setting's value are independent facts.&lt;/p&gt;

&lt;p&gt;So I tried the create anyway, and it worked. The terms were already accepted for the subscription.&lt;/p&gt;

&lt;p&gt;This is the mirror of my Day 31 mistake, where a quota error left its &lt;code&gt;Location&lt;/code&gt; field blank and I concluded the limit was subscription-wide. Same error, opposite direction: an error about your ability to observe something is not evidence about the thing itself. Attempt the operation when it fails safely.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Three gates, checked separately
&lt;/h3&gt;

&lt;p&gt;Password authentication means no SSH key, so every in-guest operation went through Run Command, which runs as root and returns synchronously.&lt;/p&gt;

&lt;p&gt;A remote MySQL connection has three gates, and all three failures look alike from the PHP side:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Gate&lt;/th&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Azure network&lt;/td&gt;
&lt;td&gt;&lt;code&gt;az network nsg rule list&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;open-port-3306&lt;/code&gt; at 1010&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MySQL user host&lt;/td&gt;
&lt;td&gt;&lt;code&gt;SELECT user,host FROM mysql.user&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;xfusion_user&lt;/code&gt; / &lt;code&gt;%&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MySQL bind address&lt;/td&gt;
&lt;td&gt;&lt;code&gt;SHOW VARIABLES LIKE 'bind_address'&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;*&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The bind address is the one most worth checking, because MySQL defaults to &lt;code&gt;127.0.0.1&lt;/code&gt; in many distributions, and a localhost-only bind defeats a correct NSG rule and a correct &lt;code&gt;%&lt;/code&gt; host with nothing to indicate why. This image binds to &lt;code&gt;*&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Checking all three before touching the PHP file meant a later failure could only be the PHP file.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Two techniques from this task I would reuse, and one thing the task asks for that production should not.&lt;/p&gt;

&lt;p&gt;Base64 for awkward payloads. The SQL contains nested quotes and has to survive the local shell, the Run Command transport and the remote shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SQL_B64&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%s\n'&lt;/span&gt; &lt;span class="s2"&gt;"CREATE USER ... '%' ..."&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; base64 -w 0&lt;span class="o"&gt;)&lt;/span&gt;
az vm run-command invoke ... --scripts &lt;span class="s2"&gt;"echo $SQL_B64 | base64 -d &amp;gt; /tmp/s.sql; /jet/enter mysql &amp;lt; /tmp/s.sql"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Base64 output is only &lt;code&gt;A-Za-z0-9+/=&lt;/code&gt;, none of which any shell reinterprets. The quoting problem is sidestepped rather than solved, which is better.&lt;/p&gt;

&lt;p&gt;And probing an unfamiliar wrapper before scripting against it. &lt;code&gt;/jet/enter mysql&lt;/code&gt; is a Jetware convention and I had no idea whether it took &lt;code&gt;-e&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -la /jet
head -20 /jet/enter
/jet/enter mysql -e &lt;span class="s2"&gt;"SELECT VERSION();"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three cheap commands in one call, answering "does this work" and "if not, what next" at the same time. It turned out to be &lt;code&gt;exec /jet/own/bin/run "$@"&lt;/code&gt;, a thin wrapper that passes everything through.&lt;/p&gt;

&lt;p&gt;The thing production would not do is the architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PHP (eastus)  --public internet--&amp;gt;  MySQL (centralus, port 3306)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;MySQL's wire protocol is not encrypted by default, so credentials cross the internet in the clear. &lt;code&gt;az vm open-port&lt;/code&gt; with no source restriction opens 3306 to &lt;code&gt;0.0.0.0/0&lt;/code&gt;, defended by &lt;code&gt;password123&lt;/code&gt;. And every query pays cross-region latency for no benefit.&lt;/p&gt;

&lt;p&gt;The real shape is both VMs in peered VNets talking over private IPs, the NSG rule scoped to the peer's address space, TLS on the connection, and credentials from Key Vault instead of literals in a PHP file. Or Azure Database for MySQL with a private endpoint and no VM at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;Two names, neither of which was the name.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;yum&lt;/code&gt; is the more interesting one because it is invisible. The playbook works, the output is clean, and the module that ran is not the one written in the file. You only find out by reading a documentation page that contains a single sentence.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;jetware-srl&lt;/code&gt; is the louder version. An empty result from a search is at least a signal that something is wrong, and the fix was searching a fragment instead of a guess.&lt;/p&gt;

&lt;p&gt;The one I would take into real work is the denial. An &lt;code&gt;AuthorizationFailed&lt;/code&gt; on reading the marketplace agreement looks like a wall, and all it says is that I cannot see the answer. The answer happened to be yes. Twice now in this series I have reasoned from the absence of information as though it were information, and twice the one command I had already written would have settled it.&lt;/p&gt;

&lt;p&gt;So here is the Day 87 question. What have you concluded recently from an error that only told you what you were not allowed to look at?&lt;/p&gt;

&lt;p&gt;Day 87 down. Thirteen to go.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>ansible</category>
      <category>azure</category>
      <category>automation</category>
    </item>
    <item>
      <title>Day 86: A Per-Host Variable and an Account-Wide Rule</title>
      <dc:creator>Nnamdi Felix Ibe</dc:creator>
      <pubDate>Wed, 18 Nov 2026 18:00:00 +0000</pubDate>
      <link>https://dev.to/ndcodes/day-86-a-per-host-variable-and-an-account-wide-rule-538c</link>
      <guid>https://dev.to/ndcodes/day-86-a-per-host-variable-and-an-account-wide-rule-538c</guid>
      <description>&lt;p&gt;Day 86 of DevOps, Day 36 of Azure. Both tasks today were about a setting whose scope is not where you wrote it.&lt;/p&gt;

&lt;p&gt;In the Ansible half, that is the feature. One line in a playbook produced three different file owners in a single run, because the value comes from the inventory and the inventory is per host. In the Azure half, it is the hazard. A filter that reads like it names one container is a prefix on a policy that belongs to the entire storage account, and leaving the filter out means the rule deletes everything.&lt;/p&gt;

&lt;p&gt;One Ansible task, one Azure task. Create a file with the right permissions and owner on three servers, then set a lifecycle rule that deletes blobs after seven days. The tasks come from the KodeKloud Engineer platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 1: Three servers, three owners, one line
&lt;/h2&gt;

&lt;p&gt;The task: create &lt;code&gt;/tmp/nfsshare.txt&lt;/code&gt; on all three app servers with mode &lt;code&gt;0644&lt;/code&gt;, owned by that server's own user.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The playbook
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;hosts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;app_servers&lt;/span&gt;
  &lt;span class="na"&gt;become&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;yes&lt;/span&gt;

  &lt;span class="na"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Create empty file with proper permissions&lt;/span&gt;
      &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/tmp/nfsshare.txt&lt;/span&gt;
        &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;touch&lt;/span&gt;
        &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0644'&lt;/span&gt;
        &lt;span class="na"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{ ansible_user }}"&lt;/span&gt;
        &lt;span class="na"&gt;group&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"{{ ansible_user }}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[tony@stapp01 ~]$   -rw-r--r-- 1 tony tony     0 /tmp/nfsshare.txt
[steve@stapp02 ~]$  -rw-r--r-- 1 steve steve   0 /tmp/nfsshare.txt
[banner@stapp03 ~]$ -rw-r--r-- 1 banner banner 0 /tmp/nfsshare.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;{{ ansible_user }}&lt;/code&gt; is the inventory variable from Day 82, read back inside the playbook. The inventory sets it per host, so one line resolves to three different values in one run.&lt;/p&gt;

&lt;p&gt;Which is the clearest argument yet for the separation Day 83 described. The playbook describes the shape of what should exist. The inventory supplies the particulars. Neither file duplicates the other, and adding a fourth server changes one line in one file.&lt;/p&gt;

&lt;p&gt;It also means this playbook only works against an inventory that sets &lt;code&gt;ansible_user&lt;/code&gt; explicitly. A host relying on the default, which is whoever is running &lt;code&gt;ansible-playbook&lt;/code&gt;, has nothing to interpolate, and the task fails with an undefined variable rather than quietly picking something. Worth knowing because that failure happens at template time, not when the file is created.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: This is the day the ownership question gets answered
&lt;/h3&gt;

&lt;p&gt;Days 84 and 85 both created root-owned files, and neither mentioned it. The reason is in the module's defaults: &lt;code&gt;owner&lt;/code&gt; unspecified "uses the current user unless you are root, in which case it can preserve the previous ownership", and a file that did not exist has no previous ownership to preserve. With &lt;code&gt;become: yes&lt;/code&gt;, that is root every time.&lt;/p&gt;

&lt;p&gt;Two lines fix it, and this is the first of the three days to write them.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Three things, and the first I got right for the documented reason.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mode: '0644'&lt;/code&gt; is quoted, which is what the documentation asks for: "For consistent results, quote octal numbers (for example, &lt;code&gt;'644'&lt;/code&gt; or &lt;code&gt;'1777'&lt;/code&gt;) so Ansible receives a string and can do its own conversion from string into number."&lt;/p&gt;

&lt;p&gt;The warning attached to it is about the unquoted form: "Adding a leading zero (for example, &lt;code&gt;0755&lt;/code&gt;) works sometimes, but can fail in loops and some other circumstances." Quoted, the leading zero is harmless. Unquoted, YAML gets to decide what &lt;code&gt;0644&lt;/code&gt; means, and that is the failure being described.&lt;/p&gt;

&lt;p&gt;The second is an assumption the playbook makes and does not state. &lt;code&gt;group: "{{ ansible_user }}"&lt;/code&gt; asks for a group named &lt;code&gt;tony&lt;/code&gt;, &lt;code&gt;steve&lt;/code&gt; and &lt;code&gt;banner&lt;/code&gt;. All three existed, so it worked, and that is a property of how those accounts were created rather than anything the playbook establishes. A new user on a RHEL-family system gets a private group of the same name by default, which is why the listing shows &lt;code&gt;tony tony&lt;/code&gt;. On a system where users share a group such as &lt;code&gt;users&lt;/code&gt;, this same playbook succeeds on the owner and fails on the group.&lt;/p&gt;

&lt;p&gt;The task's wording, that ownership and group "must be that of the users of the respective app-servers", reads as one requirement and is two lookups against two different databases. Omitting &lt;code&gt;group&lt;/code&gt; entirely is closer to what it means, because the system then resolves the user's actual primary group whatever it happens to be called.&lt;/p&gt;

&lt;p&gt;Third, this playbook is still not idempotent, and now for exactly one reason. &lt;code&gt;mode&lt;/code&gt;, &lt;code&gt;owner&lt;/code&gt; and &lt;code&gt;group&lt;/code&gt; are comparisons: the module reads the current value and reports a change only if it differs, so all three settle after the first run. &lt;code&gt;state: touch&lt;/code&gt; defaults both timestamps to &lt;code&gt;now&lt;/code&gt;, as Day 84 covered, so a second run reports &lt;code&gt;changed=1&lt;/code&gt; on all three hosts and the only thing that changed is two timestamps nobody asked about.&lt;/p&gt;

&lt;p&gt;Three days, three playbooks, and the pattern is clear enough to state. &lt;code&gt;file&lt;/code&gt; is the only module in this batch that is not idempotent by default, and it is the one I used twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Task 2: A rule that deletes blobs after seven days
&lt;/h2&gt;

&lt;p&gt;The task: a lifecycle rule on a container, deleting blobs seven days after their last modification.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: There is no such thing as a rule on a container
&lt;/h3&gt;

&lt;p&gt;Azure has one management policy per storage account. Container scoping happens inside the rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"filters"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"blobTypes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"blockBlob"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"prefixMatch"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"nautilus-container21738529"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;prefixMatch&lt;/code&gt; is a blob path prefix, and because a blob's full path begins with its container name, the container name alone scopes the rule to that container. More specific prefixes work too, so adding &lt;code&gt;/logs/&lt;/code&gt; would hit only that virtual folder, which is the flat-namespace behaviour from Day 18.&lt;/p&gt;

&lt;p&gt;Leave &lt;code&gt;prefixMatch&lt;/code&gt; out, and the rule applies to every blob in the account. For a delete action, that is the difference between tidying one container and emptying a storage account on a seven-day rolling basis.&lt;/p&gt;

&lt;p&gt;Which is the Ansible half inverted. There, one line resolving differently per host is the feature. Here, a filter that looks like it names a container is a prefix on an account-wide policy, and the scope is wider than the place you wrote it.&lt;/p&gt;

&lt;p&gt;Azure's own documentation signals this trips people up without explaining the mechanism. The configuration page's only mention of prefixes is a link to an FAQ entry named for the symptom: "The blob prefix match string didn't apply the policy to the expected blobs".&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: The policy replaces, and that is the service
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;az storage account management-policy create --account-name &lt;span class="nv"&gt;$SA&lt;/span&gt; -g &lt;span class="nv"&gt;$RG&lt;/span&gt; --policy &lt;span class="s1"&gt;'{"rules":[...]}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;create&lt;/code&gt; sets the entire policy. I had written this up as CLI behaviour, and it is stated more strongly than that, as a property of the service: "You must read or write a lifecycle management policy in full. The service doesn't support partial updates."&lt;/p&gt;

&lt;p&gt;So adding a second rule later means reading the current policy, appending to its &lt;code&gt;rules&lt;/code&gt; array, and writing the whole thing back. Running &lt;code&gt;create&lt;/code&gt; again with just the new rule silently removes the first one.&lt;/p&gt;

&lt;p&gt;Third instance of the same pattern in this challenge:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Day&lt;/th&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;Replaces&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;&lt;code&gt;az resource tag&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All tags&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AWS 46&lt;/td&gt;
&lt;td&gt;&lt;code&gt;put-bucket-notification-configuration&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All notifications&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;36&lt;/td&gt;
&lt;td&gt;&lt;code&gt;management-policy create&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;All lifecycle rules&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 3: Modification is not creation
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Condition&lt;/th&gt;
&lt;th&gt;Clock starts at&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;daysAfterModificationGreaterThan&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Last write to the blob&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;daysAfterCreationGreaterThan&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Blob creation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The task said "7 days of last modification", so the first. They diverge for anything rewritten: a blob overwritten weekly never ages past seven days under the modification rule, and would be deleted on schedule under the creation rule. For a retention policy, that distinction decides whether active data survives.&lt;/p&gt;

&lt;p&gt;Worth adding that delete is not the only action available. &lt;code&gt;tierToCool&lt;/code&gt;, &lt;code&gt;tierToCold&lt;/code&gt; and &lt;code&gt;tierToArchive&lt;/code&gt; move blobs to cheaper storage rather than destroying them, which is usually the better first move if the goal is cost. This task asked for deletion.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the docs recommend
&lt;/h3&gt;

&lt;p&gt;Here is the thing I cannot do, and would rather say than imply otherwise.&lt;/p&gt;

&lt;p&gt;"Azure Storage runs the policy once per day", and the blob is seven days from being eligible. So there is no way to observe this rule working inside a one-hour lab, or any reasonable session.&lt;/p&gt;

&lt;p&gt;Which makes this a genuine exception to the rule these notes keep arriving at. Day 28 failed because behaviour was proven and the configuration was wrong. Day 38 failed because the configuration was right and behaviour was never tested. The resolution both times was to check both.&lt;/p&gt;

&lt;p&gt;Here behaviour is unobservable on a human timescale. So verification was configuration only, read back from the service rather than trusting the create response, with each requirement pulled out as its own field so a missing one is visible:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"Name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"nautilus-del-rule"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Enabled"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"DeleteAfterDays"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;7.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"Prefix"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"nautilus-container21738529"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"BlobTypes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"blockBlob"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Saying "the rule works" would be an inference dressed as a result. What would strengthen it in a real environment is the lifecycle management log category, which records what each rule matched and deleted on each run.&lt;/p&gt;

&lt;p&gt;Two smaller findings. &lt;code&gt;DeleteAfterDays&lt;/code&gt; came back as &lt;code&gt;7.0&lt;/code&gt; having been sent as &lt;code&gt;7&lt;/code&gt;, because the API models it as a number rather than an integer, so a scripted check needs a numeric comparison and not a string one. And two claims from my own notes I could not source this time, so they are marked unverified rather than repeated: that the first run after a policy change can take up to 48 hours, and that lifecycle management requires a &lt;code&gt;StorageV2&lt;/code&gt; account.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;Scope, twice, pointing in opposite directions.&lt;/p&gt;

&lt;p&gt;The Ansible playbook is the version where this works for you. One line, three results, because the value lives in the inventory and the inventory knows about hosts. That is a tool designed so the thing you write once stays written once.&lt;/p&gt;

&lt;p&gt;The Azure rule is the version where it works against you. The task says container, the resource is an account, and the only thing standing between "delete blobs in this container" and "delete everything in this storage account" is a filter that is easy to leave out and that the documentation barely explains. It runs once a day, it does not ask, and if soft delete is off, which is the default, there is no undo.&lt;/p&gt;

&lt;p&gt;And the honest part of today is the bit I could not finish. The rule's configuration is verified exhaustively, and its behaviour is not verified at all, because nobody can watch a seven-day timer in a one-hour lab. Every other day in this series ends with a check that something actually happened. This one ends with a careful description of what was configured and a sentence saying which kind of check was possible.&lt;/p&gt;

&lt;p&gt;So here is the Day 86 question. Which of your scheduled deletion rules has anyone watched actually run?&lt;/p&gt;

&lt;p&gt;Day 86 down. Fourteen to go.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>ansible</category>
      <category>azure</category>
      <category>automation</category>
    </item>
    <item>
      <title>Part 6: The Walkthrough That Only Worked on My Machine</title>
      <dc:creator>Nnamdi Felix Ibe</dc:creator>
      <pubDate>Wed, 18 Nov 2026 06:43:15 +0000</pubDate>
      <link>https://dev.to/ndcodes/part-6-the-walkthrough-that-only-worked-on-my-machine-15e8</link>
      <guid>https://dev.to/ndcodes/part-6-the-walkthrough-that-only-worked-on-my-machine-15e8</guid>
      <description>&lt;p&gt;This is Part 6 of a series building an HL7 v2-to-FHIR R4 interoperability service in public. The repository is &lt;a href="https://github.com/ND-codes/nhs-interop-platform" rel="noopener noreferrer"&gt;ND-codes/nhs-interop-platform&lt;/a&gt;,&lt;br&gt;
and the code as it stood for this article is tagged &lt;code&gt;part-6&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This week's plan was a ten-minute tour of the repository and the questions an interviewer asks about it. Before writing the tour, I did the obvious thing and followed the one I already had.&lt;/p&gt;

&lt;p&gt;It doesn't work on a machine that isn't mine. Not in a subtle way.&lt;/p&gt;
&lt;h2&gt;
  
  
  A walkthrough is a promise
&lt;/h2&gt;

&lt;p&gt;Most of what a repository claims is hard to check. A threat model, an&lt;br&gt;
architecture diagram, a note about scaling: a reader takes those on trust or not at all.&lt;/p&gt;

&lt;p&gt;A quickstart is different. It is a sequence of commands with stated outcomes, and the reader finds out within minutes whether you were telling the truth. It is the most falsifiable document in the repository and usually the least tested, because the author is the one person who can never run it fresh.&lt;/p&gt;

&lt;p&gt;Mine had four failures. Three of them break on the reader's machine and work perfectly on mine. The fourth was not about machines at all.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;make test&lt;/code&gt; could not run outside Git Bash
&lt;/h2&gt;

&lt;p&gt;Step 7 of my quickstart said &lt;code&gt;make test&lt;/code&gt;. The recipe:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight make"&gt;&lt;code&gt;docker run --rm -v &lt;span class="s2"&gt;"$$(cygpath -m $$(cd services/$$svc &amp;amp;&amp;amp; pwd))"&lt;/span&gt;:/app -w //app python:3.12-slim \
  sh -c &lt;span class="s2"&gt;"pip install -q -r requirements-dev.txt &amp;amp;&amp;amp; pytest -q"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;cygpath&lt;/code&gt; converts a Windows path into the &lt;code&gt;C:/&lt;/code&gt; form Docker wants. It exists&lt;br&gt;
in Git Bash on Windows and nowhere else. On macOS or Linux that line is&lt;br&gt;
&lt;code&gt;cygpath: command not found&lt;/code&gt;, and &lt;code&gt;make test&lt;/code&gt; and &lt;code&gt;make lint&lt;/code&gt; both die on the&lt;br&gt;
first service.&lt;/p&gt;

&lt;p&gt;I work in Git Bash on Windows. It had never once failed for me, which is the entire problem.&lt;/p&gt;

&lt;p&gt;The fix keeps the Windows behaviour exactly and adds the other path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;abs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; services/&lt;span class="nv"&gt;$svc&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;wd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/app &lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;command&lt;/span&gt; -v cygpath &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null 2&lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;1 &lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; &lt;span class="nv"&gt;abs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;cygpath -m &lt;span class="s2"&gt;"$abs"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;wd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;//app &lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt;
docker run --rm -v &lt;span class="s2"&gt;"$abs"&lt;/span&gt;:/app -w &lt;span class="s2"&gt;"$wd"&lt;/span&gt; python:3.12-slim ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The doubled &lt;code&gt;//app&lt;/code&gt; is the other half of the same problem. MSYS rewrites a leading &lt;code&gt;/app&lt;/code&gt; into a Windows path, so Git Bash needs it doubled and nothing else does. Both branches were tested, the second by putting a fake &lt;code&gt;cygpath&lt;/code&gt; on &lt;code&gt;PATH&lt;/code&gt;. Then the Git Bash branch ran for real on my machine: 92 tests, all&lt;br&gt;
passing.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;make integration&lt;/code&gt; installed into the system interpreter
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight make"&gt;&lt;code&gt;python3 -m pip install --quiet httpx pytest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;On Debian, Ubuntu and Homebrew Python 3.11 and later, that is refused outright. PEP 668 lets a distribution mark its base interpreter as externally managed, and pip then declines with &lt;code&gt;error: externally-managed-environment&lt;/code&gt;. It works on my machine because my Python is not marked that way.&lt;/p&gt;

&lt;p&gt;It builds a throwaway virtualenv now, with a &lt;code&gt;bin&lt;/code&gt; and &lt;code&gt;Scripts&lt;/code&gt; fallback so the same line works in Git Bash.&lt;/p&gt;
&lt;h2&gt;
  
  
  A file the quickstart told you to copy did not exist
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cp terraform.tfvars.example terraform.tfvars
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;There was no &lt;code&gt;terraform.tfvars.example&lt;/code&gt;. There never had been. You only find that by following your own instructions as though you had not written them.&lt;/p&gt;
&lt;h2&gt;
  
  
  The alert that reached nobody
&lt;/h2&gt;

&lt;p&gt;The fourth is the one worth the article, and I did not find it. Nan, a reader of Part 4, did.&lt;/p&gt;

&lt;p&gt;Part 4 was about an alert that could never fire, because it watched a metric no service exported. I fixed that, exported the gauge, wrote the rule unit tests, added the runbook sections, and built scripts to open the circuit breaker on purpose so you could watch &lt;code&gt;PDSCircuitOpen&lt;/code&gt; go Firing.&lt;/p&gt;

&lt;p&gt;Nan's question was roughly: and then who gets told?&lt;/p&gt;

&lt;p&gt;Nobody. Here is the whole chain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;observability/alertmanager/alertmanager.yml&lt;/code&gt; exists, and is a reasonable config. It routes by severity, groups by alertname and service, and has an inhibit rule.&lt;/li&gt;
&lt;li&gt;Nothing starts an Alertmanager. There is no such service in Docker Compose and no such manifest anywhere in &lt;code&gt;k8s/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;prometheus.yml&lt;/code&gt; had no &lt;code&gt;alerting&lt;/code&gt; block, so even if one had been running, Prometheus did not know where it was.&lt;/li&gt;
&lt;li&gt;That config's &lt;code&gt;smtp_smarthost&lt;/code&gt; pointed at &lt;code&gt;mailhog:1025&lt;/code&gt;. No file in the repository has ever started a mailhog.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the rules evaluated, turned red in the Prometheus UI, and stopped there.&lt;br&gt;
Meanwhile &lt;code&gt;docs/architecture.md&lt;/code&gt; said "Alertmanager routes pages" and the runbook's prerequisites told the on-call engineer they would need access to "the alerts Slack/PagerDuty queue".&lt;/p&gt;

&lt;p&gt;Part 4 made the alert fireable. Part 5 made the documentation honest about the controls. Neither of us noticed that the last hop did not exist, and it is the hop that makes the other two matter. An alert nobody receives is a dashboard.&lt;/p&gt;

&lt;p&gt;The fix is small, which is the irritating part:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;alerting&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;alertmanagers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;static_configs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'alertmanager:9093'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Plus two services in Compose. Alertmanager and Mailpit as the destination: a disposable SMTP sink with a web inbox, which holds mail in memory and forwards it nowhere. That is what makes it safe to point a demo at. I used Mailpit rather than the MailHog the old config named, because MailHog has not been released since 2020 and Part 5 was about not shipping things you would not defend.&lt;/p&gt;

&lt;p&gt;Now &lt;code&gt;make break-pds&lt;/code&gt; opens the breaker, &lt;code&gt;PDSCircuitOpen&lt;/code&gt; goes Firing about two minutes later, and the notification arrives at a web inbox on port 8025 where you can read it. The whole path, end to end, is a demo you can run on a laptop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhjcxf9vspxmzgf2knp6x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhjcxf9vspxmzgf2knp6x.png" alt="Prometheus alerts page showing PDSCircuitOpen in the Firing state, with the rule expression pybreaker_state equals 1 for 2 minutes, its runbook link and summary" width="800" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcr1clrsi0truaijavn5j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcr1clrsi0truaijavn5j.png" alt="Mailpit inbox with four alert emails, two PDSCircuitOpen and two IngestNoTraffic, and the newest PDSCircuitOpen email open showing its labels, runbook link and summary" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I ran it on 17 November, and again this morning for the screenshots. The subject line began &lt;code&gt;[FIRING:1] PDSCircuitOpen transform&lt;/code&gt;. Six parts in, it is the first alert this project has ever delivered to anything.&lt;/p&gt;

&lt;p&gt;The inbox also holds two &lt;code&gt;IngestNoTraffic&lt;/code&gt; alerts I did not ask for. I checked the rule in &lt;code&gt;alerts.yml&lt;/code&gt; before calling it a fault: it fires once ingest has gone 15 minutes without an HL7 message, and the stack sat idle overnight. So it is expected, but a demo stack left running will email you about its own quiet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making the tour testable
&lt;/h2&gt;

&lt;p&gt;The underlying failure is that a quickstart is prose, and prose does not run in CI. So the tour is now a script, and &lt;code&gt;make walkthrough&lt;/code&gt; runs it.&lt;/p&gt;

&lt;p&gt;Eight checks. The stack is up, ingest accepts an ADT, the Patient reaches FHIR keyed on the NHS number, a lab result produces Observations, Prometheus is scraping every service, Prometheus has discovered an Alertmanager, Alertmanager is healthy, and the inbox is reachable. Each one fails loudly and stops.&lt;/p&gt;

&lt;p&gt;The sixth is the one that would have caught Nan's finding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;discovered&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;curl -sf &lt;span class="s2"&gt;"$PROM/api/v1/alertmanagers"&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; python3 -c &lt;span class="s1"&gt;'import json,sys; print(len(json.load(sys.stdin)["data"]["activeAlertmanagers"]))'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$discovered"&lt;/span&gt; -ge 1 &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; fail &lt;span class="s2"&gt;"Prometheus has no active Alertmanager."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two small things I would do again. The FHIR checks parse the Bundle rather than grepping for &lt;code&gt;"total"&lt;/code&gt;, because the whitespace is not guaranteed and a grep for that string also matches a zero. And the Mailpit check asserts reachability but reads the message count defensively, because I could not get Mailpit's API documentation to load and I was not willing to assert a field name I had not seen. A schema change should not turn a working inbox into a failed tour.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tour failed its own first run
&lt;/h2&gt;

&lt;p&gt;The script was written and checked without a Docker daemon. The first time it ran against a real stack, it stopped at check 3:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[3/8] The Patient reaches FHIR, keyed on the NHS number
      FAIL the Patient did not become true within 30s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Patient was there. Asking HAPI for a count returned one. The query was the problem. A FHIR token search separates system and code with a pipe,&lt;br&gt;
&lt;code&gt;identifier=https://fhir.nhs.uk/Id/nhs-number|9000000009&lt;/code&gt;, and RFC 3986 does&lt;br&gt;
not allow an unencoded &lt;code&gt;|&lt;/code&gt; in a query string. HAPI runs on Tomcat, which enforces that by default and answers HTTP 400.&lt;/p&gt;

&lt;p&gt;The 400 never reached the screen. &lt;code&gt;curl -sf&lt;/code&gt; turns any HTTP error into a silent non-zero exit, and the retry loop read that as "not there yet". Thirty seconds later it reported a missing Patient that was never missing.&lt;/p&gt;

&lt;p&gt;The fix is &lt;code&gt;%7C&lt;/code&gt; in place of the pipe, in the script and in the quickstart. The quickstart needed it too: Tomcat's own documentation says the major browsers send that character unencoded, so the link would have failed in a browser as well.&lt;/p&gt;

&lt;p&gt;This is the alert story again, at a smaller scale. A check that cannot tell "not found" from "you asked the wrong way" will pass or fail for the wrong reason, and you only find out by running it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fls1d8v825s82anxk3mj0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fls1d8v825s82anxk3mj0.png" alt="Terminal output of make walkthrough with all eight checks reporting ok, including check 3 finding the Patient at a URL with the pipe encoded as %7C" width="800" height="576"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Four things the architecture document still claimed
&lt;/h2&gt;

&lt;p&gt;While I was at it. &lt;code&gt;docs/architecture.md&lt;/code&gt; said messages are dead-lettered to S3, which Part 5 established is false. It said GitLab CI gates quality, two weeks after we deleted &lt;code&gt;.gitlab-ci.yml&lt;/code&gt;. It said CI pushes to an image registry, which it does not, because there is nowhere to push to. And it said "every request is traced", when what actually exists is a trace id carried in log lines. That is correlation, not distributed tracing, and there is no OpenTelemetry in any of these services.&lt;/p&gt;

&lt;p&gt;All four are corrected in place, with a short note saying what each one used to claim. Quietly editing them would have been tidier and worse.&lt;/p&gt;

&lt;h2&gt;
  
  
  The questions an interviewer actually asks
&lt;/h2&gt;

&lt;p&gt;This is the other half of what Part 6 was meant to cover, and the walkthrough work made it easier rather than harder, because the questions people ask about a system are mostly the ones a broken walkthrough exposes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Walk me through what happens to a message.
&lt;/h3&gt;

&lt;p&gt;It arrives at &lt;code&gt;POST /hl7&lt;/code&gt; on ingest, which validates the MSH segment and assigns a trace id. Transform parses it, maps it to a FHIR R4 transaction Bundle, optionally enriches the Patient from PDS, and writes the Bundle to HAPI FHIR with a conditional update keyed on the NHS number. Failures dead-letter to a local path. The trace id&lt;br&gt;
follows the message through all three services.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens when PDS is down?
&lt;/h3&gt;

&lt;p&gt;Enrichment fails open. A circuit breaker&lt;br&gt;
opens after five consecutive failures, and the pipeline keeps writing Patients with locally derived demographics. Data quality degrades; no clinical message is dropped. That is a deliberate trade-off and it is the seventh Caldicott principle in practice, the one that says the duty to share can matter as much as the duty to protect. You can watch it with &lt;code&gt;make break-pds&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Who gets paged?
&lt;/h3&gt;

&lt;p&gt;Until this week, nobody, and I would say exactly that. The&lt;br&gt;
rules evaluated and notified no one. It is fixed for the local stack and still missing in Kubernetes. A question like this is a gift, because the honest answer is more interesting than the tidy one.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do you know the mapping is correct?
&lt;/h3&gt;

&lt;p&gt;Unit tests per defect, each written to fail against the previous code. Part 3 covers nine specific ways an HL7 v2 to FHIR mapping goes wrong, most of them found by readers. The honest limit is that there is no conformance suite and no validation against the HL7 v2 to FHIR&lt;br&gt;
implementation guide; the tests encode the defects we know about.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where does patient data live and for how long?
&lt;/h3&gt;

&lt;p&gt;Mapped fields in HAPI FHIR on Postgres. Complete raw messages in the dead-letter path, which holds more patient data than the FHIR store does, for up to 72 hours. That retention is new as of Part 5 and the path still does not survive a pod restart.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the worst bug you have shipped here?
&lt;/h3&gt;

&lt;p&gt;Part 4's fix for the alert that could never fire. The circuit breaker was applied as a decorator to a coroutine function, so it counted the returned coroutine object as a success and never opened, which means the gauge I had just added and the alert I had just made fireable still could not fire. The test passed because it drove the breaker synchronously. I found it by running the stack.&lt;/p&gt;

&lt;h3&gt;
  
  
  How would you scale it?
&lt;/h3&gt;

&lt;p&gt;The ingest-to-transform hop is synchronous HTTP,&lt;br&gt;
which keeps the local demo one command and is the first thing I would replace with an SQS FIFO queue using the NHS number as the message group id so a patient's messages stay ordered. Beyond that the services are stateless and scale horizontally; the bottleneck is the FHIR write path.&lt;/p&gt;

&lt;h3&gt;
  
  
  What would you do differently?
&lt;/h3&gt;

&lt;p&gt;Wrote the documentation last. Almost every false claim in this repository was true of the design at the moment it was&lt;br&gt;
written and never revisited.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I did not fix
&lt;/h2&gt;

&lt;p&gt;There is still no Alertmanager in the Helm charts, so the Kubernetes path notifies nobody. I did not write one, because I cannot deploy a cluster to test it and shipping untested YAML two days before publishing is the exact thing Part 5 was about. It is in the "Claimed, not built" section of &lt;code&gt;docs/security.md&lt;/code&gt; and a roadmap issue.&lt;/p&gt;

&lt;p&gt;There is no paging integration anywhere. The Alertmanager config has a PagerDuty receiver commented out and has never been pointed at a routing key.&lt;/p&gt;

&lt;p&gt;Correction: an earlier version of this paragraph said&lt;br&gt;
&lt;code&gt;make restore-pds&lt;/code&gt; does not clear the alert and that the script should send a message. It already does. It waits out the 30-second reset timeout and sends three synthetic messages, and has since Part 4. I described the script from what I saw on the dashboard instead of reading it.&lt;/p&gt;

&lt;p&gt;The real gap is the other end. Alertmanager's email receiver does not send a resolved notification unless you ask it to; &lt;code&gt;send_resolved&lt;/code&gt; defaults to false for email, though it defaults to true for webhooks and PagerDuty. So the inbox tells you an incident started and never tells you it ended. That is next week's pull request.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq0a90i5nogulu7ywfbil.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq0a90i5nogulu7ywfbil.png" alt="Grafana PDS circuit breaker panel holding at 1, open, for about seven minutes before dropping back to 0" width="800" height="138"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The retry loop still hides the status code. The pipe is fixed, but the next malformed query would fail the same silent way.&lt;/p&gt;

&lt;p&gt;And I have not timed the tour on a second machine. The series plan called this part a ten-minute walkthrough; the document now says the figure should be yours rather than mine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Worth stealing
&lt;/h2&gt;

&lt;p&gt;Run your own quickstart on a machine you did not configure. A colleague's, a fresh VM, a container. The author is the one person who cannot test it.&lt;/p&gt;

&lt;p&gt;Grep your build tooling for anything platform-specific. &lt;code&gt;cygpath&lt;/code&gt;, &lt;code&gt;open&lt;/code&gt;, &lt;code&gt;sed -i&lt;/code&gt; with a bare &lt;code&gt;-i&lt;/code&gt;, &lt;code&gt;realpath&lt;/code&gt;, &lt;code&gt;date -d&lt;/code&gt;. Each one quietly scopes your repository to one operating system.&lt;/p&gt;

&lt;p&gt;Make the tour a target. Prose cannot run in CI; a script can, and then the document and the repository cannot drift apart silently.&lt;/p&gt;

&lt;p&gt;Check the last hop of anything that is supposed to tell a human. Working alert rules that notify nobody look identical to working alerting from inside the repository.&lt;/p&gt;

&lt;p&gt;Correct a stale claim in place, with a line saying what it used to say. The&lt;br&gt;
edit history is not where a reader looks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where AI helps here, and where it doesn't
&lt;/h2&gt;

&lt;p&gt;I built this with Claude Code, and this week drew the line unusually clearly.&lt;/p&gt;

&lt;p&gt;Reading the Makefile and noticing that &lt;code&gt;cygpath&lt;/code&gt; is Git Bash only is exactly the kind of thing it is good at. So is knowing that PEP 668 would refuse the pip line, and checking &lt;code&gt;terraform.tfvars.example&lt;/code&gt; against the variables that are actually declared. That sweep took minutes, and I would not have done it by hand two days before publishing.&lt;/p&gt;

&lt;p&gt;But none of that is the same as running the thing. It wrote and checked this week's changes in a sandbox with no Docker daemon, so "works on my machine" problems were invisible to it by construction. It found the &lt;code&gt;cygpath&lt;/code&gt; problem by reading, after I pointed it at the walkthrough, which is not the same as the problem announcing itself.&lt;/p&gt;

&lt;p&gt;The walkthrough script is the clearest example. It was reviewed, shellchecked and clean, and it failed its first real run on a URL encoding rule. Once the stack was up on my machine, the same assistant ran the query directly, found the 400 in about a minute, and checked the fix against the RFC and Tomcat's documentation. Reading wrote the bug. Running found it.&lt;/p&gt;

&lt;p&gt;The alert delivery gap is the sharper case. It was not found by reading at all, by a model or by me. Nan found it by asking the one question neither of us had: and then who gets told? Two articles in a row went past it while looking directly at the alerting configuration.&lt;/p&gt;

&lt;p&gt;The pattern I would now state plainly, three weeks running: reading finds inconsistencies, running finds defects, and other people find the questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://peps.python.org/pep-0668/" rel="noopener noreferrer"&gt;PEP 668&lt;/a&gt;, on externally managed Python environments&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/" rel="noopener noreferrer"&gt;Prometheus configuration&lt;/a&gt;, for the top-level &lt;code&gt;alerting&lt;/code&gt; block&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://prometheus.io/docs/prometheus/latest/querying/api/" rel="noopener noreferrer"&gt;Prometheus HTTP API&lt;/a&gt;, for the &lt;code&gt;/api/v1/alertmanagers&lt;/code&gt; response shape&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.rfc-editor.org/rfc/rfc3986#section-3.4" rel="noopener noreferrer"&gt;RFC 3986, section 3.4&lt;/a&gt;, the characters allowed in a URI query&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://tomcat.apache.org/tomcat-10.1-doc/config/http.html" rel="noopener noreferrer"&gt;Apache Tomcat HTTP connector&lt;/a&gt;, &lt;code&gt;relaxedQueryChars&lt;/code&gt; and the characters rejected by default&lt;/li&gt;
&lt;li&gt;&lt;a href="https://mailpit.axllent.org/docs/install/docker/" rel="noopener noreferrer"&gt;Mailpit, Docker install&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.gov.uk/government/publications/the-caldicott-principles" rel="noopener noreferrer"&gt;The Caldicott Principles&lt;/a&gt;, National Data Guardian&lt;/li&gt;
&lt;li&gt;Alertmanager and Prometheus configurations in this article were validated with &lt;code&gt;amtool check-config&lt;/code&gt; 0.34.1 and &lt;code&gt;promtool check config&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;[Alertmanager configuration (&lt;a href="https://prometheus.io/docs/alerting/latest/configuration/" rel="noopener noreferrer"&gt;https://prometheus.io/docs/alerting/latest/configuration/&lt;/a&gt;), for the &lt;code&gt;send_resolved&lt;/code&gt; defaults&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Next
&lt;/h2&gt;

&lt;p&gt;Part 7 is the last one: where AI fits in this work and where it does not, with seven weeks of specifics rather than opinions.&lt;/p&gt;

&lt;p&gt;If you have a quickstart in a repository you maintain, run it somewhere else this week. What broke first?&lt;/p&gt;




&lt;p&gt;This is a personal project. It is not affiliated with or endorsed by NHS England or any NHS organisation. It uses the public PDS FHIR sandbox and synthetic test data only. Views are my own.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>ai</category>
      <category>programming</category>
      <category>career</category>
    </item>
  </channel>
</rss>
