Introduction to Nornir | Python Network Automation!

Поділитися
Вставка
  • Опубліковано 10 лют 2025

КОМЕНТАРІ • 47

  • @hassinba
    @hassinba 4 роки тому +2

    Watching your CBT Nuggets now, you're the first person to not just mention that it's not best practice to store credentials in plain text, but how to actually properly store them and call on them, thank you.

    • @IPvZero
      @IPvZero  4 роки тому

      Hey h! Thanks so much. I really appreciate it. Trying my best to give out real world practical info!! :)
      -John

  • @frankiefuryland
    @frankiefuryland 2 роки тому

    Nice to hear a fellow Scottish voice talking networking. Looking forward to following your content. This wis crackin'!

  • @aslanabdurahmanov
    @aslanabdurahmanov 4 роки тому +1

    You nailed it! Awesome explanation with instant result.... bravo John!

    • @IPvZero
      @IPvZero  4 роки тому

      Thanks so much, Aslan! I really appreciate it! :)
      -John

  • @IPvZero
    @IPvZero  4 роки тому +2

    IMPORTANT NOTE: Nornir has now upgraded to Nornir3. This configurations in this video worked for the previous version.
    To setup Nornir3 see my newer video:
    ua-cam.com/video/e-ynGenf8pk/v-deo.html
    Link to my Python Network Automation course at CBT Nuggets: learn.gg/adv-net

  • @alreid12345
    @alreid12345 5 років тому +1

    Great video John and good to see the difference between Ansible, NAPALM and now Nornir.
    If using this topology across multiple vids and sessions would you consider uploading the EVE-NG topology (these also usually contain the saved config files as part of exported zip).
    Thanks again and keep up the great work.

    • @IPvZero
      @IPvZero  5 років тому +3

      Hey Al! Good to hear your feedback again!
      About EVE-NG, I can upload the topology no problem, although there isn't really anything too interesting going on haha - just a single IP address on each router and the SSH login info. For the automation all I'm doing is using the EVE-NG "management" cloud so I reach the topology from my host PC and using the "Windows Subsystem For Linux" to get a Ubuntu terminal on my Windows 10 machine. The Linux Server you see in the topology is just a graphic in effect to make it easier for beginners to conceptualise what's going on, rather than see everything being controlled "from a cloud" haha.
      So the actual scripts etc wouldn't be saved as part of the EVE zip! But like I say, it's no problem to upload it if you'd still like to use it!
      Thanks again! :)
      -John

  • @BlindPigBluesBand
    @BlindPigBluesBand 5 років тому +1

    Awesome content. Thanks!

    • @IPvZero
      @IPvZero  5 років тому

      Thanks, Gerardo! Very kind of you :)
      -John

  • @BorisV8V
    @BorisV8V 3 роки тому

    Hello John, do you have a video where you show how to deal with Confirm Y/N prompts after you send a command?

  • @HenriqueAlencarDF
    @HenriqueAlencarDF 4 роки тому

    It's very helpful, thanks for sharing.

    • @IPvZero
      @IPvZero  4 роки тому

      Thanks, Henrique!! Really appreciate hearing your feedback!
      -John

  • @JeDeXxRioProKing
    @JeDeXxRioProKing 5 років тому

    great vid Man thanks a lot

    • @IPvZero
      @IPvZero  5 років тому +2

      Thanks, Sefraoui! Really appreciate it :)
      -John

  • @avinashshankarpalli2130
    @avinashshankarpalli2130 4 роки тому

    when i executed the script2 in pycharm connecting to gns3, for "nr = InitNornir()" it was throwing a hosts file not found error so i replaced it with "nr = InitNornir(config_file='config.yml')" and then the error went away.Is it compulsory to add config .yml in initnornir?As I see you ran it without it and it did not throw any error for you

    • @IPvZero
      @IPvZero  4 роки тому

      Hey, Avinash. You don't need to explictly state the config file - although I almost always do. Nornir should automatically look in this current directory for "hosts.yaml" etc. I suspect that your hosts file etc is named "hosts.yml" - ie yml, not yaml. It didn't find it. I'd need to lab that just to be sure but that's my suspicion :)
      -John

  • @2ronaldinho21
    @2ronaldinho21 3 роки тому

    what ia have wrong in my env ? ModuleNotFoundError: No module named 'nornir.plugins.tasks.networking'

    • @IPvZero
      @IPvZero  3 роки тому +1

      Hey, Pavel. This is an older video which uses Nornir2. Now the current version is Nornir3. The imports are all different. I cover the changes you have to make in this video here:
      ua-cam.com/video/e-ynGenf8pk/v-deo.html
      Hope that helps :)
      -John

    • @2ronaldinho21
      @2ronaldinho21 3 роки тому

      @@IPvZero Thank you for your message.Yes that was the problem. Now works like a charm :)

  • @SoulJah876
    @SoulJah876 4 роки тому

    I tried doing this in a GNS docker image (Python,Go,Perl,PHP) but got nowhere. Got bogged down just trying to get the correct pip version installed because Nornir wouldn't run

    • @IPvZero
      @IPvZero  4 роки тому +1

      Hey, SoulJah. Sorry to hear you're having issues. I just tried installing it on a new VM there and it worked okay. What I did was install pip3, and then pip3 installed Nornir:
      1) sudo apt install python3-pip
      2) pip3 install nornir
      Hopefully that helps!
      -John

    • @SoulJah876
      @SoulJah876 4 роки тому

      @@IPvZero I did this but hit an error on the first line at import. I'll try again in a couple hours but with the stock set up and lab.
      from nornir import InitNornir
      File "/usr/local/lib/python3.5/dist-packages/nornir/__init__.py", line 3, in
      from nornir.init_nornir import InitNornir
      File "/usr/local/lib/python3.5/dist-packages/nornir/init_nornir.py", line 22
      return f"{cls.__module__}.{cls.__name__}"

    • @IPvZero
      @IPvZero  4 роки тому

      @@SoulJah876 Ah I see you've got an older version of Python3. Python3.5 does not support f strings, so it'll crash. You'll need to update to Python version 3.6.2 or above :)

  • @DineshKumar-uw3yn
    @DineshKumar-uw3yn 4 роки тому

    1.Is it possible to promote to enter username and password and enable password ? 2. As we are using same ios is it possible to call list if host name from file ? 3. As we are using list of commands is it possible to call list if commands from file ?

    • @IPvZero
      @IPvZero  4 роки тому +1

      Hey, Dinesh! UA-cam only gave me an alert for this today. Sorry about the delay! Yeah, if you watch my video here - you can see how to push commands from a textfile:
      ua-cam.com/video/rE6t7M-3xOI/v-deo.html&
      With regard to prompting username and password, you instruct the script to ask you for the username and store is as a variable, and then pass that variable into to nornir's inventory.
      For example:
      username = input("Please enter your username: ")
      nr = InitNornir()
      nr.inventory.defaults.username = username
      Alternatively you could use Sysargv to pass this value into the script. The same can be done for passwords by importing getpass.
      An example being:
      password = getpass.getpass()
      nr = InitNornir()
      nr.inventory.defaults.password = password
      Hope that helps!
      :)
      -John

    • @DineshKumar-uw3yn
      @DineshKumar-uw3yn 4 роки тому

      @@IPvZero thanks john but let's say I want push some config or get some show output for 500 devices then I can simply the host file and it's hard to write host file right ? Is it possible to copy past 500 device to text file and call it to script if yes please give me idea how can do it and also to enter enable password ?

    • @IPvZero
      @IPvZero  4 роки тому

      @@DineshKumar-uw3yn Hey, Dinesh I'm still a little unsure of what you're looking to do. Are you asking - can you, for example, use Nornir to gather the running configs for each devices and save the output to a seperate text file. And then you could call upon those textfiles as configurations in another script?

    • @IPvZero
      @IPvZero  4 роки тому +1

      With respect to the enable password, you can specify enable password in your inventory, something like:
      R1:
      connection_options:
      netmiko:
      extras:
      secret: secretpassword
      Then when execute commands use the enable method like so:
      results = nr.run(task=netmiko_send_command, command_string="show run", enable=True)

    • @DineshKumar-uw3yn
      @DineshKumar-uw3yn 4 роки тому

      @@IPvZero thanks for reply john ! I'm already using netmiko with multithread/multiprocess for configuration push and get some show output and Im just checking is there any best way to use nornir+netmiko but I'm feeling this method is very complicated compare to only netmiko...let's say example I want to push config for 1000 devices what I will doI create text file and past 1000 devices but in nornir I'm feeling adding 1000 devices only it will take some time ... and another thing Let's say we have different vendors. Cisco- 200 devices ,Aruba-200 devices , juniper - 100 devices ,. cisco_nxos-100 devies and I want to push different config to different vendor can we do it using with nornir+netmiko and end it should print any failed devices and pushed config should save in different files

  • @preetkochar
    @preetkochar 5 років тому

    How about putting links to specific youtube videos on github so that i can reference videos from github back to youtube.

    • @IPvZero
      @IPvZero  5 років тому

      Hey, GuRpReEt! Good thinking, that's exactly what I'm doing. I'm gradually copying over each videos configs and giving it its own repo! I've started doing this since submitting my material to Cisco Code Exchange to make things cleaner! For example:
      github.com/IPvZero/Archiving_Telemetry
      So we're definitely thinking the same thing haha! Thanks for the feedback, let's me know it's a good move!
      -John

  • @michaelyang8074
    @michaelyang8074 4 роки тому

    I’m getting error with network plugin.

    • @IPvZero
      @IPvZero  4 роки тому +1

      Hey Michael. This video was recording using Nornir2. It has since been updated. Basically the import paths and the config.yaml has changed. Check out my video on Nornir3 on how to make the changes! ua-cam.com/video/e-ynGenf8pk/v-deo.html
      If you have any problems after that, just lemme know :)
      -John

  • @mc-wi8wp
    @mc-wi8wp 4 роки тому

    The Font is still small. And also, just keep it calm. Talk slower and user a non CLI Text editor.

    • @IPvZero
      @IPvZero  4 роки тому

      Keep calm?

    • @mc-wi8wp
      @mc-wi8wp 4 роки тому

      @@IPvZero Because you talk too fast. And for people who are not native English speaker it's not fun!

    • @IPvZero
      @IPvZero  4 роки тому +1

      @@mc-wi8wp Apologies, but that's how people from Scotland speak.

  • @toolate6971
    @toolate6971 4 роки тому

    It seems like a pure asyncio ssh is faster.

    • @IPvZero
      @IPvZero  4 роки тому

      Hey, Too Late! Thanks for watching!
      The benefit in Nornir is really that it simplifies things. It handles all the concurrent execution for you, plus there's get the benefit of in-built features like F Object for filtering, and the Ansible-like inheritance model with the inventory. That said, this is just an introduction to Nornir.
      Currently I'm using Nornir with a tool called Scrapli to run the concurrent connections over SSH2 and it is much faster than what I demonstrate here :)
      -John