• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

Roger Perkin

Learn Network Automation

  • Network Automation
    • Ansible Network Automation
      • Ansible Hosts File
      • What is Ansible?
    • Python Network Automation
      • Python for Network Engineers
    • Python Tutorial for Beginners
    • Terraform
    • pyATS
    • Docker
    • GIT
  • Cisco
    • ISE
    • SD WAN Training
    • Password Recovery
    • Software-Upgrade-Guides
    • BGP
    • Data Center
    • WIRELESS
  • CCIE
  • Blog
  • About
    • My Red Special Guitar
  • COURSES

Ansible vs Python Scripts

Home » Network Automation » Ansible

Ansible or Python?

ansible vs nornir

In the world of networking right now there are many discussions about which network automation tools are the best.

But one of the most asked questions is Ansible or Python?

Page Contents

  • Ansible or Python?
  • So which is better Python or Ansible?
    • Conclusion:
  • Nornir vs Ansible
  • pyATS vs Ansible
    • Frequently asked questions
    • Is Ansible a programming language?
    • Is Ansible better than Puppet?
    • How long does it take to learn Python?
    • What language are Ansible Playbooks written in?
  • You might also like,

Ansible for network automation is the tool of choice for most network engineers who are getting started with network programmability.

Python is a general purpose programming language that is widely used across the world and has found a big following with network engineers and is now the programming language of choice for network automation.

Both Ansible and Python are very good tools for network automation but which one should you learn and use?

ansible training course

Reasons to use Ansible for network automation:

  • Ansible is open source.
  • Ansible is easy to get started with, whilst it is written in Python you don’t need to know any Python to use it.
  • Ansible is agentless – unlike Puppet or Chef or Salt you do not need to install an agent. It only require SSH access to your network devices.
  • There is a great community and plenty of support for Ansible.
  • Very low barrier of entry

Reasons to not use Ansible:

  • Ansible is considered slow compared to Python
  • Ansible playbooks are written in YAML
  • Debugging problem playbooks can be difficult
  • Ansible can break between version updates

Reasons to use Python scripts for network automation:

  • You are learning one of the most popular programming languages in the world today. Infoworld.com reports that it might overtake Java & C in a few years. https://www.infoworld.com/article/3401536/python-popularity-reaches-an-all-time-high.html
  • Python gives you complete control over what you want to automate, you are writing your own custom scripts to perform whatever tasks you want.
  • Python is quick, using tools like Asyncio or Nornir, Python wins hands down in a speed test.

Reasons to not use Python:

  • Python has a higher barrier to entry and is harder to learn than
  • If you are using Python within a team, everyone needs to understand it

Check out more Python for Network Engineers Examples or best way to learn Python

ansible or python for network automation

So which is better Python or Ansible?

This really depends on where you are on your journey into network automation, how much you want to learn and how much you just want a tool to do a job. So let’s discuss these points one at a time.

  • Both Python and Ansible are free to use
  • Ansible has a much shorter learning curve, you can be up and running with Ansible in under an hour.
  • Python does require more learning and would be considered to be the more advanced tool.
  • Both are agentless, only using SSH to connect to devices.
  • Python is quicker than Ansible, but that might not be a problem if you don’t have 1000’s of devices to automate.
  • Both use human readable code, but Ansible is considered to be more human readable with it’s YAML playbooks. For someone who doesn’t know programming interpreting a Python script to automate network devices might not be that easy.
ansible network automation course

Conclusion:

The answer to this question really depends on the type of person you are and how much you want to learn.

If you just want a tool that will take backups, push configs and pull data from your network, most will go for Ansible, that is not to say it is not a powerful too, it is. However the general thoughts on this question are that if you want to get started with network automation then use Ansible and once you start to find it limiting you i.e with speed, debugging or not being able to break tasks to different devices / vendors then most people will start to explore Python.

Then once you know a bit of Pyhon you could look at Nornir!

Nornir vs Ansible

Nornir is a Python automation framework that enables you to use the most powerful Python libraries like Netmiko and the use the inventory of Nornir to be able to run all your automation directly from Python.

Once you have tried Ansible and learnt a bit of Python, the tool a lot of network engineers are now starting to use is Nornir.

But at the end of the day any tool is only as good as the person who is using it. A carpenter with a blunt saw will be able to make a much better table than someone who has never cut a piece of wood in his life.

