Skip to content

community.yang.generate_spec generating bad json for openconfig-system #57

@stevenca

Description

@stevenca
SUMMARY

community.yang.generate_spec generating bad json for openconfig-system

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.yang.generate_spec

ANSIBLE VERSION
$ ansible --version
ansible 2.10.7
  config file = /Users/stevenca/Workspaces/mdd/ansible.cfg
  configured module search path = ['/Users/stevenca/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/stevenca/Workspaces/mdd/venv-mdd/lib/python3.9/site-packages/ansible
  executable location = /Users/stevenca/Workspaces/mdd/venv-mdd/bin/ansible
  python version = 3.9.0 (default, Dec  6 2020, 18:02:34) [Clang 12.0.0 (clang-1200.0.32.27)]
CONFIGURATION
$ ansible-config dump --only-changed
[DEPRECATION WARNING]: DEFAULT_HASH_BEHAVIOUR option, this feature is fragile and not portable, leading to continual confusion and misuse, use the ``combine`` filter explicitly instead. This feature will be removed from ansible-base in version 2.13. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
COLLECTIONS_PATHS(/Users/stevenca/Workspaces/mdd/ansible.cfg) = ['/Users/stevenca/Workspaces/mdd']
DEFAULT_HASH_BEHAVIOUR(/Users/stevenca/Workspaces/mdd/ansible.cfg) = merge
DEFAULT_HOST_LIST(/Users/stevenca/Workspaces/mdd/ansible.cfg) = ['/Users/stevenca/Workspaces/mdd/inventory/arch2']
DEFAULT_ROLES_PATH(/Users/stevenca/Workspaces/mdd/ansible.cfg) = ['/Users/stevenca/Workspaces/mdd/roles']
HOST_KEY_CHECKING(/Users/stevenca/Workspaces/mdd/ansible.cfg) = False
INTERPRETER_PYTHON(/Users/stevenca/Workspaces/mdd/ansible.cfg) = auto_silent
PERSISTENT_COMMAND_TIMEOUT(/Users/stevenca/Workspaces/mdd/ansible.cfg) = 60
PERSISTENT_CONNECT_TIMEOUT(/Users/stevenca/Workspaces/mdd/ansible.cfg) = 60
OS / ENVIRONMENT

Cisco IOS XE Software, Version 17.01.01

STEPS TO REPRODUCE

Run the playbook below

- hosts: internet-rtr1
  connection: ansible.netcommon.netconf
  gather_facts: no
  tasks:
    - name: generate spec from open-config interface yang model data and represent in xml, json and yang tree
      community.yang.generate_spec:
        file: "./openconfig/release/models/{{ item }}/openconfig-{{ item }}.yang"
        search_path: "./openconfig/release/models"
        doctype: config
        json_schema:
          path: "./specs/openconfig-{{ item }}-config.json"
          defaults: True
        xml_schema:
          path: "./specs/openconfig-{{ item }}-config.xml"
          defaults: True
          annotations: True
        tree_schema:
          path: "./specs/openconfig-{{ item }}-config.tree"
      loop:
        - interfaces
        - system
EXPECTED RESULTS

dns search and host entry lists show be constructed properly

ACTUAL RESULTS

dns search and host entry lists are not constructed properly

$ cat specs/openconfig-system-config.json
{
    "openconfig-system:system": {
        "config": {
            "hostname": "",
            "domain-name": "",
            "login-banner": "",
            "motd-banner": ""
        },
        "clock": {
            "config": {
                "timezone-name": ""
            }
        },
        "dns": {
            "config": {
                "search": [
                    "[",
                    "]"
                ]
            },
            "servers": {
                "server": [
                    {
                        "address": "",
                        "config": {
                            "address": "",
                            "port": "53"
                        }
                    }
                ]
            },
            "host-entries": {
                "host-entry": [
                    {
                        "hostname": "",
                        "config": {
                            "hostname": "",
                            "alias": [
                                "[",
                                "]"
                            ],
                            "ipv4-address": [
                                "[",
                                "]"
                            ],
                            "ipv6-address": [
                                "[",
                                "]"
                            ]
                        }
                    }
                ]
            }
        },
        "ntp": {
            "config": {
                "enabled": "False",
                "ntp-source-address": "",
                "enable-ntp-auth": "False"
            },
            "ntp-keys": {
                "ntp-key": [
                    {
                        "key-id": "",
                        "config": {
                            "key-id": "",
                            "key-type": "",
                            "key-value": ""
                        }
                    }
                ]
            },
            "servers": {
                "server": [
                    {
                        "address": "",
                        "config": {
                            "address": "",
                            "port": "123",
                            "version": "4",
                            "association-type": "SERVER",
                            "iburst": "False",
                            "prefer": "False"
                        }
                    }
                ]
            }
        },
        "grpc-server": {
            "config": {
                "enable": "True",
                "port": "9339",
                "transport-security": "True",
                "certificate-id": "",
                "metadata-authentication": "False",
                "listen-addresses": [
                    "[",
                    "]"
                ]
            }
        },
        "ssh-server": {
            "config": {
                "enable": "True",
                "protocol-version": "V2",
                "timeout": "",
                "rate-limit": "",
                "session-limit": ""
            }
        },
        "telnet-server": {
            "config": {
                "enable": "False",
                "timeout": "",
                "rate-limit": "",
                "session-limit": ""
            }
        },
        "logging": {
            "console": {
                "config": {},
                "selectors": {
                    "selector": [
                        {
                            "facility": "",
                            "severity": "",
                            "config": {
                                "facility": "",
                                "severity": ""
                            }
                        }
                    ]
                }
            },
            "remote-servers": {
                "remote-server": [
                    {
                        "host": "",
                        "config": {
                            "host": "",
                            "source-address": "",
                            "remote-port": "514"
                        },
                        "selectors": {
                            "selector": [
                                {
                                    "facility": "",
                                    "severity": "",
                                    "config": {
                                        "facility": "",
                                        "severity": ""
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        },
        "aaa": {
            "config": {},
            "authentication": {
                "config": {
                    "authentication-method": [
                        "[",
                        "]"
                    ]
                },
                "admin-user": {
                    "config": {
                        "admin-password": "",
                        "admin-password-hashed": ""
                    }
                },
                "users": {
                    "user": [
                        {
                            "username": "",
                            "config": {
                                "username": "",
                                "password": "",
                                "password-hashed": "",
                                "ssh-key": "",
                                "role": ""
                            }
                        }
                    ]
                }
            },
            "authorization": {
                "config": {
                    "authorization-method": [
                        "[",
                        "]"
                    ]
                },
                "events": {
                    "event": [
                        {
                            "event-type": "",
                            "config": {
                                "event-type": ""
                            }
                        }
                    ]
                }
            },
            "accounting": {
                "config": {
                    "accounting-method": [
                        "[",
                        "]"
                    ]
                },
                "events": {
                    "event": [
                        {
                            "event-type": "",
                            "config": {
                                "event-type": "",
                                "record": ""
                            }
                        }
                    ]
                }
            },
            "server-groups": {
                "server-group": [
                    {
                        "name": "",
                        "config": {
                            "name": "",
                            "type": ""
                        },
                        "servers": {
                            "server": [
                                {
                                    "address": "",
                                    "config": {
                                        "name": "",
                                        "address": "",
                                        "timeout": ""
                                    },
                                    "tacacs": {
                                        "config": {
                                            "port": "49",
                                            "secret-key": "",
                                            "secret-key-hashed": "",
                                            "source-address": ""
                                        }
                                    },
                                    "radius": {
                                        "config": {
                                            "auth-port": "1812",
                                            "acct-port": "1813",
                                            "secret-key": "",
                                            "secret-key-hashed": "",
                                            "source-address": "",
                                            "retransmit-attempts": ""
                                        }
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        },
        "memory": {
            "config": {}
        },
        "processes": {},
        "messages": {
            "config": {
                "severity": ""
            },
            "debug-entries": {
                "debug-service": [
                    {
                        "service": "",
                        "config": {
                            "service": "",
                            "enabled": "False"
                        }
                    }
                ]
            }
        },
        "license": {
            "licenses": {
                "license": [
                    {
                        "license-id": "",
                        "config": {
                            "license-id": "",
                            "license-data": "",
                            "active": "False"
                        }
                    }
                ]
            }
        }
    }
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions