Operations / Topic 22 of 30

Programming, Scripting, and Automation

How do you prevent a useful script from making a broad unwanted change?

Core exercise: 45–90 minutes · Self-paced · Synthetic data

Suggested prerequisites: Topic 06

All topics · Read Markdown source

Understand the technology

Automation makes a repeatable decision or action executable. Safe scripts validate inputs, limit scope, handle errors and make results visible. Idempotency means repeated execution preserves the intended state rather than duplicate side effects. Begin with read-only analysis and a dry-run plan before considering write actions. Approval belongs at the meaningful boundary, not after an irreversible operation.

By the end, you should be able to

  • Explain how the components below support the business need.
  • Complete the scoped exercise and compare expected with observed results.
  • Defend a decision using your own evidence and state its limitations.
Variables and structured data
Represent and validate inputs.
Control flow
Apply explicit conditions and error handling.
Dry run and idempotency
Preview changes and avoid duplicate effects.
Least privilege
Use only necessary access for the specific task.

See the connections

Conceptual sequence: Synthetic input, Validation, Dry-run decision, Approved action, Result log
A conceptual dependency sequence, not a literal network path. Explain each transition and identify the evidence needed.
1. Synthetic input

Locate Synthetic input in the scenario. Explain how it depends on the other stages, using the supporting technologies above. State what you would test before trusting its result.

In your diagram, label the owner, input, output and a possible failure at this stage.

2. Validation

Locate Validation in the scenario. Explain how it depends on the other stages, using the supporting technologies above. State what you would test before trusting its result.

In your diagram, label the owner, input, output and a possible failure at this stage.

3. Dry-run decision

Locate Dry-run decision in the scenario. Explain how it depends on the other stages, using the supporting technologies above. State what you would test before trusting its result.

In your diagram, label the owner, input, output and a possible failure at this stage.

4. Approved action

Locate Approved action in the scenario. Explain how it depends on the other stages, using the supporting technologies above. State what you would test before trusting its result.

In your diagram, label the owner, input, output and a possible failure at this stage.

5. Result log

Locate Result log in the scenario. Explain how it depends on the other stages, using the supporting technologies above. State what you would test before trusting its result.

In your diagram, label the owner, input, output and a possible failure at this stage.

Practice: How do you prevent a useful script from making a broad unwanted change?

Choose your depth. Core: analyze the supplied synthetic material in a browser, text editor or spreadsheet; no paid cloud account is required. Technical extension: optional external tool, installation or account as stated below. Review tool requirements and current licensing first. For paper-only practice, walk through tool steps as a plan and label outcomes modeled; do not claim configuration or testing you did not perform. No production changes are authorized.

Northstar needs to identify stale fictional device records. The exercise must report candidates without deleting anything.

Supplied synthetic input

device,days_since_seen,owner
LAB-A,5,team_a
LAB-B,95,team_b
LAB-C,unknown,unknown

Download synthetic input · Download worksheet

Procedure

  1. Read the CSV and define stale as a numeric age greater than 90 days; unknown is a separate review state.
  2. Write pseudocode or Python that validates the header and each value.
  3. Generate candidate and review reports without editing the input.
  4. Run twice and compare results to check deterministic behavior.
  5. Test a missing column and a nonnumeric value; require a visible failure or explicit review result.
  6. Document a future deletion approval process, but include no delete operation in the lab.
Compare your reasoning and expected results

LAB-B is a candidate, LAB-C requires review and LAB-A is current under the supplied rule. The script performs no external action; a candidate is not authorization to delete.

Download the read-only Python example. Run it with the supplied Topic 22 CSV; inspect the code first.

Optional technical extension

Implement the report with Python csv.DictReader, output a new CSV and add cases for missing headers, empty input and invalid ages. Use only supplied synthetic data.

External-tool procedures are reviewed instructions, not claims of execution in every listed environment. Record your actual tool version, observations and deviations. See the verification record.

Best practices to verify

  • Validate inputs and fail clearly.
  • Prefer read-only and dry-run modes first.
  • Avoid hard-coded credentials and broad privileges.
  • Test repeat execution and failure paths.

For each practice, specify an owner, a verification test and the evidence that would show failure.

Vendors, projects and tools

Representative examples, not a market ranking or endorsement
Vendor / projectWhat to investigateOfficial reference
Python Software FoundationOpen-source Python runtime and CSV libraryDocumentation / product site
MicrosoftPowerShell documentationDocumentation / product site
Red HatAnsible automation documentationDocumentation / product site

Selection criteria: fit to the requirement, support lifecycle, integration, security controls, learning access, licensing and total cost. Examples are not exhaustive. Commercial products may require paid licenses; community editions and free learning access do not imply free production use. No purchase is required for the core exercise.

Check your reasoning

An unknown age should be treated as stale and deleted.

Read the explanation

Unknown evidence needs explicit review. Neither stale classification nor missing ownership authorizes deletion.

Turn practice into career evidence

Role families to investigate: IT automation technician, Junior infrastructure engineer, Technical support analyst. These are search suggestions, not verified vacancies or a promise of job readiness. Requirements vary by employer.

  1. Search for these titles plus the supporting technologies in this lesson. Compare three current job descriptions and record repeated requirements.
  2. Map requirements to evidence you personally produced. Mark gaps honestly and plan one additional lab or supervised experience.
  3. Publish your original diagram, sanitized inputs, decisions and test record in your own repository after checking reuse rights. Link the relevant project in an application.
  4. Rehearse the interview question below, explaining what you did, what failed and how you verified the result.
How would you design a script so a malformed file cannot trigger unintended actions?

Resume pattern: “Independent lab project: investigated programming, scripting, and automation, documented [your specific action], verified [your actual result], and identified [a limitation].” Replace placeholders truthfully; do not imply employment or production implementation.

Start here: build your GitHub portfolio

Your learning record

This form sends nothing to a server. Browser storage can be cleared, blocked or shared with other users of this browser. Download a copy you want to keep. Do not enter sensitive information.

Continue with primary sources

Reference review date: December 1, 2026. Follow current vendor instructions and verify licensing before optional tool use. Product links establish context, not independent performance rankings.