{"id":20074206,"url":"https://github.com/juniper/nita-ansible","last_synced_at":"2025-09-12T02:12:54.909Z","repository":{"id":40541225,"uuid":"310604343","full_name":"Juniper/nita-ansible","owner":"Juniper","description":"Ansible, a radically simple IT automation engine, part of the Juniper NITA solution","archived":false,"fork":false,"pushed_at":"2025-06-10T16:04:18.000Z","size":259,"stargazers_count":8,"open_issues_count":6,"forks_count":11,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-10T17:47:35.048Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/Juniper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-06T13:26:33.000Z","updated_at":"2025-06-10T16:04:23.000Z","dependencies_parsed_at":"2023-11-07T18:25:57.930Z","dependency_job_id":"5902ba11-ea29-4706-b618-fcb74b5dbb5b","html_url":"https://github.com/Juniper/nita-ansible","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Juniper/nita-ansible","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Juniper%2Fnita-ansible","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Juniper%2Fnita-ansible/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Juniper%2Fnita-ansible/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Juniper%2Fnita-ansible/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Juniper","download_url":"https://codeload.github.com/Juniper/nita-ansible/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Juniper%2Fnita-ansible/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261937031,"owners_count":23232845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-13T14:49:52.475Z","updated_at":"2025-06-25T19:03:55.724Z","avatar_url":"https://github.com/Juniper.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"[branch]: https://github.com/Juniper/nita/tree/23.12\n[readme]: https://github.com/Juniper/nita/blob/23.12/README.md\n[create_ansible_job_k8s]: https://github.com/Juniper/nita-jenkins/blob/23.12/create_ansible_job_k8s.py\n\n# NITA Ansible 23.12\n\nWelcome to NITA, an open source platform for automating the building and testing of complex networks.\n\n# Release Notes\nThe major change in this version is that all components now run within pods under the control of Kubernetes, rather than as Docker containers. Consequently we have updated the way that Ansible runs because it is now controlled by Kubernetes instead of Docker. \n\nPlease refer to the [README][readme] for more details.\n\n# Installing\n\nThe simplest way to install nita-ansible is by installing the nita repositories, which can be done by running the ``install.sh`` script located and in the parent [nita repo][branch] as described [here][readme]. You can also install nita-ansible as a standalone Docker container, which can run independently of the NITA containers that are running under Kubernetes.\n\n## Accessing the nita-ansible container\n\nNote that the nita-ansible container is ephemeral, i.e. it is started and stopped by Jenkins when it is needed for a job. However, you can start an instance of a new Ansible container and access it via the shell simply be running the following command:\n\n```\nuser@host$ nita-cmd ansible cli\nIf you don't see a command prompt, try pressing enter.\nnita-ansible:~# exit\nexit\npod \"nita-ansible\" deleted\nuser@host$\n```\n\n:warning: Unlike docker, many of the arguments needed by kubectl are defined in YAML files rather than being passed on the command line. For example, if you wish to mount a volume in a container from the host, you will need to define it in a YAML file. We use a python script ``create_ansible_job_k8s.py`` ([see link][create_ansible_job_k8s]) to create the required job_yaml, and you can use this as an example if you want to create your own ansible containers.\n\nIf you want to run a standalone Ansible container with your own playbooks and/or roles, we recommend doing so as a Docker container, described below.\n\n# Running a Standalone Ansible Docker Container\n\nWe provide the ability for you to run Ansible as a standalone Docker container, without having to use the other parts of NITA that are controlled by Kubernetes, such as Jenkins, Robot Framework or the Webapp.  This is very handy if you want to be able to quickly just run an instance of Ansible with your own playbooks or roles, as is explained below.\n\n## Ansible Versions: 2.10 and greater\n\nStarting with Ansible 2.10, juniper.device and junipernetworks.junos ansible collections are available. This collection has been included in the requirements.yml file and will be built into the NITA container automatically. The existing juniper.junos role is still supported and works with Ansible 2.10. For more information on this transition see https://www.juniper.net/documentation/us/en/software/junos-ansible/ansible/topics/concept/junos-ansible-modules-overview.html and https://galaxy.ansible.com/juniper/device. Juniper.junos roles has been removed and are superceded by the newer collections. If the old roles are still required, simply uncomment the line from the standalone ``Dockerfile``:\n\n```\nRUN ansible-galaxy install Juniper.junos -p /etc/ansible/roles/\n```\n\nThe network-roles that the Docker container copies over have been updated to remove the dependencies on the old roles and will use the collections.\n\n## Using Standalone nita-ansible\n\nThis Docker container holds Ansible executables, related libraries, and files for managing Juniper devices using Ansible. The NITA framework uses the nita-ansible container to run ansible playbooks included with the framework. Nita-ansible can also be used as a standalone container for executing your own playbooks. Simply put your inventory file and playbooks into a new project folder on the system hosting the Docker container. You will also want to put a bash script to execute the ```ansible-playbook``` command.\n\n### A Simple Project Folder Example\n\nA simple project folder with a single playbook may look like this:\n\n```\n-rw-rw-r-- 1 auser auser  972 Jun  4 16:21 playbook.yml\n-rw-rw-r-- 1 auser auser  148 Jun  4 10:42 hosts\n-rwxrwxr-x 1 auser auser  136 Jun  4 16:22 runme.sh\n```\n\nThe ```runme.sh``` should execute the playbook pointing to the hosts file as follows:\n\n```\n#!/bin/bash\nansible-playbook -i hosts playbook.yml\n```\n### Using Standalone nita-ansible with your project folder\n\nTo use the standalone nita-ansible Docker container with your project folder, simply use the ```docker run``` command, mounting your project folder onto the Docker container and passing the command to run your script like the example below:\n\n```\ndocker run -u root -v /project_folder:/container_folder:rw  --rm  -it --name ansible juniper/nita-ansible:\u003cversion\u003e /bin/bash -c \"cd /container_folder; ./runme.sh\"\n```\n### Troubleshooting playbooks\n\nYou can execute the playbook into a bash shell and troubleshoot from the project folder mounted inside the Docker container if your playbooks are not operating correctly by issuing the ```docker run``` command above with just the bash shell (remove everything after ```/bin/bash```).\n\n## Built-in Ansible roles\n\nStandalone nita-ansible contains many built-in roles for building Juniper configuration files related to an EVPN VXLAN IP fabric. An example of a project using these roles can be found at https://github.com/Juniper/nita-webapp/tree/main/examples/evpn_vxlan_erb_dc. When invoking the Docker container to use these roles an additional output directory needs to be mounted for the configuration files to be built and stored in the /container_build_folder (the example uses /var/tmp/build) folder as follows:\n\n```\ndocker run -u root -v /project_folder:/container_folder:rw -v /local_output_folder:/container_build_folder --rm  -it --name ansible juniper/nita-ansible:\u003cversion\u003e /bin/bash -c \"cd /container_folder; ./runme.sh\"\n```\n\nWhen invoking these built-in roles the build-folder needs to be passed to the ansible as a variable in the runme.sh file like this:\n\n```\nansible-playbook -i hosts playbook.yaml --extra-vars \"build_dir=container_build_folder\"\n```\n### ebgp_ip_fabric\n\nBuilds the configuration stanzas that make up a Junos eBGP IP fabric underlay. It includes configurations for forwarding, routing, and policy options as well as interfaces participating in the fabric and BGP protocol configuration. In the sample Excel file included with the NITA package for EVPN data center, the tabs that hold the variable information include \"underlay_ebgp+\", \"core_interfaces+\", \"underlay_ebgp+\"\n\nInvoking this role from ansible playbook can be accomplished as follows:\n```\n- hosts: switches\n  connection: local\n  roles:\n    - { role: junos_qfx_common }\n    - { role: ebgp_ip_fabric }\n```\n\n### evpn_vxlan_common\n\nBuilds the configuration stanzas that make up a Junos policy and routing options for leaf nodes. It also checks the leaf_type variable and if it is type \"border\" will create the policy to export default routes via both EVPN and OSPF. Invoking this role from an ansible playbook can be accomplished as follows:\n```\n- hosts: leaves\n  connection: local\n  roles:\n    - { role: evpn_vxlan_common }\n```\n\nIncluded in the evpn_vxlan_common role is \u003cb\u003ejunos_commit_config\u003c/b\u003e role which includes examples for using juniper.junos roles (commented out) and juniper.device collection (see \u003cb\u003eansible 2.10 and greater\u003c/b\u003e above)\n\n### evpn_vxlan_dci\n\nBuilds the configuration stanzas that make up a eBGP routing for DCI connectivity. In the sample Excel file included with the NITA package for EVPN data center, the tab that holds the variable is \"dci_ebgp+\". Invoking this role from an ansible playbook can be accomplished as follows:\n\n```\n- hosts: leaves\n  connection: local\n  roles:\n    - { role: evpn_vxlan_dci }\n```\n\n### evpn_vxlan_erb_leaf\n\nBuilds the configuration stanzas that make up iBGP EVPN overlay configuration for leafs in spine/leaf IP fabric. Also includes configuration for related switch-options stanza in Junos (vtep source interface, route-distinguisher, vrf-target).\nIn the sample Excel file included with the NITA package for EVPN data center, the tabs that hold the variable information include \"evpn_ibgp+\" and \"base\". Invoking this role from an ansible playbook can be accomplished as follows:\n\n```\n- hosts: leaves\n  connection: local\n  roles:\n    - { role: evpn_vxlan_erb_leaf }\n```\n\n### evpn_vxlan_erb_spine\n\nBuilds the configuration stanzas that make up iBGP EVPN overlay \"lean\" spines as iBGP route-reflectors for family evpn signaling. Of particular interest the configuration implicitly allows all neighbors from the defined loopback_subnet. This means all the leafs will initiate the BGP connection.\nIn the sample Excel file included with the NITA package for EVPN data center,  the tabs that hold the variable information include \"evpn_ibgp+\" and \"base\". Invoking this role from an ansible playbook can be accomplished as follows:\n\n```\n- hosts: spines\n  connection: local\n  roles:\n    - { role: evpn_vxlan_erb_spine }\n```\n\n### evpn_vxlan_port\n\nBuilds the configuration stanzas that make up L2 port information for devices connected to leafs in an EVPN VXLAN IP Fabric. Configures ports, ESIs, VLANs, LAGs, and IP addresses. In the sample Excel file included with the NITA package for EVPN data center, the tabs that hold the variable information include \"evpn_port+\" and \"base\". Invoking this role from an ansible playbook can be accomplished as follows:\n\n```\n- hosts: leaves\n  connection: local\n  roles:\n    - { role: evpn_vxlan_port }\n```\n\n### evpn_vxlan_vni\n\nBuilds the configuration stanzas that make up VNI information for EVPN VXLAN configuration.\nIn the sample Excel file included with the NITA package for EVPN data center, the tabs that hold the variable information include \"vnis+\". Invoking this role from an ansible playbook can be accomplished as follows:\n\n```\n- hosts: leaves\n  connection: local\n  roles:\n    - { role: evpn_vxlan_vni }\n```\n\n### evpn_vxlan_vrf\n\nBuilds the configuration stanzas that make up VRF for EVPN VXLAN configuration. In the sample Excel file included with the NITA package for EVPN data center, the tabs that hold the variable information include \"vrfs+\" (and indirectly \"vnis+\". The example datacenter uses route-targets and does not create unique policies for each VRF. Invoking this role from an ansible playbook can be accomplished as follows:\n\n```\n- hosts: leaves\n  connection: local\n  roles:\n    - { role: evpn_vxlan_vrf }\n```\n\n### Junos_common\n\nBuilds the configuration stanzas that make that includes configuration stanzas common to all junos devices. Configures ethernet device aggregation in chassis, grpc under system services, management interface (will configure DHCP if no IP address is assigned), static routes under routing-options, and snmp. It is invoked:\n\n```\n- hosts: switches\n  pre_tasks:\n  connection: local\n  roles:\n    - { role: junos_common }\n```\n\n### junos_qfx_common\n\nThis includes the configuration templates for the base Junos config portion of a QFX switch. In the sample Excel file included with the NITA package for EVPN data center, the tabs that hold the variable information related to this role include \"base\" and \"password_hashes\".\n\nInvoking this role from ansible playbook can be accomplished as follows:\n\n```\n- hosts: switches\n  connection: local\n  roles:\n    - { role: junos_qfx_common }\n```\n\n### srx_common and srx_firewall\n\nThis includes the configuration templates for the base Junos config portion of an switch. In the sample Excel file included with the NITA package for EVPN data center, the tabs that hold the variable information related to this role include \"base\", \"password_hashes\", \"vrfs+\", and \"firewall_port+\".\n\nInvoking this role from ansible playbook can be accomplished as follows:\n\n```\n- hosts: firewalls\n  pre_tasks:\n  connection: local\n  roles:\n    - { role: junos_common }\n    - { role: srx_common }\n    - { role: srx_firewall }\n```\n\n### junos_commit_config\n\nOnce the device configuration files have been built and stored in the build folder, this role will manually commit the configuration files to their respective Junos device. Invokes as follows:\n\n```\n- hosts: all\n  connection: local\n  gather_facts: no\n  roles:\n    - { role: junos_commit_config }\n```\n\n## Additional roles\n\nIf you need additional roles for your playbooks, create a folder in project directory called ```roles``` and copy the appropriate files from your local ansible installation's role folder. Ansible will look in ```/container_folder/roles``` for any roles that are not already installed in the Docker container itself.\n\n## mx_common\n\nThis role is not actually included in the default container build but is an example of a role that can be added via the project. This role is located at https://github.com/Juniper/nita-webapp/tree/main/examples/ebgp_wan and NITA loads it under the roles folder in the project folder.\n\nThis role contains junos configuration statements for the MX router in the WAN role in the NITA example project.\n\n## Examples\n\nMore complex examples of project folders can be found in the larger NITA project itself, particularly at https://github.com/Juniper/nita/tree/main/examples.\n\n# Copyright\n\nCopyright 2024, Juniper Networks, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuniper%2Fnita-ansible","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuniper%2Fnita-ansible","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuniper%2Fnita-ansible/lists"}