Courseiva

CCNA VM Deployment And Provisioning Questions

36 questions · VM Deployment And Provisioning · All types, answers revealed

1
MCQhard

A Packer build targeting the qemu builder completes, but the resulting image boots to a login prompt and never runs your provisioning scripts. You configured an ssh communicator with a username and password. Which condition most likely prevents Packer from connecting to the guest during the build?

A.The guest firewall blocks outbound traffic on port 22.
B.The qemu builder does not support SSH communicators and only works with the none communicator.
C.Packer requires an Ansible provisioner to be defined before any shell provisioner can execute.
D.The communicator expects the SSH service to be available on a port that the guest has not yet opened, and no boot command waits for cloud-init or sshd to start.
AnswerD

With the qemu builder, Packer starts the VM and immediately tries to SSH using the configured credentials. If the image does not start sshd early or if the boot command does not wait for the SSH port to become reachable, the communicator times out and provisioning never runs. Ensuring sshd is enabled and adding appropriate boot wait logic resolves this.

Why this answer

Packer's qemu builder boots the image and then relies on the configured communicator to run provisioners. If sshd is not started early or the boot command does not poll for the SSH port, the communicator times out and no provisioning occurs. Verifying that the image enables SSH at boot and adding boot wait logic ensures Packer can connect and execute the scripts.

Exam trap

The trap here is focusing on provisioner configuration or outbound firewall rules when the real cause is that the guest's SSH service is not reachable at the moment Packer attempts to connect.

2
MCQeasy

You are using Vagrant to manage a development environment. You need to run a shell script that installs dependencies after the VM boots for the first time. Which provisioner type should you use in your Vagrantfile?

A.shell
B.ansible_local
C.docker
D.file
AnswerA

The shell provisioner runs scripts or inline commands on the guest. It is commonly used to install packages and configure the VM. By specifying a shell script, Vagrant will execute it during provisioning, which meets the requirement of installing dependencies after boot.

Why this answer

Vagrant's shell provisioner is designed to execute shell scripts or inline commands on the guest machine. It is the standard way to install software and configure a VM during provisioning. Other provisioners like file, ansible_local, or docker serve different purposes and would not directly run a shell script to install dependencies.

Thus, the shell provisioner is the correct choice.

Exam trap

The trap here is overcomplicating the solution by choosing a configuration management tool when a simple shell script suffices.

3
MCQmedium

When provisioning with Vagrant, which command is best used to apply changes to a configuration (like adding a new shell script) without destroying the existing virtual machine?

A.vagrant halt
B.vagrant reload
C.vagrant up
D.vagrant provision
AnswerD

`vagrant provision` re-runs the configured provisioners against the already-running guest, so a newly added shell script executes in place. It satisfies the stem's constraint of applying configuration changes without destroying the existing virtual machine, unlike `vagrant destroy` followed by `vagrant up`, which rebuilds from scratch.

Why this answer

The `vagrant provision` command is specifically designed to run provisioners (such as shell scripts, Ansible, Puppet, etc.) on a running Vagrant-managed VM without destroying or recreating it. When you modify a provisioning script or add a new one, `vagrant provision` applies those changes to the existing machine, ensuring the VM's state is updated according to the new configuration. This is the correct approach because it preserves the VM's current state while enforcing the updated provisioning logic.

Exam trap

The trap here is confusing `vagrant reload` with `vagrant provision`: many candidates assume that reloading the VM automatically re-runs provisioners, but by default it does not—you must add the `--provision` flag. Similarly, `vagrant up` is often mistakenly thought to re-provision an existing VM, but it only provisions on initial creation or when explicitly forced.

How to eliminate wrong answers

Option A is wrong because `vagrant halt` simply shuts down the running virtual machine gracefully; it does not apply any configuration changes or run provisioners. Option B is wrong because `vagrant reload` restarts the VM and, by default, does not re-run provisioners unless the `--provision` flag is explicitly added; without that flag, it only reloads the VM with the existing configuration. Option C is wrong because `vagrant up` is used to create and start a new VM from scratch or resume a halted one; if the VM is already running, it does nothing, and if it's halted, it starts it without necessarily re-provisioning unless the `--provision` flag is used, but it does not target an existing running VM for configuration updates.

4
MCQmedium

In a Vagrant environment, where should sensitive data like API keys be stored to avoid committing them to version control?

A.A box metadata file
B.The Vagrantfile
C.The provisioner script
D.A .env file excluded from git
AnswerD

A .env file excluded from git keeps API keys out of version control while remaining readable by provisioning scripts and applications at runtime. Adding it to .gitignore satisfies the stem's constraint of avoiding committed secrets, unlike hardcoding values or relying on tracked configuration files that would expose credentials in repository history.

Why this answer

Sensitive data such as API keys should be stored in a .env file that is excluded from version control (e.g., via .gitignore), so secrets are not committed to the repository. This keeps credentials out of source history while still allowing the application to load them at runtime.

Exam trap

305-300 often tests the misconception that secrets can be safely stored in the Vagrantfile or provisioner scripts, when in fact those are version-controlled and should never contain sensitive data.

How to eliminate wrong answers

Option A is wrong because a box metadata file describes the Vagrant box (name, version, provider) and is not intended for secrets; storing keys there would expose them and is not a supported pattern. Option B is wrong because the Vagrantfile is typically committed to version control and is meant for configuration, not secrets. Option C is wrong because provisioner scripts are also committed and would expose any embedded credentials.

5
MCQmedium

You are provisioning a KVM guest with virt-install. The guest must use a pre-existing disk image located at /var/lib/libvirt/images/web.img and must not have the image created or modified by virt-install. Which option should you include in the virt-install command?

A.--disk path=/var/lib/libvirt/images/web.img,sparse
B.--disk path=/var/lib/libvirt/images/web.img,readonly
C.--disk path=/var/lib/libvirt/images/web.img,shareable
D.--disk path=/var/lib/libvirt/images/web.img,import
AnswerD

