Prepare and test your skills

Prepare and test your skills

OS Patch Management and Automation is the use of Patch, the patching service in VM Manager (opens in a new tab), to keep Windows and Linux virtual machines (VMs) updated and secure. A patch job is a one-time, on-demand patching run, while a patch deployment is a recurring schedule that creates patch jobs automatically over time. Together, patch jobs and patch deployments deliver security updates and vulnerability fixes in the same controlled way across diverse VM fleets.
Patch is the VM Manager capability that installs operating system patches through the OS Config agent running on each VM. When a patch job starts, the OS Config agent uses native tools such as yum, apt, zypper, or the Windows Update Agent to pull updates from the configured package repository and install them. The VM must be able to reach those package sources, so VMs in private networks depend on Private Google Access to reach Google services and repositories. Patch also depends on a Google-managed service agent, service-PROJECT_NUMBER@gcp-sa-osconfig.iam.gserviceaccount.com with the Cloud OS Config Service Agent role, which is created when Patch starts a job to collect VM data and target the job.
A patch job is a definition of which VMs to patch, what updates to install, and how to handle reboots and special cases. The job targets VMs with an instance filter based on zones, labels such as env:prod or tier:frontend, or other VM properties, so different groups can be patched separately. A patch deployment uses the same target and patch configuration but adds a schedule, so Patch creates new patch jobs on that timetable without manual action. Before running either type, the project needs the OS Config API enabled and the OS Config agent activated on each VM through instance metadata, and Windows VMs should have Windows automatic updates disabled to avoid conflicts.
Patch jobs also control two important behaviors through boolean settings. Allow patching of MIG instances, controlled by migInstancesAllowed, decides whether VMs that belong to a managed instance group (MIG) are included, and the default is to skip MIG VMs. Skip unpatchable VMs, controlled by skipUnpatchableVms, tells Patch to skip a VM when its operating system does not support patching rather than failing the whole job. Access to run jobs is controlled by Identity and Access Management (IAM), where project owners have full access and other users need the Patch Job Executor role to run and manage jobs or the Patch Job Viewer role for read-only access.
Patch configuration is the part of a patch job that controls which updates the OS Config agent installs on each operating system family. A single patch job can carry different settings for Linux distributions and Windows, and the agent applies only the section that matches the VM. Optionally, an approved-patches list can be supplied to install only those packages, which causes Patch to skip all other patch configuration parameters.
| Operating system family | Update tool | What you can select |
|---|---|---|
| Debian and Ubuntu | apt | Standard upgrade or dist-upgrade, plus excluded packages |
| Red Hat, CentOS, and Rocky | yum | Security-only updates, minimal updates, plus excluded packages |
| SLES and openSUSE | zypper | System updates or zypper patches by category or severity, with options such as with update and with optional |
| Windows | Windows Update Agent | Update classifications such as critical and security, plus approved patches |
Reboot behavior is set separately with rebootConfig, for example DEFAULT, which lets the system reboot when a patch requires it. Pre-patch and post-patch scripts can also be attached so connections drain before patching and health checks run before the VM returns to service.
Safe automation of patch deployments means rolling out in small, controlled waves rather than patching everything at once. Labels group VMs by environment, application tier, or risk level so development VMs can be patched before production VMs. Staggering jobs zone by zone limits the blast radius if a patch causes a problem, while pre-patch and post-patch scripts protect workloads that cannot simply restart.
Common practices for consistent automation include:
env:dev, env:prod, and tier:frontend to target specific patch groups.The Patch dashboard is the console view that shows patch compliance for VMs that have the OS Config agent installed and OS inventory management enabled. The operating system overview counts VMs by operating system, and VMs with No data are typically unresponsive, missing the agent, missing inventory enablement, or running an unsupported operating system. Compliance status is grouped into four peer categories: Critical means critical updates are available, Important or security means important or security updates are available, Other means only non-critical updates are available, and Up-to-date means no updates are available.
Exam tip: Patch jobs run only within a single Google Cloud project, but compliance data can be viewed across projects, and MIG VMs are skipped unless patching of MIG instances is explicitly allowed.
Patch planning must account for MIG behavior and project scope. When a MIG repairs a VM, the MIG recreates the VM from its instance template, which can return the VM to an unpatched state, and autoscaling can delete patched VMs and create new unpatched VMs from the same template. Because jobs cannot cross project boundaries, even VMs in a Shared VPC must be patched from their own project.
Enablement and infrastructure configuration is the foundation that lets VM Manager manage operating system health across a Compute Engine fleet. VM Manager depends on the OS Config API, the Google Cloud control-plane service, the OS Config agent (opens in a new tab), the software running inside each VM, and a VM identity and network path that connect the two. Data flows from the agent inside the VM to the OS Config API, and control flows back from the API to the agent, but only after the API is enabled, activation metadata is set, and the VM has a working service account and network route.
The OS Config agent is the on-VM software that VM Manager uses to manage OS inventory, patches, and policies. The agent is delivered in the google-osconfig-agent package and it reads data from and writes data to VM metadata on the metadata server. By default, the OS Config agent does not collect or send any information until activation metadata is enabled. After activation, the agent communicates with the OS Config API service, and operations completed by the agent can be reviewed in VM Manager audit logging.
Enabling VM Manager means turning on the OS Config API for the project and activating the agent through metadata. The OS Config agent checks the enable-osconfig metadata key at the project level or the instance level, and a value of TRUE tells the agent to start communicating with the OS Config API. The project setting applies to all VMs in the project, while the instance setting applies to one VM and is checked by replacing /project/attributes/ with /instance/attributes/ in the metadata URL. On Linux, activation can be confirmed with sudo systemctl status google-osconfig-agent showing active (running), and on Windows with Get-Service google_osconfig_agent showing Running.
Exam tip: The OS Config agent is idle by default and starts collecting and sending data only after enable-osconfig metadata is set to TRUE.
A service account (opens in a new tab) is the Google Cloud identity attached to a VM that lets the OS Config agent call Google Cloud APIs. The recommended configuration follows an ordered setup:
https://www.googleapis.com/auth/cloud-platform scope on the VM so the service account can call the APIs it has permission to use.Changing a VM service account and access scopes requires stopping the VM first and restarting it after the change. The administrator making the change needs compute.instances.setServiceAccount, compute.instances.stop, and compute.instances.start, which can come from predefined or custom roles. In the Google Cloud console, the scope is set with Allow full access to all Cloud APIs, while the Google Cloud CLI and Compute Engine API use the scopes parameter.
| Service account option | Scope of impact | When to choose it |
|---|---|---|
| User-managed service account | Permissions affect only VMs using that account | Choose for least privilege and large fleets, because roles can be limited to what VM Manager needs |
| Compute Engine default service account | A role grant affects every VM running as the default account | Choose only when the default credentials are already understood, and replace a broad Editor grant with less permissive roles |
Network connectivity is the path that lets the VM reach osconfig.googleapis.com from inside its Virtual Private Cloud (VPC) network. Traffic flows from the VM to the OS Config API over public internet access, or over private Google services when the VM has no public internet. A VM in a private VPC network without public internet access depends on Private Google Access to reach the OS Config API. Connectivity can be verified from the VM with ping osconfig.googleapis.com and by requesting https://osconfig.googleapis.com/$discovery/rest, which returns discovery data with baseUrl of https://osconfig.googleapis.com/ when the path works.
Inventory Management and Policy Enforcement is the practice of keeping operating systems healthy, secure, and consistent across a large fleet of Compute Engine VMs. OS inventory management (opens in a new tab) provides operational visibility by monitoring installed packages and operating system versions, while the enforcement side uses the agent and policies to maintain a desired system state. Both functions depend on the OS Config agent (opens in a new tab) running on each VM and reporting to the central OS Config API service.
The OS Config agent is the guest software that VM Manager uses to manage OS inventory, patches, and policies on a VM. The agent is delivered in the google-osconfig-agent package and it reads data from and writes data to VM metadata to receive configuration and report status. By default, the OS Config agent does not collect or send any information until it is enabled in metadata, and after it is enabled the agent communicates directly with the OS Config API service. Operations completed by the agent can be reviewed through VM Manager audit logging.
OS inventory management is the VM Manager capability that collects OS inventory data from each VM and makes it visible for operations and security teams. Once the OS Config agent is set up and reporting inventory, the OS Config API service continuously compares that inventory against vulnerability sources for the operating system. Results appear as vulnerability reports in the Google Cloud console, and the same Common Vulnerabilities and Exposures (CVE) information also flows to Security Command Center and Cloud Asset Inventory. This shared visibility lets teams track OS versions, see which packages are installed, and spot vulnerable systems without signing in to each VM.
A vulnerability is a weakness that can cause an accidental system failure or allow malicious activity, and for VMs it is often an issue in the code or logic of operating system packages or applications. To get vulnerability data for a VM, VM Manager must be set up and OS Config agent version dated 20201110 or later must be running on that VM. After setup, the service generates a report when a package change introduces a known CVE or when an operating system vendor publishes a new security advisory.
VM Manager creates vulnerability reports through an ordered process:
Package changes normally appear as CVE information within two hours after a package is installed or updated, while updated CVEs from new vendor advisories are normally available within 24 hours after the vendor publishes the advisory.
A vulnerability source is the vendor repository that defines which CVEs apply to each operating system, and VM Manager checks inventory against the matching source for that VM. The sources differ by operating system because each vendor publishes advisories in its own system:
Data retention and accuracy limits define how long VM Manager keeps inventory data and when that data may be incomplete. OS inventory and vulnerability report data for a VM is stored until the VM is deleted, so history remains available for the life of the instance. If the OS Config agent stops reporting to the OS Config API service for a few days, VM Manager deletes the stored inventory and vulnerability data collected up to that point. No data will be available for that VM until the OS Config agent starts running and reporting again.
Exam tip: Vulnerability scanning for RHEL is based on the latest minor version for each major version, so a VM running an older RHEL minor version might show inaccurate results.
enable-osconfig metadata set to TRUE, a VM service account with the cloud-platform access scope, and a network path to osconfig.googleapis.com, including Private Google Access for private VMs.A patch job is a one-time, on-demand patching run, while a patch deployment is a recurring schedule that creates patch jobs automatically over time. Both target virtual machines (VMs) with an instance filter based on zones, labels or other VM properties, and a patch deployment adds a schedule so new jobs are created without manual action.
Patch installs operating system patches through the OS Config agent running on each VM, which uses native tools such as yum, apt, zypper or the Windows Update Agent to pull updates from the configured package repository and install them. The VM must be able to reach those package sources, so VMs in private networks depend on Private Google Access to reach Google services and repositories.
The OS Config API must be enabled for the project and the OS Config agent must be activated by setting the enable-osconfig metadata key to TRUE at the project level or the instance level. Each VM also needs a service account with the cloud-platform access scope and a network path to osconfig.googleapis.com, including Private Google Access for private VMs without public internet access.
Patch skips VMs that belong to a managed instance group unless patching of MIG instances is explicitly allowed with migInstancesAllowed. When a MIG repairs a VM, the MIG recreates the VM from its instance template which can return the VM to an unpatched state, and autoscaling can delete patched VMs and create new unpatched VMs from the same template.
Your organization operates a fleet of Compute Engine virtual machines (VMs) running both Windows and Linux in Google Cloud. You need to establish an automated patch management strategy that applies operating system security updates to a specific subset of VMs on a recurring weekly schedule.
What should you do?
Set up Cloud Scheduler to invoke a Cloud Function that executes operating system update commands over SSH on each VM
Configure an OS inventory management policy to automatically install software updates upon detection
Define instance metadata startup scripts on all VMs to execute package update commands during system boot
Create a patch deployment in VM Manager with a recurring schedule and an instance filter
Last updated