Skip to content

Latest commit

 

History

History

ops-agent-policy

Agent Policy

This module is used to install/uninstall the ops agent in Google Cloud Engine VM's using ops agent policies.

Usage

Basic usage of this module is as follows:

Sample module to install Ops Agent on all Debian 12 VMs with the label "goog-ops-agent-policy=enabled".

module "ops_agent_policy" {
  source          = "github.com/terraform-google-modules/terraform-google-cloud-operations/modules/ops-agent-policy"
  project         = "<PROJECT ID>"
  zone            = "<ZONE>"
  assignment_id   = "example-ops-agent-policy"
  agents_rule = {
    package_state = "installed"
    version = "latest"
  }
  instance_filter = {
    all = false
    inventories = [{
      os_short_name = "debian"
      os_version = "12"
    }]
    inclusion_labels = [{
      labels = {
        goog-ops-agent-policy = "enabled"
      }
    }]
  }
}

Functional examples are included in the examples directory with the prefix ops_agent_policy.

Inputs

Name Description Type Default Required
agents_rule Whether to install or uninstall the agent, and which version to install. object({ package_state : string, version : string })
{
"package_state": "installed",
"version": "latest"
}
no
assignment_id Resource name. Unique among policy assignments in the given zone string n/a yes
instance_filter Filter to select VMs. Structure is documented below here: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/os_config_os_policy_assignment.
object({
all : optional(bool),
// excludes a VM if it contains all label-value pairs for some element in the list
exclusion_labels : optional(list(object({
labels : map(string)
})), []),
// includes a VM if it contains all label-value pairs for some element in the list
inclusion_labels : optional(list(object({
labels : map(string)
})), []),
// includes a VM if its inventory data matches at least one of the following inventories
inventories : optional(list(object({
os_short_name : string,
os_version : string
})), []),
})
n/a yes
project The ID of the project in which to provision resources. If not present, uses the provider ID string null no
zone The location to which policy assignments are applied to. string n/a yes

Outputs

Name Description
ops_agent_policy The generated policy for installing/uninstalling the ops agent.

Troubleshooting

The GA agent policies public documentation shows different errors that can appear while creating policies using the ops-agent-policy module.