Day 88 of DevOps, Day 38 of Azure. Both tasks today put the thing that matters somewhere other than where I had recorded it.
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.
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.
Task 1: A block of content in a web page
The task: install httpd, start it, and write a block into /var/www/html/index.html with mode 0777 owned by apache.
- name: Using the blockinfile module. ansible.builtin.blockinfile: path: /var/www/html/index.html create: yes block: | Welcome to XfusionCorp! This is Nautilus sample file, created using Ansible! Please do not modify this file manually! mode: '0777' owner: "apache" group: "apache" Step 1: The markers are the state
[tony@stapp01 ~]$ cat /var/www/html/index.html # BEGIN ANSIBLE MANAGED BLOCK Welcome to XfusionCorp! ... # END ANSIBLE MANAGED BLOCK Those two comment lines are the whole reason this task is idempotent. The default marker is "# {mark} ANSIBLE MANAGED BLOCK", with marker_begin defaulting to BEGIN and marker_end to END. On the next run the module looks for those lines, finds the block between them, compares it to what the playbook says, and reports ok if they match.
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.
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 {mark} in it does the same thing, because the begin and end lines become identical.
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.
Worth setting against the rest of this fortnight, because blockinfile is the well-behaved one. Day 85's file: state=touch reports a change on every run because its timestamps default to now. Day 91's copy plus lineinfile pair actively undoes its own work. This module is idempotent, and the mechanism is visible in the file rather than hidden in the module.
create: yes was necessary rather than defensive, by the way. The parameter "defaults to false", and the before-check showed the file was absent, so without it the task would have failed on a missing path.
Step 2: The recap told me something I had not checked
TASK [Install httpd package.] *************** ok: [stapp01] TASK [Starting the httpd service.] *************** ok: [stapp01] TASK [Using the blockinfile module.] *************** changed: [stapp01] Two ok and one changed.
My before-check was cat /var/www/html/index.html, which came back "No such file or directory". That tested the file. It did not test the package.
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 ok. Day 91's run of a nearly identical playbook shows both as changed, because that lab had no httpd. Same tasks, two labs, and the recap distinguishes them with nothing added.
Which is worth drawing out, because a recap that is all changed 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.
What the docs recommend
Two things, and the first is the task's own fault rather than mine.
0777 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.
For a static page that Apache reads, 0644 owned by apache is sufficient, and 0444 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 0777, so the playbook is right, and it is worth knowing what was asked for.
The second is mine. My verification was cat on the file, and that is it. The task named three things: the content, the mode, and the ownership. I checked one.
ls -la /var/www/html/index.html # expect -rwxrwxrwx 1 apache apache 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.
Task 2: A file from a VM into a private container
The task: a storage account, a private blob container, and a file uploaded into it from a VM using the account key.
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.
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.
Step 1: The code I got wrong
anon_list=409 anon_blob=409 Days 17 and 19 recorded 404 for an anonymous request to a private container, on accounts where allowBlobPublicAccess was true. Here the account switch is false and curl got 409 with PublicAccessNotPermitted.
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:
"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)."
403, with a qualifier that does the work: it applies to clients using the anonymous bearer challenge. curl is not one. So the 409 I saw is real for that client and is not the number in the documentation.
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.
The honest version:
| Account setting | Container | Observed with curl | Documented |
|---|---|---|---|
| allows | private | 404 | not stated |
| allows | container | 200 | 200 |
| disallows | anything | 409 | 403 for bearer-challenge clients |
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".
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 Authorization 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.
Which pairs with the morning more neatly than I expected. inactive (dead) 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.
Step 2: Field names with no convention at all
{ "content_md5": "QiHQAs6108npE35JXOqmRw==", "etag": "\"0x8DF2D1DBDF9F49A\"", "lastModified": "2026-10-18T13:43:07+00:00", "request_server_encrypted": true } content_md5 and request_server_encrypted in snake_case. lastModified in camelCase. In the same object.
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 -o json and read the shape before writing a --query.
What the docs recommend
Two things from this task I would reuse.
Verify an upload by downloading it and hashing locally:
VM: 4221d002ceb5d3c9e9137e495ceaa647 Azure: QiHQAs6108npE35JXOqmRw== Download: 4221d002ceb5d3c9e9137e495ceaa647 The upload response returned content_md5, 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.
And pick the channel by who needs to own the result:
-rw-rw-r-- 1 azureuser azureuser 20 Oct 18 13:40 /home/azureuser/testfile.txt Run Command runs as root, so a file created that way lands owned by root:root in /home/azureuser, which is wrong even with the right content, because azureuser could not then modify it. SSH as azureuser produced correct ownership with no chown step.
Which is exactly the question Days 84 through 86 kept running into on the Ansible side, where become: yes meant root owned every file until Day 86 set owner explicitly. Same decision, two different tools.
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 az storage account keys renew is the honest end to any task that has moved one around.
What I learned
Both halves kept the thing that matters somewhere other than where I had recorded it.
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.
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 ls -la would have done it.
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.
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.
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?
Day 88 down. Twelve to go.