Git Product home page Git Product logo

ansible-nxos's Introduction

Ansible - NXOS

published Run in Cisco Cloud IDE

Kickstart your Cisco NXOS automation journey with Ansible. This project will help you get started with your Network Automation journey by show casing a simple Ansible setup which you can run in a VSCode Devcontainer or on any Linux machine with Python ^3.11 installed. It includes a couple of playbooks which are used to demonstrate how easy it can be to write automation tasks for NXOS in Ansible. Be it to configure your system or simply to get status information.

Installation

There are two ways how you can make use of this project. You can run it in a VSCode Devcontainer or you can install all dependencies directly on your Linux host.

Getting the code

To get the code simply clone it from Github or GitLab

git clone https://gitlab.com/anyweb/cisco-code-exchange/ansible-nxos.git

VSCode Devcontainer

To use this project with the pre-configured VSCode Devcontainer you must make sure that you have the pre-requisites installed. After that just go to the project folder where you cloned this project into and open VSCode

cd ansible-nxos
code .

Once the VSCode window has opened you can start the Devcontainer with:

  1. Hit Ctrl-Shift-p on your keyboard to launch the command prompt.
  2. Search for Dev Containers: Reopen in Container or Dev Containers: Rebuild Container in the search bar and hit enter

A container with all dependencies installed will be built and started so you can get started without thinking about it too much.

Linux

If you don't want to or can't use VSCode Devcontainer you still can make use of this project by following these steps.

With poetry

If Poetry is available on your system, you can install dependencies with:

poetry install --no-root
ansible-galaxy collection install -r ./requirements_ansible.yml --force

Without poetry

Otherwise you can use Pip to install all dependencies with:

pip install -r ./requirements_python-dev.txt
ansible-galaxy collection install -r ./requirements_ansible.yml --force

Configuration

NX-OS Authentication

All playbooks in this project connect via NX-API to your switches. Make sure that this feature is enabled.

nxos# configure terminal
nxos(config)# feature nxapi

User name and password for authentication can be passed to ansible via environment variables.

export NXOS_USER="my-api-user"
export NXOS_PASSWORD="my-super-secure-password"

NX-OS Backup Location

Playbooks which provide a backup functionality will save the backup to the ./backup folder. You can overwrite this behavior with the NXOS_BACKUP_LOCATION environment variable.

export NXOS_BACKUP_LOCATION="/path/to/my/backup/location"

NX-OS Configuration File

Playbook which provide a configuration functionality will load the configuration variables from the nxos-config.yml file. You can overwrite this behavior with the NXOS_CONFIGURATION_FILE environment variable.

export NXOS_CONFIGURATION_FILE="/path/to/my/configuration/file"

Usage

The following playbooks are available for demonstration purposes:

Playbook Description Configuration environment variable Configuration default
backup_config.yml Backup running-config to file NXOS_BACKUP_LOCATION ./backup -> NX-OS Backup Location
configure_vlans.yml Configure VLANs NXOS_CONFIGURATION_FILE ./vars/nxos-config.yml -> NX-OS Configuration File
configure_vrf.yml Configure VRFs NXOS_CONFIGURATION_FILE ./vars/nxos-config.yml -> NX-OS Configuration File
gather_facts.yml Gather and display all NX-OS facts
show_vlans.yml Display output of show vlan brief
show_vrfs.yml Display output of show vrf

To execute a playbook you can use the command ansible-playbook playbooks/{{ playbook_name }}.

Example:

ansible-playbook playbooks/show_vlans.yml

DevNet Sandbox

To try out this project you can use the Cisco NX-OS Sandbox Lab. Sandbox details such as username & password can be found here.

Author(s)

This project was written and is maintained by the following individuals:

ansible-nxos's People

Contributors

tepene avatar

Stargazers

Alexander Stevenson avatar

Watchers

Thomas Lanz 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.