An OS policy defines the desired state configuration for a
VM.
Attributes
Name
Description
id
str
Required. The id of the OS policy with the following
restrictions:
- Must contain only lowercase letters, numbers, and
hyphens.
- Must start with a letter.
- Must be between 1-63 characters.
- Must end with a number or a letter.
- Must be unique within the assignment.
description
str
Policy description.
Length of the description is limited to 1024
characters.
MutableSequence[google.cloud.osconfig_v1alpha.types.OSPolicy.ResourceGroup]
Required. List of resource groups for the policy. For a
particular VM, resource groups are evaluated in the order
specified and the first resource group that is applicable is
selected and the rest are ignored.
If none of the resource groups are applicable for a VM, the
VM is considered to be non-compliant w.r.t this policy. This
behavior can be toggled by the flag
allow_no_resource_group_match
allow_no_resource_group_match
bool
This flag determines the OS policy compliance status when
none of the resource groups within the policy are applicable
for a VM. Set this value to true if the policy needs to
be reported as compliant even if the policy has nothing to
validate or enforce.
An OS policy resource is used to define the desired state
configuration and provides a specific functionality like
installing/removing packages, executing a script etc.
The system ensures that resources are always in their desired
state by taking necessary actions if they have drifted from
their desired state.
This message has oneof_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
Resource groups provide a mechanism to group OS policy resources.
Resource groups enable OS policy authors to create a single OS
policy to be applied to VMs running different operating Systems.
When the OS policy is applied to a target VM, the appropriate
resource group within the OS policy is selected based on the
OSFilter specified within the resource group.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-11 UTC."],[],[],null,["# Class OSPolicy (1.21.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.21.0 (latest)](/python/docs/reference/osconfig/latest/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.20.2](/python/docs/reference/osconfig/1.20.2/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.19.0](/python/docs/reference/osconfig/1.19.0/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.18.1](/python/docs/reference/osconfig/1.18.1/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.17.5](/python/docs/reference/osconfig/1.17.5/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.16.0](/python/docs/reference/osconfig/1.16.0/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.15.3](/python/docs/reference/osconfig/1.15.3/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.14.1](/python/docs/reference/osconfig/1.14.1/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.13.0](/python/docs/reference/osconfig/1.13.0/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.12.4](/python/docs/reference/osconfig/1.12.4/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.11.2](/python/docs/reference/osconfig/1.11.2/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.10.0](/python/docs/reference/osconfig/1.10.0/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.9.0](/python/docs/reference/osconfig/1.9.0/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.8.0](/python/docs/reference/osconfig/1.8.0/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.7.1](/python/docs/reference/osconfig/1.7.1/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.6.0](/python/docs/reference/osconfig/1.6.0/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.5.2](/python/docs/reference/osconfig/1.5.2/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.4.0](/python/docs/reference/osconfig/1.4.0/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.3.2](/python/docs/reference/osconfig/1.3.2/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.2.0](/python/docs/reference/osconfig/1.2.0/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.1.0](/python/docs/reference/osconfig/1.1.0/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [1.0.0](/python/docs/reference/osconfig/1.0.0/google.cloud.osconfig_v1alpha.types.OSPolicy)\n- [0.1.2](/python/docs/reference/osconfig/0.1.2/google.cloud.osconfig_v1alpha.types.OSPolicy) \n\n OSPolicy(mapping=None, *, ignore_unknown_fields=False, **kwargs)\n\nAn OS policy defines the desired state configuration for a\nVM.\n\nClasses\n-------\n\n### InventoryFilter\n\n InventoryFilter(mapping=None, *, ignore_unknown_fields=False, **kwargs)\n\nFiltering criteria to select VMs based on inventory details.\n\n### Mode\n\n Mode(value)\n\nPolicy mode\n\n### OSFilter\n\n OSFilter(mapping=None, *, ignore_unknown_fields=False, **kwargs)\n\nFiltering criteria to select VMs based on OS details.\n\n### Resource\n\n Resource(mapping=None, *, ignore_unknown_fields=False, **kwargs)\n\nAn OS policy resource is used to define the desired state\nconfiguration and provides a specific functionality like\ninstalling/removing packages, executing a script etc.\n\nThe system ensures that resources are always in their desired\nstate by taking necessary actions if they have drifted from\ntheir desired state.\n\nThis message has `oneof`_ fields (mutually exclusive fields).\nFor each oneof, at most one member field can be set at the same time.\nSetting any member of the oneof automatically clears all other\nmembers.\n\n.. _oneof: \u003chttps://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields\u003e\n\n### ResourceGroup\n\n ResourceGroup(mapping=None, *, ignore_unknown_fields=False, **kwargs)\n\nResource groups provide a mechanism to group OS policy resources.\n\nResource groups enable OS policy authors to create a single OS\npolicy to be applied to VMs running different operating Systems.\n\nWhen the OS policy is applied to a target VM, the appropriate\nresource group within the OS policy is selected based on the\n`OSFilter` specified within the resource group."]]