XK0-006 automation and scripting explained

Updated November 25, 2026

Automation, Orchestration, and Scripting is 17% of XK0-006 and has five objectives (4.1 to 4.5): automation and orchestration, shell scripting, Python basics, Git and responsible use of AI. The questions range from reading a short script to choosing the right tool. The topics below follow CompTIA’s exam objectives.

4.1 Automation and orchestration

Infrastructure as code tools listed are Ansible (playbooks, inventory, modules, ad hoc commands, collections, facts, agentless operation), Puppet (classes, certificates, modules, facts, agent or agentless) and OpenTofu (providers, resources, state, API). Unattended deployment uses Kickstart and cloud-init. CI/CD ideas include version control, shift-left testing, GitOps, pipelines and DevSecOps. Orchestration covers Kubernetes (ConfigMaps, secrets, pods, deployments, volumes, services), Docker Swarm and Docker or Podman Compose (compose file, up and down, logs). Know what each tool is for: configuration management, provisioning, or container orchestration.

4.2 Shell scripting

Expect to read short Bash scripts. Topics:

  • Variables and expansion. Assignments, environment variables, arguments, ${var}, command substitution with $(foo), subshells.
  • Control flow. if, case, for, while, until, functions and return codes held in $?.
  • Tests and comparisons. Numeric (-eq, -ne, -gt, -ge, -lt, -le), string (=, ==, !=, <, >), file tests (-d, -f), -n and -z, and regular expressions with [[ $foo =~ regex ]].
  • Basics. The interpreter directive (#!), IFS and OFS, export, local, set, unset, alias.

A frequent trap is mixing numeric and string operators, or forgetting that the exit status 0 means success.

4.3 Python basics

Virtual environments, installing dependencies, built-in modules, data types (integer, float, string, list, dictionary, Boolean), indentation, extensibility via modules and PEP 8. You are not asked to write complex programs, but you should read a short snippet and identify what it does.

4.4 Git

Commands listed: clone, add, commit, config, diff, log, branch, checkout, fetch, pull, push, merge (including squash), rebase, reset, stash, tag and .gitignore. Know the difference between fetch (download) and pull (download and merge), and what .gitignore is for.

4.5 Responsible use of AI

Use cases: generating code, regular expressions or infrastructure as code, documenting code, improving compliance, security review, optimisation and linting. Best practices: do not paste output without review and quality assurance, and verify results. Governance themes: data security (including protecting data used to train a model), human review, local models, private versus public models and corporate policy. Prompt engineering is also listed.

Sample questions

Question 1. A team wants to configure 50 Linux servers over SSH without installing an agent on any of them. Which tool is the best fit?

  • A. Puppet with an agent on each host
  • B. Docker Swarm
  • C. Ansible
  • D. Kickstart
Show answer

Answer: C

Ansible is agentless and uses SSH to run tasks from a control node. Puppet is commonly deployed with an agent, Docker Swarm orchestrates containers rather than configuring hosts, and Kickstart automates the initial installation but is not a tool for ongoing configuration.

Want more questions like this? Full XK0-006 practice tests →

Question 2. In a Bash script, which construct runs a command and substitutes its output into another command line?

  • A. ${var}
  • B. $(command)
  • C. $?
  • D. #!
Show answer

Answer: B

$(command) is command substitution and places the command’s output where it appears. ${var} is parameter expansion of a variable, $? holds the last return code, and #! is the interpreter directive at the top of a script.

Want more questions like this? Full XK0-006 practice tests →

Question 3. A colleague pastes an AI assistant's generated firewall script straight onto a production server. According to responsible-use practice, what was missed?

  • A. Human review and verification of the output
  • B. Shortening the script
  • C. Encrypting the script file
  • D. Renaming the script with a version number
Show answer

Answer: A

Generated code must be reviewed and verified, ideally tested first, before running in production. Using a public model may also be restricted by policy, but the core failing is the missing review. Making the script shorter and encrypting it do not address correctness.

Want more questions like this? Full XK0-006 practice tests →

Next steps

Continue with troubleshooting, or go back to security.