Skip to content

fix: make sendmail target idempotent, guard mariadb secure install#17

Merged
teodesian merged 1 commit into
masterfrom
koan.trogbot/fix-sendmail-idempotency-and-mariadb-secure
Apr 26, 2026
Merged

fix: make sendmail target idempotent, guard mariadb secure install#17
teodesian merged 1 commit into
masterfrom
koan.trogbot/fix-sendmail-idempotency-and-mariadb-secure

Conversation

@troglodyne

Copy link
Copy Markdown
Contributor

What

Two independent idempotency gaps not covered by any of PRs #5#16.

Why

sendmail target (makefile.tt): had no touch $@, so Make never considered the target "done" — systemctl restart sendmail fired on every make invocation (every redeploy, test run, or manual make call). On a shared system this causes needless service churn. Also, the restart was inline rather than deferred.

mariadb secure installation (mariadb.tt): secure_installation.sql (which contains the root password in plaintext) was rendered, copied to /opt/mysql, executed, and deleted on every deploy. While the SQL itself is idempotent, writing credentials to disk and re-running the secure-install block on every redeploy is unnecessary and slightly risky.

How

  • makefile.tt: defer systemctl restart sendmail via queue_postrun_task (consistent with every other service restart in the codebase); add touch $@ so the target is stamped done after first successful run.
  • mariadb.tt: guard the secure-install block with [ -f /opt/mysql/.secured ] ||; touch the marker on success; use rm -f to clean up from both the staging dir and /opt/mysql regardless of which path was taken.

Testing

No automated test suite. Verified diff against all open PRs — no overlap on these specific changes. Patterns follow established guards from the codebase (queue_postrun_task, state file guards).

Note: this PR modifies makefile.tt (also touched by PR #7) and mariadb.tt (also touched by PR #6) — different lines, minor conflict to resolve at merge time.

sendmail: missing touch $@ meant systemctl restart sendmail fired on
every make invocation. Also defer restart via queue_postrun_task so it
runs after all recipes complete, consistent with other service starts.

mariadb: secure_installation.sql (which contains the root password) was
run on every deploy. Guard with .secured state file so the DB is only
secured once; rm -f cleans up from both staging dir and /opt/mysql
regardless of which path was taken.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@troglodyne troglodyne left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems ok

@troglodyne troglodyne marked this pull request as ready for review April 26, 2026 06:15
@teodesian teodesian merged commit b8eeba5 into master Apr 26, 2026
@troglodyne troglodyne deleted the koan.trogbot/fix-sendmail-idempotency-and-mariadb-secure branch May 23, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants