You are preparing an Ubuntu 22.04 server image that will be booted inside an on-premises KVM cluster. A NoCloud datasource will supply the following user-data to cloud-init:
The goal is to enable and start nginx only after the package has finished installing and before the first login prompt appears. Which cloud-init section name should replace <SECTION GOES HERE> so the command systemctl enable --now nginx executes at the correct point in the first-boot sequence?
The runcmd section is processed near the end of cloud-init's config stage, after all other configuration modules (including package installation) have completed. Commands listed there run once on the first boot, so the service starts after nginx is available and before the system reaches multi-user targets.
bootcmd executes much earlier (every boot, even before networking and package modules), so the service might start before nginx exists.
write_files only writes files; it does not execute commands.
cloud-init-per is a helper that can be used inside bootcmd to limit repetition, but it is not a top-level section on its own.
Therefore runcmd is the appropriate section for this requirement.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of the 'runcmd' section in cloud-init?
Open an interactive chat with Bash
How does the 'runcmd' section differ from 'bootcmd' in cloud-init?
Open an interactive chat with Bash
What are some alternatives to 'runcmd' in cloud-init, and when would you use them?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Automation, Orchestration, and Scripting
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access