Courseiva

XK0-006 Automation, Orchestration, and Scripting Practice Question

An administrator is creating an Ansible playbook to configure multiple web servers. Which of the following are valid ways to define variables for different groups of hosts? (Choose TWO.)

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 a group_vars directory

In Ansible, group variables can be defined in a group_vars directory (A) or directly in the inventory file using the :vars suffix, such as [webservers:vars] (B). The host_vars directory (C) is used for variables specific to individual hosts, not for groups of hosts. Since the question asks for two valid ways to define variables for groups, the correct answers are A and B.

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 a group_vars directory

    Why this is correct

    Variables placed in a group_vars directory apply to all hosts in the group.

  • ✓

    In the inventory file using :vars

    Why this is correct

    In the inventory file, using the :vars suffix (e.g., [groupname:vars]) defines variables for that group.

  • ✗

    In a host_vars directory

    Why it's wrong here

    Variables in a host_vars directory apply to a specific host, which can be in a group, making it a valid way to define variables for hosts in different groups.

  • ✗

    In the playbook itself using vars_files

    Why it's wrong here

    vars_files in a playbook includes external variable files, but those variables apply at the play or task level, not specifically to a group of hosts.

  • ✗

    In the roles directory

    Why it's wrong here

    Roles directory contains role-specific variables, not group-specific variables.

About these practice questions

This XK0-006 question is part of Courseiva's 781-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.