The import suboption tells virt-install to use the existing disk image without creating, resizing, or formatting it. This is the correct way to attach a pre-built image to a new domain definition. Without import, virt-install may attempt to create or modify the file, which is undesirable when the image already contains an installed OS.

Why this answer

When a disk image already exists and contains a bootable operating system, virt-install must be told not to create or format it. The import suboption within --disk achieves exactly this, allowing the new domain to boot from the existing image. Other suboptions such as readonly, shareable, or sparse address different storage behaviors and do not satisfy the requirement of reusing an unmodified image.

Exam trap

The trap here is confusing disk attributes like readonly or shareable with the import flag, which specifically prevents image creation or modification.

6
Multi-Selectmedium

Which THREE settings are commonly configured in the 'provider' block of a Vagrantfile for virtualbox?

Select 3 answers
A.gui
B.disk_size
C.cpus
D.network_type
E.memory
AnswersA, C, E

The `gui` setting in the VirtualBox provider block controls whether the virtual machine boots with a graphical interface or runs headless. Setting `gui = true` launches the VM window, satisfying scenarios requiring desktop interaction during provisioning, while the default headless mode suits automated, terminal-only workflows.

Why this answer

In a Vagrantfile, the provider block for VirtualBox accepts the settings gui, cpus, and memory, which are all valid VirtualBox provider options. Option A (gui) is correct because it controls whether the VirtualBox VM launches with a graphical user interface, a common provider-specific setting. Option C (cpus) is correct because it sets the number of virtual CPUs allocated to the VM through the VirtualBox provider.

Option E (memory) is correct because it specifies the amount of RAM in megabytes assigned to the VM by the VirtualBox provider. Option B (disk_size) is not a standard VirtualBox provider setting in Vagrant; disk resizing typically requires the vagrant-disksize plugin or manual VBoxManage commands. Option D (network_type) is not a valid Vagrant provider setting; networking is configured via config.vm.network with types like private_network or public_network.

Exam trap

The trap is including plausible-sounding but non-existent provider keys like `disk_size` or `network_type`, which belong to other configuration contexts (disk or network blocks) rather than the VirtualBox provider block.

7
MCQeasy

When using Vagrant to manage a libvirt-based provider, which command verifies that the virtual machine is currently running and identifies the provider in use?

A.vagrant up
B.vagrant status
C.vagrant validate
D.vagrant box list
AnswerB

`vagrant status` queries the active Vagrant environment and reports each machine's state, showing "running" for the libvirt-backed VM, while the provider in use is confirmed through the environment's configuration. It satisfies both constraints in the stem: verifying the running state and identifying the libvirt provider.

Why this answer

The vagrant status command reports the current state of each machine defined in the Vagrantfile (running, poweroff, not created, etc.) and shows the provider in use (e.g., libvirt, virtualbox). It is the canonical way to verify that a VM is up and which provider is backing it.

Exam trap

The trap is confusing action commands (up, halt, destroy) with informational commands (status, validate, box list) — candidates must remember that only vagrant status reports both running state and provider.

How to eliminate wrong answers

Option A is wrong because vagrant up starts or resumes the machine rather than reporting its state — it is an action, not a status query. Option C is wrong because vagrant validate checks the syntax and structure of the Vagrantfile without touching running VMs or reporting provider state. Option D is wrong because vagrant box list enumerates installed box images on the host, not the running state or provider of a specific VM.

8
MCQmedium

You need to ensure that a specific package is installed during the first boot of a cloud instance. Which cloud-init key should be added to the configuration?

A.packages
B.yum_install
C.software
D.install_packages
AnswerA

The packages key lists packages for cloud-init to install during first boot, invoking the system package manager before configuration modules run. Placing package names here guarantees installation on initial provisioning, satisfying the requirement without custom scripts or manual intervention.

Why this answer

The cloud-init configuration key `packages` is the standard directive for specifying a list of packages to install during instance initialization. It is processed by the `package-update-upgrade-install` module, which runs early in the boot sequence, ensuring the packages are present before other configuration steps. This key works across distributions by using the native package manager (apt, yum, dnf, etc.) to install the listed packages.

Exam trap

The trap here is confusing cloud-init's generic `packages` key with package-manager-specific commands like `yum_install` or intuitive but incorrect names like `install_packages`, leading candidates to choose a plausible-sounding but invalid option.

How to eliminate wrong answers

Option B is wrong because `yum_install` is not a valid cloud-init key; cloud-init uses `packages` and delegates to the appropriate package manager, so specifying a yum-specific key would be redundant and unsupported. Option C is wrong because `software` is not a cloud-init configuration key; it does not exist in any cloud-init module or schema. Option D is wrong because `install_packages` is not a recognized cloud-init key; the correct key is simply `packages`.

9
MCQeasy

Which command is used to display the configuration of a Packer build in a readable format?

A.packer inspect
B.packer view
C.packer show
D.packer list
AnswerA

`packer inspect` parses a template and prints its declared variables, builders, provisioners and post-processors as structured, human-readable output, without executing a build. This directly satisfies the stem's requirement to display build configuration readably, unlike `packer validate`, which only checks syntax, or `packer build`, which runs the build.

Why this answer

`packer inspect` is the dedicated Packer CLI subcommand that parses a template (HCL2 or legacy JSON) and prints its declared components — builders, provisioners, post-processors, and variables — in a human-readable summary without executing a build. It is the canonical way to review what a template will do before running `packer build`.

Exam trap

305-300 often tests whether candidates confuse Packer's real subcommands with plausible-sounding verbs borrowed from Terraform (`show`) or generic tooling (`view`, `list`), so memorising the actual Packer CLI surface is essential.

How to eliminate wrong answers

Option B is wrong because `packer view` is not a valid Packer subcommand; Packer's CLI exposes build, validate, inspect, fmt, init, console, fix, and version, but no 'view'. Option C is wrong because `packer show` does not exist in the Packer CLI — 'show' is a Terraform-style verb, not a Packer one. Option D is wrong because `packer list` is not a Packer subcommand either; listing installed plugins is handled by `packer plugins` in newer versions, not `packer list`.

10
MCQmedium

When defining a Vagrant network configuration for a libvirt provider, which mode allows the VM to receive an IP address directly from the physical network's DHCP server?

A.nat
B.public_network
C.forwarded_port
D.private_network
AnswerB

A public_network bridges the VM's virtual NIC onto the host's physical interface, so DHCP broadcasts reach the physical network's server and the VM obtains a routable address from that subnet. This satisfies the stem's requirement for an IP assigned directly by the external DHCP server rather than by libvirt's private NAT.

Why this answer

In Vagrant with the libvirt provider, the 'public_network' mode bridges the VM's network interface to a physical network, allowing it to obtain an IP address from the physical network's DHCP server. This makes the VM appear as a separate device on the LAN.

Exam trap

The trap is confusing public_network with private_network or nat; candidates might think private_network provides DHCP from the physical network, but it does not.

How to eliminate wrong answers

Option A is wrong because 'nat' uses network address translation, where the VM gets a private IP and shares the host's IP, not a DHCP address from the physical network. Option C is wrong because 'forwarded_port' is for port forwarding, not direct network bridging. Option D is wrong because 'private_network' creates a private network between host and VM, typically with a static IP or host-only DHCP, not the physical network's DHCP.

11
MCQeasy

Which file in a Vagrant project directory is processed by default to define the virtual environment configuration?

A.settings.json
B.Vagrantfile
C.provision.sh
D.config.yml
AnswerB

Vagrant reads the Vagrantfile in the project root automatically on every vagrant command, using Ruby syntax to declare the box, provider, networking and provisioning. No other file is parsed by default, so this is the configuration entry point the stem asks for.

Why this answer

Vagrant automatically reads a file named 'Vagrantfile' in the project directory to determine the configuration of the virtual environment, including the box to use, network settings, provisioning scripts, and provider configuration. This file is written in Ruby DSL syntax and is the single source of truth for a Vagrant project. Without a Vagrantfile, the 'vagrant up' command cannot determine what VM to create.

Exam trap

The trap is confusing Vagrant's configuration file with other common config formats like JSON or YAML — candidates may pick settings.json or config.yml because those are familiar, but Vagrant specifically uses the Ruby-DSL Vagrantfile.

How to eliminate wrong answers

Option A is wrong because settings.json is not a Vagrant configuration file — it is commonly used by VS Code and other tools, but Vagrant does not process it. Option C is wrong because provision.sh is a shell script that may be referenced by the Vagrantfile for provisioning, but it is not the default configuration file itself. Option D is wrong because config.yml is a YAML configuration file used by tools like Ansible, Docker Compose, or CI systems, but Vagrant does not read it by default.

12
Multi-Selecthard

Which THREE configuration items can be managed via cloud-init 'write_files' module?

Select 3 answers
A.Target path (path)
B.Service status
C.Permissions (permissions)
D.Kernel parameters
E.Content (content)
AnswersA, C, E

The write_files module's path key specifies the absolute filesystem location where each file is created, which is mandatory for every entry. This satisfies the stem's requirement by defining where the managed file content is written on the instance.

Why this answer

The cloud-init write_files module is designed to create arbitrary files on an instance during boot, and each file entry is defined by three key attributes: the destination path (option A, 'path'), the file's permissions (option C, 'permissions'), and the file's content (option E, 'content'). The 'path' specifies where the file is written on the filesystem, the 'permissions' sets the octal mode (e.g., '0644') applied to the file, and 'content' supplies the actual data written to that file. Options B and D are incorrect because service status is managed by cloud-init's 'runcmd' or systemd/service modules, and kernel parameters are handled by the 'sysctl' module or bootloader configuration, not by write_files.

Exam trap

The trap is assuming any boot-time setting (services, sysctl, kernel params) belongs to `write_files` — candidates must recall that `write_files` only handles file path, content, and permissions/ownership.

13
MCQhard

In a Vagrantfile, which method is used to pass environment variables into the guest virtual machine during the provisioning phase?

A.config.env.set
B.config.vm.env
C.vagrant.env.set
D.config.vm.provision "shell", env: { "VAR" => "value" }
AnswerD

The `env` hash on a shell provisioner injects the specified variables directly into the guest's provisioning environment, satisfying the requirement to pass values during provisioning rather than at boot. Vagrant exports these into the script's process, so the guest sees them without editing the box or using a separate configuration management tool.

Why this answer

In a Vagrantfile, environment variables are passed to a shell provisioner using the `env` option on the provisioner block: `config.vm.provision "shell", env: { "VAR" => "value" }`. This injects the variables into the environment of the provisioning script running inside the guest. It is the documented, supported way to make host-side values available to guest provisioning.

Exam trap

305-300 often tests the difference between valid Vagrantfile DSL methods and plausible-sounding but nonexistent ones like `config.env.set` or `config.vm.env`, so candidates who guess at syntax rather than recalling the documented `env:` option on the provisioner block get it wrong.

How to eliminate wrong answers

Option A is wrong because `config.env.set` is not a valid Vagrantfile method; Vagrant does not expose a global `config.env` namespace for this purpose. Option B is wrong because `config.vm.env` is not a Vagrant configuration method — there is no such setting on the VM config object. Option C is wrong because `vagrant.env.set` is not a Vagrant DSL method; `vagrant` is a CLI command, not a configuration object in the Vagrantfile.

14
MCQhard

You are using cloud-init to configure a VM that must run a script only on the very first boot, and the script must not run again on subsequent reboots. The script is provided as a MIME part in a multipart user-data file. Which cloud-init module should be used to ensure this behavior?

A.bootcmd
B.scripts-per-boot
C.scripts-per-instance
D.runcmd
AnswerC

scripts-per-instance is a cloud-init module that runs scripts exactly once per instance, on the first boot. It is designed for tasks that should only happen during initial provisioning. By providing the script as a MIME part with the appropriate content type, cloud-init will execute it only on the first boot, satisfying the requirement.

