Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
francisATgwn opened this issue May 25, 2021 · 1 comment

Comments

@francisATgwn
Copy link

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:

  1. create a template in icinga's config, giving it custom vars
  2. terraform a Host that uses that config
@legioner0
Copy link

any updates or workarounds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants