Icinga / terraform-provider-icinga2

Terraform Icinga2 provider
https://www.terraform.io/docs/providers/icinga2/
Mozilla Public License 2.0
21 stars 20 forks source link

Hosts created with terraform don't inherit custom variables from its template #49

Open francisATgwn opened 3 years ago

francisATgwn commented 3 years ago

Using an icinga host template that has custom variables, a host object created through a direct API call with curl inherits the custom vars from the template whereas an equivalent host object created through terraform does not.

Terraform Version

> terraform --version
Terraform v0.15.4
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.30.0
+ provider registry.terraform.io/icinga/icinga2 v0.5.0

Affected Resource(s)

Please list the resources as a list, for example:

Terraform and Icinga Configuration Files

template Host "example" {
  vars.inherited_from_template = true
}
curl -sSLD /dev/stderr \
  -u "${ICINGA2_API_USER}:${ICINGA2_API_PASSWORD}" \
  -H 'Accept: application/json' \
  -X PUT \
  "${ICINGA2_API_URL}/objects/hosts/curl-example" \
  -d '{ "templates": [ "example" ], "attrs": { "address": "1.1.1.1", "check_command": "dummy", "vars.provided_by_host": "true" }, "pretty": true }'
resource "icinga2_host" "example" {
  hostname = "terraform-example"
  address = "1.1.1.1"
  check_command = "dummy"
  templates = [ "example" ]

  vars = {
    provided_by_host = true
  }
}

Expected Behavior

The terraformed host should have the same custom vars as the curl-created host

Actual Behavior

> curl -s\
  -u "${ICINGA2_API_USER}:${ICINGA2_API_PASSWORD}" \
  -H 'Accept: application/json' \
  "${ICINGA2_API_URL}/objects/hosts/curl-example" | jq -S '.results[0].attrs.vars'
{
  "inherited_from_template": true,
  "provided_by_host": "true"
}
> curl -s \
  -u "${ICINGA2_API_USER}:${ICINGA2_API_PASSWORD}" \
  -H 'Accept: application/json' \
  "${ICINGA2_API_URL}/objects/hosts/terraform-example" | jq -S '.results[0].attrs.vars'
{
  "provided_by_host": "true"
}

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. create a template in icinga's config, giving it custom vars
  2. terraform a Host that uses that config
legioner0 commented 5 months ago

any updates or workarounds?