Why this answer

Cloud-init's scripts-per-instance module executes scripts only on the first boot of an instance. It is intended for one-time provisioning tasks. In a multipart user-data file, scripts can be included with a content type that cloud-init recognizes for per-instance execution.

Other modules like bootcmd or runcmd run on every boot, and scripts-per-boot is explicitly for every boot. Therefore, scripts-per-instance is the correct module.

Exam trap

The trap here is confusing scripts-per-boot with scripts-per-instance, as both involve scripts but differ in execution frequency.

15
MCQeasy

What is the default behavior of Vagrant when a box is not found locally on the host machine?

A.It prompts for a path
B.It downloads it from the Vagrant Cloud
C.It creates an empty machine
D.It fails immediately
AnswerB

Vagrant resolves a missing box by fetching it from the Vagrant Cloud registry, downloading and installing it locally before provisioning. This default behaviour means no manual box installation is needed, satisfying the scenario where the box is absent from the host.

Why this answer

When Vagrant is asked to bring up a machine and the specified box is not present locally, it automatically attempts to download the box from the configured box repository, which by default is Vagrant Cloud (formerly Atlas). This behavior is controlled by the box_url or the shorthand box name in the Vagrantfile, and Vagrant will fetch the box metadata and then the box file itself. No user prompt is required unless the box is not found in the repository or there is an ambiguity.

Exam trap

305-300 often tests the assumption that Vagrant requires manual intervention when a box is missing, but the default is automatic download from Vagrant Cloud.

How to eliminate wrong answers

Option A is wrong because Vagrant does not prompt for a path; it automatically resolves the box from the configured source. Option C is wrong because Vagrant does not create an empty machine; it requires a base box to clone from. Option D is wrong because Vagrant does not fail immediately; it first attempts to download the box from the default repository.

16
MCQmedium

Which tool is commonly used alongside Packer to validate the configuration file for syntax errors before attempting a build?

A.packer fmt
B.packer lint
C.packer validate
D.packer check
AnswerC

packer validate parses the template and reports syntax, schema, and configuration errors without starting a build, letting you catch mistakes cheaply. It satisfies the pre-build validation requirement, unlike packer build, which would attempt the full image creation.

Why this answer

`packer validate` is the built-in Packer subcommand that parses a template (HCL2 or JSON) and verifies its syntax, required fields, and referenced variables/builders before any build is attempted. It catches schema errors, missing required attributes, and invalid references without provisioning any infrastructure. This makes it the standard pre-build sanity check in CI pipelines alongside `packer fmt`.

Exam trap

The trap here is confusing `fmt` (formatting) with `validate` (semantic checking) and being lured by plausible-sounding but non-existent subcommands like `lint` or `check`.

How to eliminate wrong answers

Option A is wrong because `packer fmt` only rewrites the template to canonical HCL formatting (indentation, alignment) — it does not validate semantics or catch configuration errors. Option B is wrong because `packer lint` is not a native Packer subcommand; linting is typically done via third-party tools or `packer validate`. Option D is wrong because `packer check` does not exist as a Packer CLI command — it is a fabricated option designed to look plausible next to `validate`.

17
MCQhard

In cloud-init, which syntax is required at the very beginning of the configuration file to ensure it is recognized as a cloud-config script?

A.#cloud-config
B.#!/bin/bash
C.#cloud-init
D.---
AnswerA

The #cloud-config shebang on the first line signals cloud-init to parse the file as YAML configuration rather than a shell script or other user-data format. Without it, cloud-init treats the payload as an unrecognised script and skips the declared modules.

Why this answer

Cloud-init identifies a cloud-config file by the literal header #cloud-config on the very first line. Without this exact shebang-style marker, cloud-init treats the payload as a different user-data format (e.g., shell script or MIME multipart) and will not process the YAML directives.

Exam trap

The trap is assuming any comment or YAML separator works as a header — candidates must remember the exact string #cloud-config on line one, with no leading whitespace or BOM.

How to eliminate wrong answers

Option B is wrong because #!/bin/bash marks the payload as a shell script, which cloud-init executes as a script rather than parsing as YAML cloud-config. Option C is wrong because #cloud-init is not a recognized header — cloud-init looks specifically for #cloud-config (or #! for scripts, #include, etc.). Option D is wrong because --- is a YAML document separator, not a cloud-init format marker; it can appear inside a cloud-config file but does not identify the file type.

18
MCQmedium

You are building a Vagrant environment for a development team. The Vagrantfile must provision three identical web servers and one load balancer, all using the same base box but with different hostnames and static IP addresses. Which Vagrantfile construct should you use to define these machines and their individual settings?

A.config.vm.provider
B.config.vm.network
C.config.vm.define
D.config.vm.provision
AnswerC

config.vm.define creates a named machine configuration block within the Vagrantfile, allowing per-machine settings such as hostname and private network IP. Each block inherits the global configuration but can override it. This is the standard way to define multiple machines in a single Vagrantfile, exactly matching the requirement for three web servers and one load balancer with distinct identities.

Why this answer

The config.vm.define method is used to declare multiple machines within a single Vagrantfile. Each definition block can set machine-specific attributes like hostname, network, and provider settings. This allows a single Vagrantfile to manage a multi-machine environment, which is exactly what is needed for three web servers and one load balancer.

Exam trap

The trap here is confusing machine definition with provisioning or networking directives, which only affect a single machine and cannot create multiple named VMs.

19
MCQmedium

When using Vagrant with multiple machines in a single Vagrantfile, how do you define individual configurations?

A.config.vm.box_set
B.config.vm.define :name
C.config.vm.instance
D.config.vm.multi
AnswerB

Using `config.vm.define :name` creates a named machine block within the single Vagrantfile, letting each machine carry its own settings such as box, network and provider configuration. This satisfies the stem's requirement to define individual configurations for multiple machines, since each block is scoped separately rather than sharing one global definition.

Why this answer

