[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-26。"],[[["\u003cp\u003eThis page outlines the features and usage of legacy OS guest policies for managing VM configurations.\u003c/p\u003e\n"],["\u003cp\u003eOS guest policies enable the deployment, querying, and maintenance of consistent software configurations on VM instances, including installing, removing, and updating software packages.\u003c/p\u003e\n"],["\u003cp\u003eGuest policies use a resource containing settings like desired packages, repositories, and software configurations to apply to designated VMs.\u003c/p\u003e\n"],["\u003cp\u003eThe OS Config agent on VMs uses guest policy specifications to maintain the desired state, correcting any drift in configuration every 10 minutes.\u003c/p\u003e\n"],["\u003cp\u003eThe configuration management service prevents conflicts by rejecting the creation of guest policies that would result in contradictory configurations on the same VMs.\u003c/p\u003e\n"]]],[],null,["# OS guest policies (legacy)\n\n| **Caution:** This page includes instructions about the legacy OS guest policies. A later version of OS policies is now [Generally Available (GA)](/products#product-launch-stages). To use the later GA version, see [OS policies](/compute/vm-manager/docs/os-policies).\n|\n| To view a comparison of the two versions, see\n| [Comparing OS policies versions](/compute/vm-manager/docs/guest-policies/comparing_policy_options).\n\nThis page describes the legacy OS guest policies.\n\nYou can use OS guest policies to deploy, query, and\nmaintain consistent configurations (desired state and software) for your\nVM instance (VM). On Compute Engine, you must use\n[guest policies](#guest-policy) to maintain consistent software configurations on\na VM.\n\nTo create a guest policy, see\n[Create a guest policy](/compute/docs/guest-policies/create-guest-policy).\n|\n| **Beta**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nOverview\n--------\n\nA guest policy is a resource that contains settings such as the\ndesired package, package repository, and software configurations. The\nguest policy also specifies which VMs these settings should apply to.\n\nYou can use guest policies to complete the following tasks:\n\n- Install, remove, and auto-update software packages.\n- Configure software package repositories.\n- Install software using [software recipes](#key-terms).\n\n### Key terms\n\n- Package: Software packages such as dpkg or rpm.\n- Package repository: A repository where software packages can be installed from.\n- Software recipe: A set of instructions for installing unpackaged software\n for a guest operating system. With software recipes, you can specify\n instructions for installing software on the VMs. These instructions include\n additional steps such as:\n\n - Downloading files\n - Decompressing archives such as zip or tar\n - Running commands or scripts required to configure the software\n\n Software recipes are ideal if you want to install software that is not\n delivered as a conventional software package, or for packages that require\n additional installation arguments or instructions.\n\nPricing\n-------\n\nFor information about pricing, see\n[VM Manager pricing](/compute/vm-manager/docs/pricing).\n\nHow guest policies work\n-----------------------\n\nAfter you set up guest policies for your project or specific VM instances and\ninstall the OS Config agent, the OS Config agent runs on your VM\nand uses the specifications in the guest policy to maintain the desired\nstate for the VM. The OS Config agent applies the configurations during\nthe agent's first run and then polls the service and corrects any drift every 10\nminutes.\n\nThe OS Config agent uses the standard system package manager to apply the\nchanges where applicable. On Linux, this means running a system package\nmanager such as `apt install` or `yum install` for package installation.\n\nFor example you can set a policy that ensures that the\n[Cloud Monitoring agent](/monitoring/agent) is installed\non all instances in your project that have the prefix `test-`. For more\ninformation, see\n[Configuring a guest policy yaml or JSON file](/compute/vm-manager/docs/guest-policies/create-guest-policy#create-policy-file).\n\nHow the configuration management service handles assignment conflicts\n---------------------------------------------------------------------\n\nBecause guest policies apply to existing and future running VMs, during the\nguest policy creation process, the service verifies that there are no current\nor possible future conflicts.\n\nThe configuration management service prevents conflicting configurations from\nbeing assigned to the same VMs by rejecting the latter of two policies that are\ndeemed in conflict with each other.\n\nFor example, if you have the following policies:\n\n- Policy A, which installs a package `foo` on all VM instances that are labeled `color=red`.\n- Policy B, which removes package `foo` on all instances with a name prefix `dev-`.\n\nSuppose you create an instance named `dev-instance` with a label\n`color=red`, this results in conflicting policies. To mitigate\nthis problem, the service restricts `policy B` from being created.\n\nWhat's next?\n------------\n\n- [Create a guest policy](/compute/vm-manager/docs/guest-policies/create-guest-policy).\n- [Manage guest policies](/compute/vm-manager/docs/guest-policies/manage-guest-policy)."]]