Giter VIP home page Giter VIP logo

terraform-utils-nac-merge's Introduction

Tests

Terraform Merge Module

A Terraform module to merge the content of several YAML files into a single Terraform data structure.

This module is part of the Cisco Nexus as Code project. Its goal is to allow users to instantiate network fabrics in minutes using an easy to use, opinionated data model. It takes away the complexity of having to deal with references, dependencies or loops. By completely separating data (defining variables) from logic (infrastructure declaration), it allows the user to focus on describing the intended configuration while using a set of maintained and tested Terraform Modules without the need to understand the low-level ACI object model. More information can be found here: https://cisco.com/go/nexusascode.

A comprehensive example using this module is available here: https://github.com/netascode/nac-aci-comprehensive-example

Examples

module "nac_merge" {
  source  = "netascode/nac-merge/utils"
  version = ">= 0.1.0"

  yaml_strings = [
    "root:\n  child1: value1",
    "root:\n  child2: value2"
  ]
}

## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_utils"></a> [utils](#requirement\_utils) | >= 0.2.4 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_utils"></a> [utils](#provider\_utils) | >= 0.2.4 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_yaml_strings"></a> [yaml\_strings](#input\_yaml\_strings) | List of YAML strings to be merged into a single model. | `list(string)` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_model"></a> [model](#output\_model) | Model data. |
| <a name="output_defaults"></a> [defaults](#output\_defaults) | Default values. |

## Resources

| Name | Type |
|------|------|
| [utils_yaml_merge.defaults](https://registry.terraform.io/providers/netascode/utils/latest/docs/data-sources/yaml_merge) | data source |
| [utils_yaml_merge.model](https://registry.terraform.io/providers/netascode/utils/latest/docs/data-sources/yaml_merge) | data source |
<!-- END_TF_DOCS -->

terraform-utils-nac-merge's People

Contributors

danischm avatar dependabot[bot] avatar

Watchers

 avatar  avatar

terraform-utils-nac-merge's Issues

Unexpected Merge output in a specific scenario

Not sure if this is an issue, but wanted to reach out/report this just in case.

Seeing empty results for an org when the policies key is empty in one of the YAML files.

E.g. I have 2 yaml files: ntp.yaml, ssh.yaml.

  • I have an "ntp" key defined under "policies" under ntp.yaml file.
  • If I keep the "policies" key empty under ssh.yaml file, the "default" org returns an empty result even though I have ntp variables in ntp.yaml file.

Not working example:

ntp.yaml

---
intersight:
  organization:
    default:
      policies:
        ntp:
          - name: Demo-default_ntp1
            ntp_servers: ["1.1.1.1", "1.1.1.2"]
            description: Default NTP1 Policy
            enabled: false
            timezone: "America/Los_Angeles"
    prod:
      policies:
        ntp:
          - name: Demo-prod_ntp1
            ntp_servers: ["1.1.1.3", "3.3.3.3"]
            description: Prod NTP3 Policy
            enabled: true
            timezone: "America/Los_Angeles"

ssh.yaml

---
intersight:
  organization:
    default:
      policies:
        # ssh:
    prod:
      policies:
        ssh:
          - name: prod_ssh1
            description: Prod NTP1 Policy
            enabled: true
            port: 22
            timeout: 300
            tags:
              - key: Location
                value: SAN_JOSE
              - key: ENV
                value: PROD

Not Expected Output:

Sample output where the "default" key shows empty:

  + local_model  = {
      + intersight = {
          + organization = {
              + default = {}
              + prod    = {
                  + policies = {
                      + ntp = [
                          + {
                              + description = "Prod NTP3 Policy"
                              + enabled     = true
                              + name        = "Demo-prod_ntp1"
                              + ntp_servers = [
                                  + "1.1.1.3",
                                  + "3.3.3.3",
                                ]
                              + timezone    = "America/Los_Angeles"
                            },
                          + {

Working Example:

ntp.yaml

---
intersight:
  organization:
    default:
      policies:
        ntp:
          - name: Demo-default_ntp1
            ntp_servers: ["1.1.1.1", "1.1.1.2"]
            description: Default NTP1 Policy
            enabled: false
            timezone: "America/Los_Angeles"
    prod:
      policies:
        ntp:
          - name: Demo-prod_ntp1
            ntp_servers: ["1.1.1.3", "3.3.3.3"]
            description: Prod NTP3 Policy
            enabled: true
            timezone: "America/Los_Angeles"

ssh.yaml

---
intersight:
  organization:
    default:
      policies:
        ssh:
    prod:
      policies:
        ssh:
          - name: prod_ssh1
            description: Prod NTP1 Policy
            enabled: true
            port: 22
            timeout: 300
            tags:
              - key: Location
                value: SAN_JOSE
              - key: ENV
                value: PROD

Expected Output:

  + local_model  = {
      + intersight = {
          + organization = {
              + default = {
                  + policies = {
                      + ntp = [
                          + {
                              + description = "Default NTP1 Policy"
                              + enabled     = false
                              + name        = "Demo-default_ntp1"
                              + ntp_servers = [
                                  + "1.1.1.1",
                                  + "1.1.1.2",
                                ]
                              + timezone    = "America/Los_Angeles"
                            },
                          + {
                              + description = "Default NTP2 Policy"
                              + enabled     = true
                              + name        = "Demo-default_ntp2"
                              + ntp_servers = [
                                  + "2.2.2.2",
                                  + "2.2.2.1",
                                ]
                              + timezone    = "America/Los_Angeles"
                            },
                        ]
                    }
                }
              + prod    = {
                  + policies = {
                      + ntp = [
                          + {
                              + description = "Prod NTP3 Policy"
                              + enabled     = true
                              + name        = "Demo-prod_ntp1"
                              + ntp_servers = [
                                  + "1.1.1.3",
                                  + "3.3.3.3",
                                ]
                              + timezone    = "America/Los_Angeles"
                            },
                          + {

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.