terraform-provider-icinga2
terraform-provider-icinga2 copied to clipboard
Hosts created with terraform don't inherit custom variables from its template
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:
- icinga2_host
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:
- create a template in icinga's config, giving it custom vars
- terraform a Host that uses that config