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.
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
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.
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
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
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
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
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
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
@@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__}"
@@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 :)
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 ?
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
@@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 ?
@@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?
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)
@@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
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
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
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
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.
Hey h! Thanks so much. I really appreciate it. Trying my best to give out real world practical info!! :)
-John
Nice to hear a fellow Scottish voice talking networking. Looking forward to following your content. This wis crackin'!
You nailed it! Awesome explanation with instant result.... bravo John!
Thanks so much, Aslan! I really appreciate it! :)
-John
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
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.
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
Awesome content. Thanks!
Thanks, Gerardo! Very kind of you :)
-John
Hello John, do you have a video where you show how to deal with Confirm Y/N prompts after you send a command?
It's very helpful, thanks for sharing.
Thanks, Henrique!! Really appreciate hearing your feedback!
-John
great vid Man thanks a lot
Thanks, Sefraoui! Really appreciate it :)
-John
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
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
what ia have wrong in my env ? ModuleNotFoundError: No module named 'nornir.plugins.tasks.networking'
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
@@IPvZero Thank you for your message.Yes that was the problem. Now works like a charm :)
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
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
@@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__}"
@@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 :)
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 ?
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
@@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 ?
@@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?
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)
@@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
How about putting links to specific youtube videos on github so that i can reference videos from github back to youtube.
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
I’m getting error with network plugin.
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
The Font is still small. And also, just keep it calm. Talk slower and user a non CLI Text editor.
Keep calm?
@@IPvZero Because you talk too fast. And for people who are not native English speaker it's not fun!
@@mc-wi8wp Apologies, but that's how people from Scotland speak.
It seems like a pure asyncio ssh is faster.
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