Geavanceerd
Zoeken inSamenvattingen
Zo zoek je
  • Woorden vinden lestitels, tekst en code. Filter op soort (gidsen, cursussen, programma's, boeken) of blijf in dit boek.
  • book:rhcsa en ch:8 maken de zoektocht kleiner; #code vindt een woord alleen in commando's van de lessen.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

Hoofdstuk 9Naam in de cursus: Posts P1052–P1061

Automation

Ten posts (P1052–P1061) about Automation, each in one lesson: the main idea, the key points and a link to the full note with all details, the PDF field guide and the commands.

  • 11 Lessen
  • 4 Commando's
  • 1 Labs

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

Vaardigheden in dit hoofdstuk

  • Automation — P1052–P1061

9.1

The automation stack: trigger, run, verify, report

Name the layer that pages you, or the stack has no top.

An automation is not a script. It is four layers, and most teams build the second one and stop.

  • Trigger: Cron schedule, Webhook event, Manual run
  • Run: Runner, Secret broker, Concurrency lock
  • Verify: Health probe, Output assertion, State diff
  • Report: Run log, Metrics, Alert route

Full note: P1052 — The automation stack: trigger, run, verify, report

9.2

Designing a CLI people keep using

The first ten seconds decide whether there is a second use.

A command-line tool is an interface with no undo, and people forgive it only while it is predictable.

  • First run: Help with no arguments, a plan before any write, and exit 2 for a bad flag.
  • Inputs: Flags over environment over config, one printed source, prompts only on a TTY.
  • Output: Data on stdout, prose on stderr, and an exit code that means what it says.
  • Longevity: Short verbs, a versioned format, completions and a man page.

Full note: P1053 — Designing a CLI people keep using

9.3

Five signs your automation is fragile

Fragility is a property of the owner, not of the language.

Fragile automation rarely looks fragile on the day it is written. It looks fast.

  • It runs from one laptop, one shell, one person's memory.
  • A second run makes the state worse, not the same.
  • The first sign of failure is a customer message.
  • Secrets live in the script, the repo, or a pinned message.

Full note: P1054 — Five signs your automation is fragile

9.4

Cron to systemd timer: the migration path

Migrate the job that has an owner, not the one nobody remembers.

Cron is not broken. It is just quiet: no log, no status, no record of the run that never happened.

  • Inventory: crontab -l for every user, and every file in /etc/cron.d.
  • Service unit: Same command, absolute paths, secrets from EnvironmentFile.
  • Timer unit: OnCalendar, Persistent=true, a randomised delay.
  • Verify: systemd-analyze calendar, a manual start, then the journal.

Full note: P1055 — Cron to systemd timer: the migration path

9.5

Idempotent scripts and safe re-runs

The second run is the test, and the diff is the assertion.

Idempotency is not a style. It is the difference between a script you can retry and a script that needs a person.

  • Name the state: One sentence: what this script owns, and what it must leave behind.
  • Read, then write: install, ln -sfn, mkdir -p: each one a no-op on the second run.
  • Guard the run: One lock, one run id, and a timeout on every call.
  • Prove it twice: A second run in CI, and a diff that must be empty.

Full note: P1056 — Idempotent scripts and safe re-runs

9.6

Four numbers for automation

Measure the job you have, not the one the diagram promised.

Four numbers decide whether an automation deserves to stay. None is a benchmark; each is a measurement you own.

  • Runtime: median and p95 from the runner's clock; a long tail is a queue problem.
  • Failure rate: failed runs over scheduled runs, with silent misses counted.
  • Toil saved: minutes per run times runs per week, minus the maintenance.
  • Blast radius: the accounts, clusters and data one run can touch.

Full note: P1057 — Four numbers for automation

9.7

Scaffolding a new service from a template

A template is a starting line, not a finish.

A template is not scaffolding because it saves typing. It saves the decisions you would otherwise make at 6 pm on a Friday.

  • Three choices before the commit: Pick the smallest template; Name it once, everywhere; Commit the lockfiles.
  • Three things it cannot do for you: Own the pipeline; Add a real health check; Set the first alert.
  • Three runs that earn the name: Deploy to an empty account; Run the smoke test; Write the five-line runbook.

Full note: P1058 — Scaffolding a new service from a template

9.8

Observability as code

If you cannot rebuild the signal from the repository, you do not have it.

Observability as code is not a dashboard committed to git. It is the ability to rebuild every signal from the repository.

  • Review the signal: Rules, dashboards and collector config in the same pull request as the code.
  • Test the rules: promtool check and test, with synthetic series and the page you expect.
  • Provision the view: Dashboards from files or Terraform, never from a UI session.
  • Own the pipeline: service.name, team and runbook on every artefact you ship.

Full note: P1059 — Observability as code

9.9

Five rules for credential automation

The best credential is the one the job never stores.

Credentials are the part of automation that fails loudly once and quietly forever.

  • Short-lived tokens from a broker, never a static key in a repo.
  • One identity per job, scoped to the action it performs.
  • The secret never reaches argv, a log line or an error trace.
  • Rotate on a schedule, and rehearse the rotation.

Full note: P1060 — Five rules for credential automation

9.10

Release automation commands

Rehearse the release before the tag exists.

Oefenen

Alle commando's in dit hoofdstuk