In a multi-machine Vagrantfile, each VM is declared with 'config.vm.define :name do |machine| ... end', which creates a named machine block where per-VM settings (box, network, provider, provisioners) are scoped. This is the canonical Vagrant DSL for multi-machine environments and allows 'vagrant up web' or 'vagrant ssh db' to target individual machines.

Exam trap

The trap is that candidates guess at plausible-sounding DSL methods ('box_set', 'multi') instead of recalling the actual Vagrant API, which uses 'define' for multi-machine scoping.

How to eliminate wrong answers

Option A is wrong because 'config.vm.box_set' is not a Vagrant DSL method — the correct method for specifying a box is 'config.vm.box'. Option C is wrong because 'config.vm.instance' does not exist in the Vagrant configuration API. Option D is wrong because 'config.vm.multi' is not a Vagrant directive; multi-machine support is achieved through repeated 'config.vm.define' blocks, not a 'multi' flag.

20
MCQmedium

Which cloud-init module is responsible for setting the hostname of the instance during the initial boot process?

A.system_name
B.hostname
C.network_config
D.set_hostname
AnswerB

The cloud-init hostname module reads the instance's configured hostname from metadata and applies it during initial boot, setting both the transient and persistent hostname. This directly satisfies the stem's requirement for the module responsible for hostname configuration at first boot.

Why this answer

The cloud-init 'hostname' module is responsible for setting the instance's hostname and, optionally, the fully qualified domain name (FQDN) during initial boot. It reads the 'hostname' and 'fqdn' keys from the cloud-config or metadata service and applies them via the appropriate system tool. This module runs early in the cloud-init boot stages to ensure the instance is correctly identified before other services start.

Exam trap

The trap here is that candidates may assume a module named 'set_hostname' exists because it sounds descriptive, but cloud-init's actual module is simply 'hostname' — memorizing the real module names is essential.

How to eliminate wrong answers

Option A is wrong because 'system_name' is not a cloud-init module — it is a fabricated name that does not exist in the cloud-init module list. Option C is wrong because 'network_config' (or 'networking') configures network interfaces, routes, and DNS, not the hostname. Option D is wrong because 'set_hostname' is not a real cloud-init module; the actual module is simply named 'hostname'.

21
MCQmedium

You maintain a Vagrant environment where a single Vagrantfile defines three web servers and one database server. You need each web server to use a different forwarded SSH port on the host because port 2222 is already taken by another project. Which approach correctly assigns unique host ports per machine?

A.Use config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--natpf1", "ssh,tcp,,2201,,22"] end once in the global scope.
B.Add a separate config.vm.network "forwarded_port", guest: 22, host: 2201, id: "ssh" line inside each machine's config block.
C.Set config.ssh.port = 2201 once at the top level of the Vagrantfile, outside any machine block.
D.Add config.vm.hostname = "web1" to each machine and rely on Vagrant to derive unique SSH ports automatically.
AnswerB

In Vagrant, each machine defined in a multi-machine Vagrantfile has its own config block where you can override the default SSH forwarded port. Specifying guest: 22 with a unique host port and a stable id (such as "ssh") replaces the default 2222 mapping for that machine, preventing collisions when several VMs run simultaneously on the same host.

Why this answer

Multi-machine Vagrantfiles give each machine its own configuration block, and SSH port forwarding must be defined there to avoid collisions. Using the forwarded_port directive with guest: 22, a unique host port, and a stable id ensures each web server is reachable on a distinct host port while the database server keeps its own mapping. Global settings or hostname changes do not produce unique host ports.

Exam trap

The trap here is assuming that setting an SSH port or a provider customization once at the top level of the Vagrantfile will apply uniquely to each machine, when in fact it applies uniformly and causes port conflicts.

22
MCQhard

A Packer template targets the qemu builder to produce a KVM-compatible image. The build completes without error, but when the resulting qcow2 file is booted with `qemu-system-x86_64 -drive file=image.qcow2,if=virtio`, the guest kernel panics with "VFS: Unable to mount root fs" because it cannot see any block device. The template defines only `iso_url`, `iso_checksum`, `ssh_username`, and `ssh_password`. Which change to the template is MOST likely to resolve this?

A.Add a `boot_command` that boots the installer with `inst.modprobe=virtio_blk` (or install a kernel/initramfs that includes the virtio_blk module) so the guest can see the virtio disk.
B.Add `disk_interface = "virtio"` to the builder's configuration so the disk controller matches the boot command line.
C.Add `qemuargs = [["-device", "virtio-blk-pci"]]` to force an explicit virtio controller during the build.
D.Set `format` to `raw` so the disk is written as a plain image instead of qcow2.
AnswerA

The kernel panic occurs because the guest initramfs has no virtio_blk driver, so the root filesystem on the virtio disk is invisible. Injecting the module via the installer boot command, or ensuring the installed initramfs includes it, lets the kernel enumerate the disk and mount root. This is the standard fix when a KVM image built by Packer fails to boot under `-drive if=virtio`.

Why this answer

The failure is a guest-side driver problem, not a builder configuration problem. Packer's qemu builder already presents the disk as virtio-blk, and the host-side QEMU command line uses `if=virtio`, so the guest must have the virtio_blk module available in its initramfs to mount the root filesystem. Adding the module through the installer boot command, or rebuilding the initramfs to include it, restores visibility of the disk and resolves the panic.

Exam trap

The trap here is assuming the qcow2 format or a missing QEMU device argument is hiding the disk, when the actual cause is a missing virtio_blk module inside the guest initramfs.

23
Multi-Selecthard

Which TWO components are defined in a Packer 'build' block?

Select 2 answers
A.builders
B.plugins
C.sources
D.variables
E.provisioners
AnswersC, E

Defines the builder(s) to use.

Why this answer

In a Packer HCL2 template, the build block is where you declare the sources (option C) that Packer will use to create the image, referencing source blocks defined elsewhere in the template, and the provisioners (option E) that run during the build to customize the machine before the image is captured. Both sources and provisioners are valid arguments inside a build block, e.g. build { sources = ["source.amazon-ebs.example"] provisioners = [ ... ] }. Option A (builders) is not correct because in HCL2 templates the builder is defined inside a source block, not directly as a build block argument.

