VCF Automation 9.1.1: Build a WordPress Server from Ubuntu 24.04 with cloud-init
By Mayank Goyal 893 views
A VCF Automation template configures Ubuntu 24.04 with a static network, Apache, PHP, MariaDB and WordPress, with install progress visible in vCenter.

A VM that becomes a working WordPress server
A deployment can finish before the application inside its VM is ready. This VCF Automation template makes that gap visible while cloud-init turns an Ubuntu 24.04 machine into a WordPress server. It sets the guest hostname and static network, installs Apache, PHP and MariaDB, configures WordPress, and reports installation progress through a vCenter guestinfo value.

The tested setup used VCF Automation 9.1.1 in a VM Apps organisation, embedded VCF Operations Orchestrator 9.1.1 build 25643527, vSphere 9, and an Ubuntu 24.04 VM template with cloud-init and open-vm-tools installed. The design uses one machine, a tagged existing network and deployment inputs for sizing and configuration. It doesn’t depend on image or flavor mappings.
That makes the template useful for repeatable lab deployments and demonstrations. Each request can supply its own address, credentials and site details, while the VM creates its database password locally. One important operational detail: VCF Automation can report the deployment complete as soon as the VM is up, even though the application setup continues for a few minutes inside the guest.
Requirements and deployment inputs
Start with an Ubuntu 24.04 template in vCenter or a content library. It needs cloud-init and open-vm-tools. The template refers to the image by name through imageRef; CPU count and memory are direct inputs, so there’s no flavor mapping to prepare. The target network must carry a capability tag matching the template’s net: constraint. The lab example uses net:lab-vm-mgmt.
Provide an unused IPv4 address on that network, the correct prefix and gateway, and DNS servers able to resolve public hostnames. The VM needs name resolution to reach Ubuntu package mirrors and download WordPress from wordpress.org. NTP servers can also be supplied; leaving that input empty retains the image’s existing time configuration.
The lab defaults include VM name lab-wordpress01, 2 vCPU, 4 GB of memory, a 40 GB boot disk, prefix length 24, gateway 10.20.44.1, DNS servers 10.20.44.11 and 10.20.44.12, and domain vmw.lab. The default NTP servers are the same two addresses. A disk smaller than the source template’s disk won’t work; the example template specifies 40 GB as its minimum.
Two encrypted inputs collect passwords: one for the Linux login and one for the WordPress administrator. The other site inputs are the title, administrator username and email address. The example defaults are Lab WordPress, wpadmin and [email protected]. Review those values, plus the image name, network tag and addressing defaults, before using the template in another project.

Cloud-init order and credential handling
The configuration uses cloud-init to set the hostname, write helper scripts and run them in sequence. The first operation creates the Linux account and adds it to the sudo group. SSH password authentication is enabled, and cloud-init restarts the SSH service before the remaining setup steps begin. Creating the account first gives an administrator a way to inspect the VM if a later network or package step fails.
The next script configures the static address with netplan, followed by the NTP configuration and the WordPress installation. A final command records cloud-init completion in /var/log/cloudinit-done.log. Keeping each operation in its own script makes the setup easier to inspect and rerun during troubleshooting.
Cloud-init writes the deployment values to /root/wp-install.env with permissions set to 0600. It contains the network settings and WordPress URL, title, administrator name, email and password. The scripts read values from this file. The installer removes it after setup, along with the downloaded WordPress archive, so the install-time WordPress password isn’t left in that file after completion.
VCF Automation decrypts encrypted inputs before passing them to the guest configuration. The installer checks for a password value that still looks encrypted and logs a warning if it finds one; the reported successful setup was confirmed by signing in to WordPress with the password entered in the deployment request.
The MariaDB password follows a different path. The guest generates it locally and saves the database name, user and password in /root/.wp-db-credentials, protected with 0600 permissions. The installer uses that value to create the database account and grant it access to the WordPress database. The deployment overview also tells operators where this file is stored, so treat root access to the VM as access to these credentials.
Static networking and time sync
VCF Automation attaches the existing vSphere network, while the guest applies the requested address. The network script disables cloud-init’s network management so the guest’s configuration persists across reboots. It moves existing netplan YAML files into /etc/netplan/backup, then writes a new configuration for the first non-loopback interface.

