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

Not able to apply services? #23

Closed lpossamai closed 5 years ago

lpossamai commented 5 years ago

Hi all. Sorry if this is not the right place for this.

I am not able to "assign" a service via terraform. Or is it just me that is doing it wrong? The documentation doesn't say much about it.

Terraform v0.11.11
+ provider.icinga2 v0.2.0

main.tf:

provider "icinga2" {
  api_url = "https://192.168.199.9:5665/v1"
  api_user                 = "root"
  api_password             = "4c164afe4d1e95d9"
  insecure_skip_tls_verify = true
}

resource "icinga2_host" "webserver" {
  hostname      = "webserver.xxx.com"
  address       = "192.168.188.5"
  check_command = "hostalive"
  templates     = ["generic-host"]

  vars {
    os        = "centos"
    client_endpoint = "name"
    procs_warning =  500
    procs_critical  = 600
    # Disk Checks
    disk_partitions = "/"
    # Apache checks
    http_uri = "/action/robotPing/1.0"
    http_ssl = "true"
    http_clientcert = "/etc/icinga2/pki/xxx.pem"
    http_privatekey = "/etc/icinga2/pki/xxx.key"
  }
}

# Services for webserver.datacentre.motorweb.co.nz
resource "icinga2_service" "ssh" {
  name          = "ssh"
  hostname      = "${icinga2_host.webserver.hostname}"
  check_command = "ssh"
}

apply Service "ssh" {
  check_command = "ssh"
  assign where host.vars.os = 'centos'
}

The error is: Error: Unknown root level key: apply

is this feature not available yet? Cheers!

lpossamai commented 5 years ago

This is definitely a feature request...

lrsmith commented 5 years ago

@lpossamai I am not familiar with 'apply' as a terraform manifest configuration and I don't see it documented on https://www.terraform.io/docs/configuration/index.html Adding this is not something that would be added to just this resource, but would need to be added to the main terraform code and parser.

It looks like you want to create a service resource if a variable is set? Similar to https://github.com/hashicorp/terraform/issues/15281