CiscoDevNet / terraform-provider-aci

Terraform Cisco ACI provider
https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs
Mozilla Public License 2.0
90 stars 102 forks source link

Support syslog related resources (DCNE-65) #1258

Open bardahlm opened 3 months ago

bardahlm commented 3 months ago

Community Note

Description

To configure syslog a couple of new resources are needed.

Here is a aci_rest_managed configuration example that sets up syslog for tn common, fab common and fab default, mapping audit, events, faults and session to different facilities.

locals {
  syslog_server = "syslog.example.com"
  facility_mapping = {
    "audit"   = "local6"
    "events"  = "local5"
    "faults"  = "local4"
    "session" = "local3"
  }
}

resource "aci_rest_managed" "syslog_group" {
  for_each   = local.facility_mapping
  dn         = format("uni/fabric/slgroup-syslog_%s", each.value)
  class_name = "syslogGroup"
  content = {
    name                = format("syslog_%s", each.value)
    includeMilliSeconds = "yes"
    includeTimeZone     = "yes"
  }

  child {
    rn         = "console"
    class_name = "syslogConsole"
    content = {
      adminState = "disabled"
    }
  }

  child {
    rn         = "file"
    class_name = "syslogFile"
    content = {
      adminState = "disabled"
    }
  }

  child {
    rn         = "prof"
    class_name = "syslogProf"
  }
}

resource "aci_rest_managed" "syslog_remote_dest" {
  for_each   = local.facility_mapping
  dn         = format("%s/rdst-%s", resource.aci_rest_managed.syslog_group[each.key].dn, local.syslog_server)
  class_name = "syslogRemoteDest"
  content = {
    adminState         = "enabled"
    format             = "aci"
    forwardingFacility = each.value
    host               = local.syslog_server
    name               = format("syslog_%s", each.value)
    port               = "514"
    protocol           = "udp"
    severity           = "information"
  }

  child {
    rn         = "rsARemoteHostToEpg"
    class_name = "fileRsARemoteHostToEpg"
    content = {
      tDn = "uni/tn-mgmt/mgmtp-default/oob-default"
    }
  }
}

resource "aci_rest_managed" "tn_common_syslogsrc" {
  for_each   = local.facility_mapping
  dn         = format("uni/tn-common/monepg-default/slsrc-tn_common_%s", each.value)
  class_name = "syslogSrc"
  content = {
    name   = format("tn_common_%s", each.value)
    minSev = "information"
    incl   = each.key
  }
  child {
    rn         = "rsdestGroup"
    class_name = "syslogRsDestGroup"
    content = {
      tDn = resource.aci_rest_managed.syslog_group[each.key].id
    }
  }
}

resource "aci_rest_managed" "fab_common_syslog_src" {
  for_each   = local.facility_mapping
  dn         = format("uni/fabric/moncommon/slsrc-fab_common_%s", each.value)
  class_name = "syslogSrc"
  content = {
    name   = format("fab_common_%s", each.value)
    minSev = "information"
    incl   = each.key
  }

  child {
    rn         = "rsdestGroup"
    class_name = "syslogRsDestGroup"
    content = {
      tDn = resource.aci_rest_managed.syslog_group[each.key].id
    }
  }
}

resource "aci_rest_managed" "fab_default_syslog_src" {
  for_each   = local.facility_mapping
  dn         = format("uni/fabric/monfab-default/slsrc-fab_default_%s", each.value)
  class_name = "syslogSrc"
  content = {
    name   = format("fab_default_%s", each.value)
    minSev = "information"
    incl   = each.key
  }

  child {
    rn         = "rsdestGroup"
    class_name = "syslogRsDestGroup"
    content = {
      tDn = resource.aci_rest_managed.syslog_group[each.key].id
    }
  }
}

New or Affected Resource(s) + ACI Class(es):

Classes:

APIC version and APIC Platform

Potential Terraform Configuration

TBD

References

akinross commented 3 months ago

Hi @bardahlm,

Thank you for raising this issue, I have added it to the to do items.