Option B (plugins) is not a build block argument; plugins are installed via packer init and referenced through their source types. Option D (variables) is not defined inside the build block; variables are declared in variable blocks and referenced with var.<name>.

Exam trap

305-300 often tests the distinction between legacy JSON template components and HCL2 block structures, causing candidates to confuse 'builders' with 'sources' or overlook that 'provisioners' are nested within build blocks.

24
MCQhard

When using Packer with the QEMU builder, what does the 'format' option in the 'qemu' builder define?

A.The output image format
B.The filesystem type
C.The hypervisor type
D.The guest OS type
AnswerA

The format option specifies the output image format produced by the QEMU builder, satisfying the stem's requirement. It controls the on-disk artefact type, such as qcow2 or raw, and is distinct from accelerator, which selects the CPU virtualisation backend rather than the image encoding.

Why this answer

In the Packer QEMU builder, the 'format' option defines the output image format — for example 'qcow2', 'raw', 'vmdk', or 'vdi'. It tells QEMU how to write the resulting disk image so it is compatible with the target hypervisor or platform. This is distinct from filesystem or guest OS settings, which are configured elsewhere.

Exam trap

305-300 often tests whether candidates confuse the QEMU builder's 'format' (output disk image format) with filesystem or guest OS settings — the word 'format' is ambiguous, so reading the option carefully is essential.

How to eliminate wrong answers

Option B is wrong because the filesystem type (ext4, xfs, etc.) is determined by the guest OS installation and partitioning, not by the QEMU builder's 'format' option. Option C is wrong because the hypervisor type is fixed by the builder itself (QEMU/KVM); 'format' does not select a hypervisor. Option D is wrong because the guest OS type is specified via the 'accelerator', 'machine_type', or ISO/boot settings, not the 'format' option.

25
Multi-Selecthard

Which TWO pieces of information does Packer require to build an image for an existing cloud environment?

Select 2 answers
A.API credentials
B.Local disk path
C.BIOS password
D.Region
E.Host OS version
AnswersA, D

Packer authenticates to the target cloud provider's API using credentials such as access keys or service principal secrets before it can create, snapshot and register images. Without these credentials the builder cannot provision temporary instances, so they are mandatory for any existing cloud environment.

Why this answer

Packer needs API credentials (Option A) so its cloud builder can authenticate to the target cloud provider's API and create, register, and manage the resulting image on your behalf. Packer also needs the region (Option D) to know which geographic endpoint and datacenter location the image should be built in and stored, since cloud resources are region-scoped. A local disk path (Option B) is not required because Packer builds cloud images from a source image or template in the cloud, not from a local file path.

A BIOS password (Option C) is irrelevant since Packer does not modify firmware settings during image builds. The host OS version (Option E) is not required because Packer runs on the build host but the target image's OS comes from the configured source image, not the host's OS version.

Exam trap

305-300 often tests whether candidates confuse Packer's cloud builder requirements (API credentials and region) with local builder requirements (disk path, host OS) or unrelated hardware settings like BIOS passwords.

26
MCQhard

You are configuring cloud-init to inject an SSH key into a new VM. Which directive in the configuration metadata ensures the key is added to the correct user's authorized_keys file?

A.users.ssh_key
B.ssh_keys
C.ssh_authorized_keys
D.authorized_keys_file
AnswerC

The ssh_authorized_keys directive under the users list injects the specified public keys into that user's authorized_keys file during first boot. It satisfies the requirement to target the correct account rather than a default or root user.

Why this answer

In cloud-init user-data, the ssh_authorized_keys directive is a per-user key that specifies which SSH public keys should be written to that user's ~/.ssh/authorized_keys file. It is nested under the users list entry for the target user, ensuring the key lands in the correct account's authorized_keys rather than being applied globally.

Exam trap

The trap is confusing cloud-init's per-user ssh_authorized_keys with sshd_config's AuthorizedKeysFile or with a hypothetical top-level ssh_keys directive — candidates pick the name that sounds most like a config file parameter rather than the actual cloud-init schema key.

How to eliminate wrong answers

Option A is wrong because users.ssh_key is not a valid cloud-init directive — the correct per-user key is ssh_authorized_keys. Option B is wrong because ssh_keys is not a recognized cloud-init user-data key; there is no top-level ssh_keys directive in the users module schema. Option D is wrong because authorized_keys_file is not a cloud-init directive — it resembles an sshd_config parameter (AuthorizedKeysFile) but is not used by cloud-init to inject keys.

27
MCQhard

You are using Packer to build a KVM-compatible QEMU image for an on-premises OpenStack cloud. The build completes successfully, but the resulting image fails to boot because the virtual disk is not recognized. You verify that the QEMU builder is configured with accelerator 'kvm' and the correct machine type. Which QEMU builder option should you review to ensure the disk image is created in a format that OpenStack can use?

A.net_device
B.format
C.disk_image
D.headless
AnswerB

The format option in the QEMU builder defines the output disk image format, such as qcow2 or raw. OpenStack Glance commonly requires qcow2 for KVM-based instances. If the format is set incorrectly, the image may not be recognized. Reviewing and setting format to qcow2 ensures compatibility with OpenStack's default disk format expectations.

Why this answer

The QEMU builder's format option determines the output disk image format. For OpenStack KVM instances, qcow2 is typically required. If the image is built in a format that Glance or the hypervisor cannot interpret, the instance fails to boot.

Ensuring format is set to qcow2 aligns with OpenStack's expected disk format and resolves the recognition issue.

Exam trap

The trap here is assuming that disk_image or net_device controls the output format, when actually the format option is responsible for the disk image type.

28
MCQmedium

In a Packer build process for OpenStack, which 'post-processor' type is typically used to upload the resulting image to the Glance image service?

A.manifest
B.shell-local
C.openstack
D.compress
AnswerC

The openstack post-processor authenticates to the OpenStack APIs and uploads the built artefact to Glance, registering it as an image. It is the only post-processor type that targets Glance directly, satisfying the requirement to publish the Packer output there.

Why this answer

Packer's `openstack` post-processor takes the artifact produced by the builder (typically a qcow2 or raw image) and uploads it to the OpenStack Glance image service, registering it as a bootable image. It handles authentication against Keystone and can set image metadata such as name, visibility, and tags. This makes it the standard way to publish a Packer-built image into an OpenStack cloud.

Exam trap

305-300 often tests the distinction between post-processors that transform artifacts locally (compress, manifest, shell-local) versus those that publish to a cloud service (openstack), so candidates who pick a local-only processor miss the upload requirement.

How to eliminate wrong answers

Option A is wrong because the `manifest` post-processor only writes a JSON file listing the artifacts produced by the build; it does not interact with OpenStack or upload anything. Option B is wrong because `shell-local` runs a shell script on the machine running Packer, useful for local automation but not for uploading to Glance. Option D is wrong because `compress` creates a compressed archive of the artifact (e.g., .tar.gz) for storage or transfer, not for registering an image with OpenStack.

29
MCQmedium

A cloud-init configuration file is failing to apply the 'write_files' module. Which log file on the target instance should you examine to diagnose the parsing error?

A./var/log/syslog
B./var/log/messages
C./var/log/cloud-init.log
D./var/log/auth.log
AnswerC

The cloud-init log records each module's execution and any YAML parsing errors encountered while processing user-data, including write_files failures. Examining it reveals the exact syntax or schema fault, which the instance console output and syslog do not capture in equivalent detail.

Why this answer

The /var/log/cloud-init.log file is the primary log for cloud-init and records all stages of the cloud-init process, including the parsing and execution of modules like write_files. When a configuration file fails to apply, cloud-init logs detailed error messages, such as syntax errors or invalid YAML, in this file. Therefore, examining /var/log/cloud-init.log is the correct way to diagnose parsing errors.

Exam trap

305-300 often tests the distinction between general system logs and application-specific logs, so candidates might incorrectly choose /var/log/syslog or /var/log/messages assuming they contain all errors, but cloud-init writes detailed parsing errors only to its dedicated log.

How to eliminate wrong answers

Option A is wrong because /var/log/syslog is a general system log that aggregates messages from various services, but it does not contain the detailed cloud-init-specific parsing errors needed for diagnosis. Option B is wrong because /var/log/messages serves a similar purpose as syslog on some distributions, but it also lacks the granular cloud-init module execution details. Option D is wrong because /var/log/auth.log is dedicated to authentication and security events, not cloud-init configuration parsing.

30
MCQeasy

You are creating a Vagrant environment for a development team. The team needs a single VM that uses the 'ubuntu/jammy64' box and forwards host port 8080 to guest port 80. Which Vagrantfile configuration block correctly defines this?

A.config.vm.box = "ubuntu/jammy64" config.vm.network "private_network", ip: "192.168.33.10"
B.config.vm.box = "ubuntu/jammy64" config.vm.provision "shell", inline: "apt-get update"
C.config.vm.box = "ubuntu/jammy64" config.vm.network "forwarded_port", guest: 80, host: 8080
D.config.vm.box = "ubuntu/jammy64" config.vm.synced_folder ".", "/var/www", type: "nfs"
AnswerC

This configuration sets the box to ubuntu/jammy64 and defines a forwarded port mapping from host port 8080 to guest port 80. The syntax uses the network forwarded_port option with guest and host parameters, which is the standard Vagrant way to forward ports. It directly satisfies the requirement for a single VM with the specified box and port forwarding.

Why this answer

Vagrant port forwarding is configured with config.vm.network "forwarded_port", specifying guest and host ports. The correct option sets the box to ubuntu/jammy64 and maps host port 8080 to guest port 80. Other options define private networks, synced folders, or provisioners, which do not provide the required port forwarding functionality.

Exam trap

The trap here is mixing up network types, such as private_network, with forwarded_port, which is specifically for host-to-guest port mapping.

31
MCQmedium

What is the primary function of the cloud-init 'runcmd' module?

A.Setting the system locale
B.Configuring users
C.Running arbitrary shell commands
D.Installing software packages
AnswerC

The runcmd module executes arbitrary shell commands during instance initialisation, after other cloud-init stages complete. Commands are listed in the cloud-config under 'runcmd' and run in order, letting administrators perform custom configuration beyond the built-in modules.

Why this answer

The cloud-init `runcmd` module executes arbitrary shell commands on the instance during the final stage of boot, after other configuration modules have run. It is commonly used to run scripts, start services, or perform custom setup that is not covered by declarative modules. Because it runs late in the boot sequence, it can rely on packages and files configured by earlier modules.

Exam trap

305-300 often tests the distinction between cloud-init modules by function — candidates may pick `packages` or `users` for tasks that `runcmd` can technically do, but the question asks for the module whose primary purpose is running arbitrary shell commands.

How to eliminate wrong answers

Option A is wrong because setting the system locale is handled by the `locale` module, not `runcmd`. Option B is wrong because configuring users is handled by the `users` and `groups` modules. Option D is wrong because installing software packages is handled by the `packages` module (or `apt`/`yum` specific modules), not `runcmd`, although `runcmd` could technically run a package manager command, that is not its primary function.

32
Multi-Selectmedium

Which THREE of the following are common cloud-init modules?

Select 3 answers
A.network-bridge
B.packages
C.runcmd
D.disk-partition
E.users-groups
AnswersB, C, E

The packages module is a standard cloud-init module that installs listed packages during first boot, satisfying the stem's requirement for a genuine cloud-init module. It runs in the config stage and is distinct from bootcmd or write_files, which handle commands and file content instead.

Why this answer