That netplan file disables DHCP for IPv4 and IPv6, assigns the requested address and prefix, sets the default route, and adds the DNS servers and search domain. The script restricts the file’s permissions to 0600 and applies it. It then checks whether archive.ubuntu.com resolves, trying up to 24 times. Each DNS lookup has a five-second timeout, with a five-second pause between attempts, giving the check roughly two minutes to succeed.
If DNS answers, the script publishes a network-ready status. If it does not, the script logs a warning and continues. That distinction matters during diagnosis: the interface may have its static address even when the VM can’t resolve package sources, so an address alone doesn’t establish that the installation can proceed.
The time-sync script reads the comma-separated NTP input, writes a systemd-timesyncd drop-in, enables time sync and restarts the service. An empty NTP value makes the script exit without replacing the image’s existing settings.
Follow installation from vCenter
The installer writes detailed output to /var/log/wordpress-install.log. A small status script also writes each milestone to the VM’s guestinfo.wp.status advanced setting using VMware Tools. This lets an operator check progress in vCenter without opening a guest session. The same value can be read from an Orchestrator workflow.
The example Orchestrator snippet uses ES5 JavaScript and searches for a VM whose name begins with lab-wordpress01. It reads the VM’s extraConfig, finds the guestinfo.wp.status key and logs its value alongside the guest IP address. The stated compatibility is Orchestrator 8.x and 9.x.
During a successful run, the status moves through milestones for the login account, network, NTP, package installation and WordPress setup. Completion is reported as a message such as DONE WordPress ready at http://10.20.44.71 (REST API HTTP 200). If the installer hits an error, its trap reports FAILED at line <n>; the accompanying log on the VM contains the detail.

Don’t use the deployment’s initial completion state as the signal that WordPress is ready. Check the guestinfo value or installer log, then test the site. The deployment overview also explains that its displayed values are captured when the deployment is created or updated. For a live resource state, use the Resources tab.
Two template issues to account for
VCF Automation interprets %{ as the beginning of an expression, in the same way it handles ${. Apache rewrite rules normally use the percent-brace sequence in expressions such as %{REQUEST_FILENAME}. Placing that literal sequence in cloudConfig causes template validation to fail with a compile error.
The workaround constructs the Apache rule at runtime. The script stores a percent sign in a shell variable, then uses the variable before {REQUEST_FILENAME}. As a result, the template text itself doesn’t contain the pair that VCF Automation would parse. The same concern affects curl’s -w '%{http_code}' format string, so the installer reads the HTTP status from response headers instead.
There’s a separate Apache wrinkle. The command wp rewrite structure '/%postname%/' --hard is expected to write rewrite rules, but the reported command-line setup didn’t create .htaccess. In that environment, wp-cli couldn’t detect Apache’s loaded mod_rewrite module. The home page loaded, but other paths—including /wp-json/—returned Apache 404 responses.
The template addresses this by enabling Apache’s rewrite module and a configuration that permits overrides in /var/www/html. It then writes the WordPress rewrite rules into .htaccess itself, using the variable-built percent sign, and assigns the file to www-data. The wp-cli rewrite commands still run, but the manually written file supplies the rules needed by Apache.
What the installer puts in the guest
Once networking is configured, the installer updates the Ubuntu package lists and installs Apache, MariaDB, PHP and the extensions WordPress needs, including support for MySQL, cURL, image handling, XML, ZIP and internationalization. It enables and starts the Apache and MariaDB services.
The database setup creates a database named wordpress with the utf8mb4 character set and utf8mb4_unicode_ci collation. It creates a local database user named wpuser, sets its password from the protected guest-side credentials file, and grants it privileges on the WordPress database.
The installer downloads the latest WordPress archive from wordpress.org, extracts the files into /var/www/html and assigns ownership to www-data. It also downloads wp-cli from its GitHub builds location and uses it to create the WordPress configuration and install the site with the requested title and administrator details. The installation skips email delivery.
Because the template downloads the latest WordPress and current packages during first boot, the installed versions depend on what those endpoints provide at deployment time. The source setup doesn’t pin a WordPress release or package versions. Teams that need repeatable version control should account for that behavior when adapting the template.
Deployment overview and practical checks
The template uses formatVersion: 2 and a __deploymentOverview output to show deployment details in the Overview tab. Its Markdown table includes the VM name, hostname, template, power state at deployment, CPU and memory, zone, network, IP and gateway, DNS and NTP, site URL, WordPress admin URL and SSH command.
The output can also include the WordPress administrator username, but it doesn’t expose the password. Some output expressions point to resource properties. If a property isn’t present, the template may still validate and display null, so check the rendered overview after adapting it. The power state is a snapshot from creation or update, not a continuously refreshed reading.
Once guestinfo.wp.status reports completion, test the site from a machine that can reach the VM’s network. The example checks the home page title with curl and expects <title>Lab WordPress</title>. It then requests /wp-json/ and expects HTTP status 200. That REST API check exercises the permalink and rewrite configuration that can otherwise be missed by testing only the home page.
The site is available at http://<ip>, and its administration page is at http://<ip>/wp-admin/. The reported deployment also installed a custom theme through the administration page using the supplied credentials, demonstrating that the finished instance accepted a theme upload.
Adapting the template
The complete template is intended to be pasted into a new project template in code view. Before deployment, check the VM template name, network capability tag and input defaults for the target network. Supply a free static address and verify that the DNS servers can resolve the external package and WordPress download locations.
The central operational advantage is that the deployment exposes both connection details and installation progress. The overview gives the requester the site URL and SSH command; guestinfo and the log explain whether setup has advanced beyond VM creation. For a lab or demonstration, that makes failures easier to locate. The checks to carry into each deployment are straightforward: confirm DNS resolution, wait for the installer’s completion status, and verify both the page title and REST API response.