Git Product home page Git Product logo

terraform-aci's Introduction

概要

CiscoACIをTerraformで操作するときのテンプレート的なやつ。
公式のProviderだと細かいところに手が届かない。例えばuSEGを全くイジれなかったりとか。他にもEPGやContractは大量に用意するだろうけど、そういったループ処理も当然自前で作る必要がある。
滅多にないけど、そういう用事ができたときに速やかに実装できるようにしておきたい・・・という思いでテンプレを用意しておく。

モジュール一覧

モジュール名 内容
attach_contract.tf EPGをコントラクトのConsumer
contract.tf コントラクト作成のラッパーモジュール。サブジェクト作成まで一括で行う。
epg.tf EPG作成ラッパーモジュール。AP作成~EPG作成~ドメインアタッチ~ポートアタッチまで行う。つまりこれを使えば周辺オブジェクトも含めて一気に作成可能。必要に応じて、IPアドレス属性を使ったuSEG EPGも作成可能。
ext_epg.tf ExternalEPG作成ラッパーモジュール。サブネット指定まで行う。
node2epg.tf EPGにノードをアタッチするモジュール。本来、こういったリソースは公式には用意されていないため、aci_restで独自に作成。
ports.tf EPGにスタティックパス(リーフのポートやVLANのマッピング)を行うモジュール。
useg_epg.tf epg.tfから使用するuSEG EPGを取り扱う専用のモジュール。uSEG関係のリソースは公式には用意されていないため、全面的にaci_restで独自に作成。

使い方

各モジュールを使えば、大量にACIのEPGやContractのオブジェクトを大量に作成できる。uSEG EPGやExternalEPGにも対応。

これだけでOK

module "epg" {
  source   = "./modules/epg"
  for_each = var.ap_with_epgs

  tenant   = aci_tenant.common.id
  app_prof = each.key
  epgs     = each.value
}

あとはvar_*.tf側をイジる。mapな形でどんどんオブジェクトを増やしていけば良い。これで10個でも100個でもEPGやContractを一気に作成できる。

ap_with_epgs  = {
  "EPG_Name" = {
    physical_domain = "Physical_Domain"
    bridge_domain   = "Bridge_Domain"
    attach_nodes = [
      "topology/pod-1/node-201",
      "topology/pod-1/node-202",
    ]
    attach_ports = {
      vlan  = ""
      mode  = ""
      ports = []
    }
    inheritances  = []
    is_useg       = true
    useg_ipaddrs  = ["192.168.0.1"]
    useg_matching = "any"
    subnet_cidr   = ""
    subnet_ctrl   = []
    subnet_scope  = []
  }
}

参考

手動でACIのAPIを叩いて特定テナント配下のオブジェクトをぶっこ抜く。

$ cat login.json
{
  "aaaUser" : {
    "attributes" : {
      "name" : "admin",
      "pwd" : "password"
    }
  }
}
$ curl -k -L -X POST https://example.aci.local/api/aaaLogin.json -d@./login.json -c cookie
$ curl -k "https://example.aci.local/api/mo/uni/tn-common.json?query-target=subtree" -b cookie | jq . > common_subtree.json

terraform-aci's People

Contributors

gzock avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.