Option B (packages) is a standard cloud-init module that installs or upgrades packages on first boot by reading the packages and package_upgrade keys, so it is correct. Option C (runcmd) is a core cloud-init module that executes arbitrary shell commands listed under the runcmd key during the final boot stage, making it correct. Option E (users-groups) is the cloud-init module responsible for creating and configuring users and groups from the users and groups directives, so it is also correct.

Options A (network-bridge) and D (disk-partition) are not cloud-init modules; networking is handled by modules such as network-config or the distro's network renderer, and partitioning is handled by modules like disk_setup and growpart, so neither belongs here.

Exam trap

The trap is picking plausible-sounding but non-existent modules like 'network-bridge' or 'disk-partition' — candidates who have not read the cloud-init module list assume any infrastructure task must have a dedicated module, when in fact many tasks are handled by runcmd or by differently named modules (disk_setup, mounts).

33
Multi-Selectmedium

Which THREE directives are valid under the cloud-init 'users' configuration section?

Select 3 answers
A.name
B.ssh_authorized_keys
C.expiration_date
D.security_level
E.groups
AnswersA, B, E

name is the mandatory identifying directive within cloud-init's users section, specifying the account to create or modify. It satisfies the stem by being a core valid user-configuration key, required whenever a user entry is defined.

Why this answer

In the cloud-init 'users' configuration section, the 'name' directive (A) is valid and required, as it defines the login name of the user account to be created. The 'ssh_authorized_keys' directive (B) is also valid, allowing a list of public SSH keys to be injected into the user's ~/.ssh/authorized_keys file for passwordless authentication. The 'groups' directive (E) is valid as well, specifying a list of supplementary groups to which the user should be added.

The 'expiration_date' option (C) is not a recognized cloud-init user directive; account expiration is handled via the 'expire' directive (or 'expiredate' in some schemas), not 'expiration_date'. The 'security_level' option (D) is not part of the cloud-init users schema at all and has no meaning in this context.

Exam trap

The trap is that plausible-sounding keys like `expiration_date` or `security_level` feel like they belong in a user configuration schema, but cloud-init's users module only supports a specific documented set.

34
Multi-Selecthard

Which TWO methods can be used to pass configuration data to cloud-init during instance creation?

Select 2 answers
A.kernel-args
B.user-data
C.bios-injection
D.sys-config
E.metadata
AnswersB, E

The primary configuration file.

Why this answer

Option B (user-data) is correct because cloud-init's primary mechanism for receiving instance-specific configuration at launch is the user-data blob, which can contain cloud-config YAML, shell scripts, or cloud-boothook directives that cloud-init parses on first boot. Option E (metadata) is correct because cloud-init also consumes instance metadata (for example, EC2 IMDS or OpenStack metadata service) to obtain configuration such as hostname, SSH keys, and network settings during initialization. Option A (kernel-args) is not a standard cloud-init configuration channel, since kernel command-line parameters are used for boot-time kernel behavior rather than passing structured config data to cloud-init.

Option C (bios-injection) is not a supported cloud-init datasource method, as BIOS settings are firmware-level and not used to deliver cloud-init configuration. Option D (sys-config) is not a recognized cloud-init mechanism; no such datasource or configuration-passing method exists in cloud-init's documented interfaces.

Exam trap

The trap is confusing kernel boot parameters with cloud-init inputs — candidates see 'kernel-args' and assume it's a legitimate injection path because cloud-init does read some system info at boot.

35
MCQhard

You are using Packer to build an image for a private cloud. The build uses the 'qemu' builder and a 'shell' provisioner. The provisioner script runs but fails to install a package because the package repository is unreachable. You suspect the VM has no network connectivity during provisioning. Which Packer feature should you verify to ensure the VM has network access?

A.The 'accelerator' setting in the qemu builder configuration.
B.The 'http_directory' setting in the builder configuration.
C.The 'net_device' setting in the qemu builder configuration.
D.The 'communicator' setting in the builder configuration.
AnswerC

In the qemu builder, the 'net_device' setting specifies the network device model and can also configure the network backend. If it is set to 'none' or misconfigured, the VM will have no network connectivity. By default, Packer configures a user-mode network, but if overridden, the VM may lack access. Verifying this setting ensures the VM can reach external repositories.

Why this answer

The qemu builder's 'net_device' setting defines the network interface for the VM. If it is set to 'none' or lacks a proper backend, the VM will have no network connectivity, causing package installations to fail. Packer's default qemu configuration usually includes a user-mode network, but explicit overrides can disable it.

Checking this setting ensures the VM can reach external repositories during provisioning.

Exam trap

The trap here is confusing the communicator with network connectivity; the communicator only enables Packer to run commands, not the VM's own outbound network access.

36
MCQmedium

Which Packer builder is most appropriate for creating an image specifically for Amazon Web Services (AWS)?

A.amazon-ebs
B.virtualbox-iso
C.qemu
D.docker
AnswerA

The amazon-ebs builder provisions an EC2 instance, runs provisioners against it, then stops it and creates an Amazon Machine Image (AMI) from the resulting EBS snapshot. This directly satisfies the requirement for an AWS-specific image, producing a native AMI rather than a generic artefact requiring later conversion.

Why this answer

The amazon-ebs builder is Packer's native AWS builder that launches a temporary EC2 instance, provisions it, creates an EBS-backed AMI, and terminates the instance. It is the standard and most appropriate choice for producing AWS AMIs directly. The other builders target different platforms or artifact formats.

Exam trap

305-300 often tests whether candidates can match Packer builders to their target platforms — the trap is picking a generic builder like qemu or virtualbox-iso when the question specifically asks for an AWS-native AMI.

How to eliminate wrong answers

Option B is wrong because virtualbox-iso builds a VirtualBox OVF/OVA image for local desktop virtualization, not an AWS AMI. Option C is wrong because the qemu builder produces QEMU/KVM disk images (e.g., qcow2/raw) for local or on-prem hypervisors, not AWS-native AMIs. Option D is wrong because the docker builder produces Docker container images, which are a completely different artifact type from an EC2 AMI.

Ready to test yourself?

Try a timed practice session using only VM Deployment And Provisioning questions.