So try out a few of these tools, see which ones you like and make your own decision. Whichever one you decide to use, just get good with it and your life will be so much easier:

pyATS vs Ansible

Another tool that is gaining traction in the network automation space is pyATS. On it’s own this is a Python testing framework, but teamed up with Genie and it becomes a network testing powerhouse. Nornir in comparison is a Python automation framework that handles inventory management very well and allows you to run your Python Scripts. Team this up with pyATS and you have a great solution so there is no real comparison between pyATS and Nornir they really work together.

Frequently asked questions

Is Ansible a programming language?

Not really, Ansible is an automation framework that is written in Python and uses Playbooks to perform it’s tasks. The playbooks are written in YAML.

Is Ansible better than Puppet?

Ansible and Puppet are both great tools in their own way, It all depends on what your use case is, Ansible would be used for smaller deployments, whilst Puppet is better for larger deployments. However in the network engineer field Ansible is used more than Puppet as it is agentless.

How long does it take to learn Python?

Python is a big language and you can’t learn it all in 1,7,21 days as some books claim. However within a few weeks you can start to make things work with Python, the key to learning Python is to just keep going, it will takes years to become an expert, but in the world of network automation you do not need to be an expert, you just need to have a good understanding of how it works.

What language are Ansible Playbooks written in?

Ansible Playbooks are written in YAML format. YAML stands for Yet Another Markup Language, or YAML Aint Markup Language! Playbooks tell Ansible what to execute.

You might also like,

  • Understanding the Ansible Hosts File
  • Ansible vs Python – Which one should you learn?
  • Ansible Vault Tutorial
  • Cisco IOS Upgrade for switch using Ansible
  • AnsbleFest London / Review
  • How to install Ansible Tower
  • What are the advantages of using Ansible Roles
  • What is Ansible?
  • Ansible IOS Command Example
  • Backup Cisco Switch config using Ansible
Category: Ansible Network Automation Training
Previous Post: « python for networking Start using Python for Networking today
Next Post: Nornir Training – Learn the Python Automation Framework »

Reader Interactions

Comments

  1. JamesClIts

    April 26, 2020 at 10:53 pm

    I love this site – its so usefull and helpfull.

    Reply
    • Roger Perkin

      April 28, 2020 at 2:11 pm

      Thanks James – glad it’s helped you.

      Reply
  2. brendan choi

    February 14, 2021 at 10:42 am

    Thank you for another great article! Always enjoy reading your articles. You are always shining the light for other network engineers. Respect to you Mr Perkins.

    Reply
    • Roger Perkin

      February 16, 2021 at 1:55 pm

      Thanks Brendan!

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Sidebar

Hi I'm Roger Perkin,
Based in the UK working as a Technical Architect focussed on Network Automation CCIE #50038
About Roger | Twitter | Linkedin

More Ansible

  • What is Ansible?
  • Ansible Vault Tutorial
  • Ansible vs Python Scripts
  • Advantages of Ansible Roles
  • Ansible Hosts File Tutorial
  • How to install Ansible Tower
  • Ansible Network Automation Course
  • Ansible Cisco IOS Command
  • Use Ansible to Backup Cisco Config
  • Where are Ansible Modules Stored?
  • AnsibleFest London Review

Recent Posts

  • Hashicorp Vault Tutorial
  • Ansible Tower vs Ansible Automation Platform
  • Cisco Certified DevNet Expert Getting Started Guide
  • Python for Network Engineers Course
  • Gitlab vs Github the Differences Explained

Topics

Network Automation
Ansible
Python for Network Automation
CCIE
Cisco ISE
F5 Certification
BGP
OSPF

Git for Network Engineers

Ansible vs Nornir

Start learning today with my Network Automation Courses

Master Ansible, Python, Git, Nornir, Jenkins and more..


Buy me a coffeeBuy me a coffee

ansible training course

Have you seen my YouTube Channel?

YouTube Subscribe

Let’s get started

Take a look at my premium courses on Ansible, Nornir & Git or buy them all with the Network Automation Bundle!

Network Automation Courses

Navigation

Home

Blog

About

Contact

Network Tools

Python VENV Tutorial

Contact

Get in touch with me here

[email protected]

Buy me a coffeeBuy me a coffee

YouTube

Don’t forget to take a look at my YouTube Channel

youtube button

Tech

Best Vertical Mouse for RSI

Copyright © 2022 · Roger Perkin · All Rights Reserved · Powered by Mai Theme