mmv1/products/osconfig/GuestPolicies.yaml (859 lines of code) (raw):

# Copyright 2024 Google Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. --- name: 'GuestPolicies' api_resource_type_kind: GuestPolicy api_variant_patterns: - 'folders/{folder}/guestPolicies/{guestPolicy}' - 'organizations/{organization}/guestPolicies/{guestPolicy}' - 'projects/{project}/guestPolicies/{guestPolicy}' description: | An OS Config resource representing a guest configuration policy. These policies represent the desired state for VM instance guest environments including packages to install or remove, package repository configurations, and software to install. min_version: 'beta' references: guides: 'Official Documentation': 'https://cloud.google.com/compute/docs/os-config-management' api: 'https://cloud.google.com/compute/docs/osconfig/rest' docs: base_url: 'projects/{{project}}/guestPolicies' self_link: 'projects/{{project}}/guestPolicies/{{guest_policy_id}}' create_url: 'projects/{{project}}/guestPolicies?guestPolicyId={{guest_policy_id}}' update_verb: 'PATCH' timeouts: insert_minutes: 20 update_minutes: 20 delete_minutes: 20 identity: - guestPolicyId examples: - name: 'os_config_guest_policies_basic' primary_resource_id: 'guest_policies' vars: instance_name: 'guest-policy-inst' guest_policy_id: 'guest-policy' ignore_read_extra: # project number is returned in rest response - 'project' - name: 'os_config_guest_policies_packages' primary_resource_id: 'guest_policies' vars: guest_policy_id: 'guest-policy' ignore_read_extra: # project number is returned in rest response - 'project' - name: 'os_config_guest_policies_recipes' primary_resource_id: 'guest_policies' vars: guest_policy_id: 'guest-policy' ignore_read_extra: # project number is returned in rest response - 'project' parameters: - name: 'guestPolicyId' type: String description: | The logical name of the guest policy in the project 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 project. min_version: 'beta' url_param_only: true required: true validation: regex: '(?:(?:[-a-z0-9]{1,63}\.)*(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?):)?(?:[0-9]{1,19}|(?:[a-z0-9](?:[-a-z0-9]{0,61}[a-z0-9])?))' properties: - name: 'name' type: String description: | Unique name of the resource in this project using one of the following forms: projects/{project_number}/guestPolicies/{guestPolicyId}. min_version: 'beta' output: true - name: 'description' type: String description: | Description of the guest policy. Length of the description is limited to 1024 characters. min_version: 'beta' - name: 'assignment' type: NestedObject description: | Specifies the VM instances that are assigned to this policy. This allows you to target sets or groups of VM instances by different parameters such as labels, names, OS, or zones. If left empty, all VM instances underneath this policy are targeted. At the same level in the resource hierarchy (that is within a project), the service prevents the creation of multiple policies that conflict with each other. For more information, see how the service [handles assignment conflicts](https://cloud.google.com/compute/docs/os-config-management/create-guest-policy#handle-conflicts). min_version: 'beta' required: true properties: - name: 'groupLabels' type: Array description: | Targets instances matching at least one of these label sets. This allows an assignment to target disparate groups, for example "env=prod or env=staging". min_version: 'beta' at_least_one_of: - 'assignment.0.group_labels' - 'assignment.0.zones' - 'assignment.0.instances' - 'assignment.0.instance_name_prefixes' - 'assignment.0.os_types' item_type: type: NestedObject properties: - name: 'labels' type: KeyValuePairs description: | Google Compute Engine instance labels that must be present for an instance to be included in this assignment group. min_version: 'beta' required: true - name: 'zones' type: Array description: | Targets instances in any of these zones. Leave empty to target instances in any zone. Zonal targeting is uncommon and is supported to facilitate the management of changes by zone. min_version: 'beta' at_least_one_of: - 'assignment.0.group_labels' - 'assignment.0.zones' - 'assignment.0.instances' - 'assignment.0.instance_name_prefixes' - 'assignment.0.os_types' item_type: type: String - name: 'instances' type: Array description: | Targets any of the instances specified. Instances are specified by their URI in the form zones/[ZONE]/instances/[INSTANCE_NAME]. Instance targeting is uncommon and is supported to facilitate the management of changes by the instance or to target specific VM instances for development and testing. Only supported for project-level policies and must reference instances within this project. min_version: 'beta' at_least_one_of: - 'assignment.0.group_labels' - 'assignment.0.zones' - 'assignment.0.instances' - 'assignment.0.instance_name_prefixes' - 'assignment.0.os_types' item_type: type: String - name: 'instanceNamePrefixes' type: Array description: | Targets VM instances whose name starts with one of these prefixes. Like labels, this is another way to group VM instances when targeting configs, for example prefix="prod-". Only supported for project-level policies. min_version: 'beta' at_least_one_of: - 'assignment.0.group_labels' - 'assignment.0.zones' - 'assignment.0.instances' - 'assignment.0.instance_name_prefixes' - 'assignment.0.os_types' item_type: type: String - name: 'osTypes' type: Array description: | Targets VM instances matching at least one of the following OS types. VM instances must match all supplied criteria for a given OsType to be included. min_version: 'beta' at_least_one_of: - 'assignment.0.group_labels' - 'assignment.0.zones' - 'assignment.0.instances' - 'assignment.0.instance_name_prefixes' - 'assignment.0.os_types' item_type: type: NestedObject properties: - name: 'osShortName' type: String description: | Targets VM instances with OS Inventory enabled and having the following OS short name, for example "debian" or "windows". min_version: 'beta' - name: 'osVersion' type: String description: | Targets VM instances with OS Inventory enabled and having the following following OS version. min_version: 'beta' - name: 'osArchitecture' type: String description: | Targets VM instances with OS Inventory enabled and having the following OS architecture. min_version: 'beta' - name: 'packages' type: Array description: | The software packages to be managed by this policy. min_version: 'beta' item_type: type: NestedObject properties: - name: 'name' type: String description: | The name of the package. A package is uniquely identified for conflict validation by checking the package name and the manager(s) that the package targets. min_version: 'beta' required: true - name: 'desiredState' type: Enum description: | The desiredState the agent should maintain for this package. The default is to ensure the package is installed. min_version: 'beta' enum_values: - 'INSTALLED' - 'UPDATED' - 'REMOVED' - name: 'manager' type: Enum description: | Type of package manager that can be used to install this package. If a system does not have the package manager, the package is not installed or removed no error message is returned. By default, or if you specify ANY, the agent attempts to install and remove this package using the default package manager. This is useful when creating a policy that applies to different types of systems. The default behavior is ANY. min_version: 'beta' default_value: "ANY" enum_values: - 'ANY' - 'APT' - 'YUM' - 'ZYPPER' - 'GOO' - name: 'packageRepositories' type: Array description: | A list of package repositories to configure on the VM instance. This is done before any other configs are applied so they can use these repos. Package repositories are only configured if the corresponding package manager(s) are available. min_version: 'beta' item_type: type: NestedObject properties: - name: 'apt' type: NestedObject description: | An Apt Repository. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'archiveType' type: Enum description: | Type of archive files in this repository. The default behavior is DEB. min_version: 'beta' default_value: "DEB" enum_values: - 'DEB' - 'DEB_SRC' - name: 'uri' type: String description: | URI for this repository. min_version: 'beta' required: true - name: 'distribution' type: String description: | Distribution of this repository. min_version: 'beta' required: true - name: 'components' type: Array description: | List of components for this repository. Must contain at least one item. min_version: 'beta' required: true item_type: type: String - name: 'gpgKey' type: String description: | URI of the key file for this repository. The agent maintains a keyring at /etc/apt/trusted.gpg.d/osconfig_agent_managed.gpg containing all the keys in any applied guest policy. min_version: 'beta' - name: 'yum' type: NestedObject description: | A Yum Repository. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'id' type: String description: | A one word, unique name for this repository. This is the repo id in the Yum config file and also the displayName if displayName is omitted. This id is also used as the unique identifier when checking for guest policy conflicts. min_version: 'beta' required: true - name: 'displayName' type: String description: | The display name of the repository. min_version: 'beta' - name: 'baseUrl' type: String description: | The location of the repository directory. min_version: 'beta' required: true - name: 'gpgKeys' type: Array description: | URIs of GPG keys. min_version: 'beta' item_type: type: String - name: 'zypper' type: NestedObject description: | A Zypper Repository. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'id' type: String description: | A one word, unique name for this repository. This is the repo id in the zypper config file and also the displayName if displayName is omitted. This id is also used as the unique identifier when checking for guest policy conflicts. min_version: 'beta' required: true - name: 'displayName' type: String description: | The display name of the repository. min_version: 'beta' - name: 'baseUrl' type: String description: | The location of the repository directory. min_version: 'beta' required: true - name: 'gpgKeys' type: Array description: | URIs of GPG keys. min_version: 'beta' item_type: type: String - name: 'goo' type: NestedObject description: | A Goo Repository. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'name' type: String description: | The name of the repository. min_version: 'beta' required: true - name: 'url' type: String description: | The url of the repository. min_version: 'beta' required: true - name: 'recipes' type: Array description: | A list of Recipes to install on the VM instance. min_version: 'beta' item_type: type: NestedObject properties: - name: 'name' type: String description: | Unique identifier for the recipe. Only one recipe with a given name is installed on an instance. Names are also used to identify resources which helps to determine whether guest policies have conflicts. This means that requests to create multiple recipes with the same name and version are rejected since they could potentially have conflicting assignments. min_version: 'beta' required: true - name: 'version' type: String description: | The version of this software recipe. Version can be up to 4 period separated numbers (e.g. 12.34.56.78). min_version: 'beta' - name: 'artifacts' type: Array description: | Resources available to be used in the steps in the recipe. min_version: 'beta' item_type: type: NestedObject properties: - name: 'id' type: String description: | Id of the artifact, which the installation and update steps of this recipe can reference. Artifacts in a recipe cannot have the same id. min_version: 'beta' required: true - name: 'allowInsecure' type: Boolean description: | Defaults to false. When false, recipes are subject to validations based on the artifact type: Remote: A checksum must be specified, and only protocols with transport-layer security are permitted. GCS: An object generation number must be specified. min_version: 'beta' default_value: false - name: 'remote' type: NestedObject description: | A generic remote artifact. min_version: 'beta' # TODO (mbang): add `conflicts` when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'uri' type: String description: | URI from which to fetch the object. It should contain both the protocol and path following the format {protocol}://{location}. min_version: 'beta' - name: 'checkSum' type: String description: | Must be provided if allowInsecure is false. SHA256 checksum in hex format, to compare to the checksum of the artifact. If the checksum is not empty and it doesn't match the artifact then the recipe installation fails before running any of the steps. min_version: 'beta' - name: 'gcs' type: NestedObject description: | A Google Cloud Storage artifact. min_version: 'beta' # TODO (mbang): add `conflicts` when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'bucket' type: String description: | Bucket of the Google Cloud Storage object. Given an example URL: https://storage.googleapis.com/my-bucket/foo/bar#1234567 this value would be my-bucket. min_version: 'beta' - name: 'object' type: String description: | Name of the Google Cloud Storage object. Given an example URL: https://storage.googleapis.com/my-bucket/foo/bar#1234567 this value would be foo/bar. min_version: 'beta' - name: 'generation' type: Integer description: | Must be provided if allowInsecure is false. Generation number of the Google Cloud Storage object. https://storage.googleapis.com/my-bucket/foo/bar#1234567 this value would be 1234567. min_version: 'beta' - name: 'installSteps' type: Array description: | Actions to be taken for installing this recipe. On failure it stops executing steps and does not attempt another installation. Any steps taken (including partially completed steps) are not rolled back. min_version: 'beta' item_type: type: NestedObject properties: - name: 'fileCopy' type: NestedObject description: | Copies a file onto the instance. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'artifactId' type: String description: | The id of the relevant artifact in the recipe. min_version: 'beta' required: true - name: 'destination' type: String description: | The absolute path on the instance to put the file. min_version: 'beta' required: true - name: 'overwrite' type: Boolean description: | Whether to allow this step to overwrite existing files.If this is false and the file already exists the file is not overwritten and the step is considered a success. Defaults to false. min_version: 'beta' default_value: false - name: 'permissions' type: String description: | Consists of three octal digits which represent, in order, the permissions of the owner, group, and other users for the file (similarly to the numeric mode used in the linux chmod utility). Each digit represents a three bit number with the 4 bit corresponding to the read permissions, the 2 bit corresponds to the write bit, and the one bit corresponds to the execute permission. Default behavior is 755. Below are some examples of permissions and their associated values: read, write, and execute: 7 read and execute: 5 read and write: 6 read only: 4 min_version: 'beta' - name: 'archiveExtraction' type: NestedObject description: | Extracts an archive into the specified directory. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'artifactId' type: String description: | The id of the relevant artifact in the recipe. min_version: 'beta' required: true - name: 'destination' type: String description: | Directory to extract archive to. Defaults to / on Linux or C:\ on Windows. min_version: 'beta' default_from_api: true - name: 'type' type: Enum description: | The type of the archive to extract. min_version: 'beta' required: true enum_values: - 'TAR' - 'TAR_GZIP' - 'TAR_BZIP' - 'TAR_LZMA' - 'TAR_XZ' - 'ZIP' - name: 'msiInstallation' type: NestedObject description: | Installs an MSI file. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'artifactId' type: String description: | The id of the relevant artifact in the recipe. min_version: 'beta' required: true - name: 'flags' type: Array description: | The flags to use when installing the MSI. Defaults to the install flag. min_version: 'beta' default_from_api: true item_type: type: String - name: 'allowedExitCodes' type: Array description: | Return codes that indicate that the software installed or updated successfully. Behaviour defaults to [0] min_version: 'beta' default_from_api: true item_type: type: Integer - name: 'dpkgInstallation' type: NestedObject description: | Installs a deb file via dpkg. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'artifactId' type: String description: | The id of the relevant artifact in the recipe. min_version: 'beta' required: true - name: 'rpmInstallation' type: NestedObject description: | Installs an rpm file via the rpm utility. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'artifactId' type: String description: | The id of the relevant artifact in the recipe. min_version: 'beta' required: true - name: 'fileExec' type: NestedObject description: | Executes an artifact or local file. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'args' type: Array description: | Arguments to be passed to the provided executable. min_version: 'beta' item_type: type: String - name: 'allowedExitCodes' type: String description: | A list of possible return values that the program can return to indicate a success. Defaults to [0]. min_version: 'beta' default_from_api: true - name: 'artifactId' type: String description: | The id of the relevant artifact in the recipe. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) - name: 'localPath' type: String description: | The absolute path of the file on the local filesystem. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) - name: 'scriptRun' type: NestedObject description: | Runs commands in a shell. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'script' type: String description: | The shell script to be executed. min_version: 'beta' required: true - name: 'allowedExitCodes' type: Array description: | Return codes that indicate that the software installed or updated successfully. Behaviour defaults to [0] min_version: 'beta' default_from_api: true item_type: type: Integer - name: 'interpreter' type: Enum description: | The script interpreter to use to run the script. If no interpreter is specified the script is executed directly, which likely only succeed for scripts with shebang lines. min_version: 'beta' enum_values: - 'SHELL' - 'POWERSHELL' - name: 'updateSteps' type: Array description: | Actions to be taken for updating this recipe. On failure it stops executing steps and does not attempt another update for this recipe. Any steps taken (including partially completed steps) are not rolled back. min_version: 'beta' item_type: type: NestedObject properties: - name: 'fileCopy' type: NestedObject description: | Copies a file onto the instance. min_version: 'beta' # TODO (mbang): add exactly_one_of when it can be applied to lists (https://github.com/hashicorp/terraform-plugin-sdk/issues/470) properties: - name: 'artifactId' type: String description: | The id of the relevant artifact in the recipe. min_version: 'beta' required: true - name: 'destination' type: String description: | The absolute path on the instance to put the file. min_version: 'beta' required: true - name: 'overwrite' type: Boolean description: | Whether to allow this step to overwrite existing files.If this is false and the file already exists the file is not overwritten and the step is considered a success. Defaults to false. min_version: 'beta' default_value: false - name: 'permissions' type: String description: | Consists of three octal digits which represent, in order, the permissions of the owner, group, and other users for the file (similarly to the numeric mode used in the linux chmod utility). Each digit represents a three bit number with the 4 bit corresponding to the read permissions, the 2 bit corresponds to the write bit, and the one bit corresponds to the execute permission. Default behavior is 755. Below are some examples of permissions and their associated values: read, write, and execute: 7 read and execute: 5 read and write: 6 read only: 4 min_version: 'beta' - name: 'archiveExtraction' type: NestedObject description: | Extracts an archive into the specified directory. min_version: 'beta' properties: - name: 'artifactId' type: String description: | The id of the relevant artifact in the recipe. min_version: 'beta' required: true - name: 'destination' type: String description: | Directory to extract archive to. Defaults to / on Linux or C:\ on Windows. min_version: 'beta' default_from_api: true - name: 'type' type: Enum description: | The type of the archive to extract. min_version: 'beta' required: true enum_values: - 'TAR' - 'TAR_GZIP' - 'TAR_BZIP' - 'TAR_LZMA' - 'TAR_XZ' - 'ZIP' - name: 'msiInstallation' type: NestedObject description: | Installs an MSI file. min_version: 'beta' properties: - name: 'artifactId' type: String description: | The id of the relevant artifact in the recipe. min_version: 'beta' required: true - name: 'flags' type: Array description: | The flags to use when installing the MSI. Defaults to the install flag. min_version: 'beta' default_from_api: true item_type: type: String - name: 'allowedExitCodes' type: Array description: | Return codes that indicate that the software installed or updated successfully. Behaviour defaults to [0] min_version: 'beta' default_from_api: true item_type: type: Integer - name: 'dpkgInstallation' type: NestedObject description: | Installs a deb file via dpkg. min_version: 'beta' properties: - name: 'artifactId' type: String description: | The id of the relevant artifact in the recipe. min_version: 'beta' required: true - name: 'rpmInstallation' type: NestedObject description: | Installs an rpm file via the rpm utility. min_version: 'beta' properties: - name: 'artifactId' type: String description: | The id of the relevant artifact in the recipe. min_version: 'beta' required: true - name: 'fileExec' type: NestedObject description: | Executes an artifact or local file. min_version: 'beta' properties: - name: 'args' type: Array description: | Arguments to be passed to the provided executable. min_version: 'beta' item_type: type: String - name: 'allowedExitCodes' type: Array description: | A list of possible return values that the program can return to indicate a success. Defaults to [0]. min_version: 'beta' default_from_api: true item_type: type: Integer - name: 'artifactId' type: String description: | The id of the relevant artifact in the recipe. min_version: 'beta' - name: 'localPath' type: String description: | The absolute path of the file on the local filesystem. min_version: 'beta' - name: 'scriptRun' type: NestedObject description: | Runs commands in a shell. min_version: 'beta' properties: - name: 'script' type: String description: | The shell script to be executed. min_version: 'beta' required: true - name: 'allowedExitCodes' type: Array description: | Return codes that indicate that the software installed or updated successfully. Behaviour defaults to [0] min_version: 'beta' default_from_api: true item_type: type: Integer - name: 'interpreter' type: Enum description: | The script interpreter to use to run the script. If no interpreter is specified the script is executed directly, which likely only succeed for scripts with shebang lines. min_version: 'beta' enum_values: - 'SHELL' - 'POWERSHELL' - name: 'desiredState' type: Enum description: | Default is INSTALLED. The desired state the agent should maintain for this recipe. INSTALLED: The software recipe is installed on the instance but won't be updated to new versions. INSTALLED_KEEP_UPDATED: The software recipe is installed on the instance. The recipe is updated to a higher version, if a higher version of the recipe is assigned to this instance. REMOVE: Remove is unsupported for software recipes and attempts to create or update a recipe to the REMOVE state is rejected. min_version: 'beta' default_value: "INSTALLED" enum_values: - 'INSTALLED' - 'UPDATED' - 'REMOVED' - name: 'createTime' type: String description: | Time this guest policy was created. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z". min_version: 'beta' output: true - name: 'updateTime' type: String description: | Last time this guest policy was updated. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z". min_version: 'beta' output: true - name: 'etag' type: String description: | The etag for this guest policy. If this is provided on update, it must match the server's etag. min_version: 'beta' default_from_api: true