{"id":20324593,"url":"https://github.com/netascode/nx-as-code","last_synced_at":"2026-03-19T15:15:58.562Z","repository":{"id":47057223,"uuid":"403579962","full_name":"netascode/nx-as-code","owner":"netascode","description":"Deploy and test Nexus configuration in a declarative way ","archived":false,"fork":false,"pushed_at":"2022-02-06T20:37:48.000Z","size":541,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-30T13:12:19.082Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netascode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-06T10:28:28.000Z","updated_at":"2023-10-19T07:25:07.000Z","dependencies_parsed_at":"2022-09-14T05:42:24.491Z","dependency_job_id":null,"html_url":"https://github.com/netascode/nx-as-code","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/netascode/nx-as-code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netascode%2Fnx-as-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netascode%2Fnx-as-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netascode%2Fnx-as-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netascode%2Fnx-as-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netascode","download_url":"https://codeload.github.com/netascode/nx-as-code/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netascode%2Fnx-as-code/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30240337,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T00:58:18.660Z","status":"ssl_error","status_checked_at":"2026-03-08T00:55:48.608Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T19:34:37.868Z","updated_at":"2026-03-08T01:05:42.055Z","avatar_url":"https://github.com/netascode.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"Implement NetDevOps practices on Nexus Infrastructure:  NX-OS Management using RESTCONF\n=====================================================================================\n[![published](https://static.production.devnetcloud.com/codeexchange/assets/images/devnet-published.svg)](https://developer.cisco.com/codeexchange/github/repo/netascode/nx-as-code)\n\nA modular Ansible role to validate, configure and test VXLAN-EVPN Fabrics on NX-OS switches from a Jenkins Pipeline\n\n## Use Case Description\n\nAutomate the management of your Nexus-based Data Center Infrastructure leveraging Open Source Tools. This repository contains an [Ansible](https://www.ansible.com/) role named the `nexus_manage_restconf` which validates, configures and tests the configurations deployed on you Nexus switches.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"images/netdevops.png\" border=\"0\" alt=\"nx-as-code\"\u003e\n\u003cbr/\u003e\n\nThe code uses [Jinja2](https://jinja.palletsprojects.com/en/3.0.x/) Templates to dynamically render JSON files compliant with the NX-OS [OpenConfig](https://www.openconfig.net/) [YANG](https://github.com/YangModels/yang/tree/master/vendor/cisco/nx) Model. The JSON payloads are afterwards sent via HTTPS to the Nexus [RESTCONF](https://datatracker.ietf.org/doc/html/rfc8040) API. The code also uses Jinja2 Templates to dynamically render [Robot Framework](https://robotframework.org/) test suites which verify the operational status of the different protocols configured on the Nexus switches.\n\nThe current state of the project only allows you configure the protocols required to spin up a VXLAN-EVPN Fabric, however its modular architecture allows you to easily extend support to other protocols.\n\nThe Ansible Playbooks can be executed directly on a shell or can be executed by any CI/CD tool. This repository also contains a simple example of a [Jenkins](https://www.jenkins.io/) CI/CD Pipeline. \n\nThis projects aims to implement GitOps practices on Nexus Switches by declaring the switch configuration as Code.\n\n## Prerequisites \n\nMake sure to have Python 3.7+ and Ansible 2.9+ installed on your computer or Jenkins server.\n\n## Installation\n\nThe Ansible playbooks in this repository can be executed on your machine or on a Jenkins Server. In any case make sure to install the libraries listed in the `requirements.txt` file\n\n 1. Clone the Github repository\n\n        git clone https://github.com/jgomezve/nexus-as-code\n\n 2. Install the required python libaries\n\n        cd nexus-as-code       \n        pip install -r requirements.txt\n\n## Usage \n\n* Modifiy the Ansible inventory `inventory/hosts.yaml` with the Nexus switches you would like to manage and its corresponding management IP addresses. Here an example:\n\n```yaml\n---\nnetwork:\n  children:\n    nexus:\n      hosts:\n        LEAF1:\n          nexus_host: 192.168.0.1\n          ansible_connection: local\n        LEAF2:\n          nexus_host: 192.168.0.2\n          ansible_connection: local\n        SPINE1:\n          nexus_host: 192.168.0.3\n          ansible_connection: local\n```\n\n* Modify the the Host variables `inventory/host_vars/` based on the configuration you would like to deploy. The schema file (`roles/nexus_manage_restconf/files/nexus_schema`) helps you to verify the supported variables/attributes. Here an example of the BGP configuration on a Spine switch\n\n```yaml\nnexus:\n  bgp:\n    asn: 65001\n    router_id: 192.168.1.1\n    address_families:\n      - type: ipv4\n        subtype: unicast\n      - type: l2vpn\n        subtype: evpn\n        retain_rt: all\n    neighbors:\n      - ip_address: 192.168.1.3\n        remote_asn: 65001\n        update_source: lo0\n        address_families:\n          - type: ipv4\n            subtype: unicast\n            send_community: enabled\n            route_reflector: enabled\n          - type: l2vpn\n            subtype: evpn\n            send_community: enabled\n            route_reflector: enabled\n```\n**Note**: As of today the code supports only the configuration required to set up a VXLAN-EVPN Fabric (OSPF, PIM, BGP, VXLAN). \n\n### Local execution - Single Ansible Playbooks\n\nThis repository contains four different Ansible playbooks, each of them in charge of executing a task withing the network management lifecycle (Validate, Prepare, Deploy \u0026 Test)\n\n\n* `nexus_validate.yaml` uses [yamale](https://github.com/23andMe/Yamale) to verify the variables defined on your host_vars against a pre-defined schema (`roles/nexus_manage_restconf/files/nexus_schema.yaml`).\n\n        ansible-playbook -i inventory/ nexus_validate.yaml \n\n* `nexus_prepare.yaml` uses Ansible built-in modules to enable the RESTCONF API on the managed Nexus devices\n\n        ansible-playbook -i inventory/ nexus_prepare.yaml -e \"username=\u003c\u003cusername\u003e\u003e password=\u003c\u003cpassword\u003e\u003e\"\n\n* `nexus_deploy.yaml` uses Jinja2 Templates to render JSON files which are latter sent to the Nexus RESTCONF API\n\n        ansible-playbook -i inventory/ nexus_deploy.yaml -e \"username=\u003c\u003cusername\u003e\u003e password=\u003c\u003cpassword\u003e\u003e\"\n\n* `nexus_test.yaml` uses Jinja2 Templates to render RobotFramework Test suites which verify the operational status of the protocols configured on the Nexus switches\n\n        ansible-playbook -i inventory/ nexus_deploy.yaml -e \"username=\u003c\u003cusername\u003e\u003e password=\u003c\u003cpassword\u003e\u003e\"\n\n### Jenkins CI/CD Pipeline\n\nThis respository also contains a sample of a __Jenkinsfile__ which in a declarative way describes the Pipeline stages. Folow these steps in order to link you GitHub repository with a Jenkins server:   \n\n* Configure a Webhook on your Github repository. More information here https://docs.github.com/en/developers/webhooks-and-events/webhooks/creating-webhooks\n\n![alt text](images/webhook.png?raw=true)\n\n* The __Jenkins__ file uses the credentials named `nexus_credentials` to configure the Nexus switches. Set up global credentials with that name on the Jenkins server. More information here https://www.jenkins.io/doc/book/using/using-credentials/\n\n![alt text](images/credentials.png?raw=true)\n\n* Create a Pipeline through the Jenkins classic UI. More information here https://www.jenkins.io/doc/book/pipeline/getting-started/#defining-a-pipeline-in-scm\n\n![alt text](images/pipeline_creation_jenkins.png?raw=true)\n\n* Now everytime you push changes to your Git repository a Pipeline execution will be triggered on Jenkins which in turn will execute the Validation, Preparation, Deployment and Testing phases on your managed Nexus switches. Jenkins will display the outcome of each stage and  publish Robot Framework HTML reports and JUnit tests results.\n\n![alt text](images/jenkins_status.png?raw=true)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetascode%2Fnx-as-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetascode%2Fnx-as-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetascode%2Fnx-as-code/lists"}