Courseiva
Automation, Orchestration, and ScriptinghardMultiple ChoiceObjective-mapped

XK0-006 Automation, Orchestration, and Scripting Practice Question

An administrator wants to run a script on multiple remote servers using Ansible. The script requires a variable that differs per host. Where should the administrator define this variable to follow best practices?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

In host_vars/<hostname>.yml

Host-specific variables should be defined in host_vars files, which are automatically loaded by Ansible when the host is targeted.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • In the playbook under vars:

    Why it's wrong here

    Playbook vars apply to all hosts in the play, not per-host.

  • In host_vars/<hostname>.yml

    Why this is correct

    host_vars allows defining variables specific to a single host.

  • In the inventory file as a variable

    Why it's wrong here

    While possible, it is less organized and not best practice for many variables.

  • In group_vars/all.yml

    Why it's wrong here

    group_vars/all applies to all hosts, not per-host.

About these practice questions

Courseiva writes every XK0-006 question from scratch — 979 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.