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

Roger Perkin

Network Automation Architect

  • Network Automation
    • Network Automation Courses
    • What is NetDevOps?
    • Workflow Orchestration
    • Ansible Automation Platform
    • Ansible Workshop
    • What is Network Automation?
    • Network Automation Tools
    • ContainerLab
    • Ansible Training
      • What is Ansible?
      • Ansible Tutorial for Beginners
      • Ansible Network Automation
      • Ansible Inventory Example
    • Python Network Automation
      • Nornir
      • Python Network Automation Course
      • Python for Network Engineers
      • Python VENV / Virtual Environment Tutorial
      • Python Tutorial for Beginners
      • pyATS
    • Network Source of Truth
      • NetBox
      • Infrahub
    • NetDevops
    • DevOps Tutorial
      • Git Training
      • Terraform Training
      • Linux Training
      • Kubernetes Training
      • Devops Training Course
      • Azure Devops Training
    • Terraform
    • GIT
      • Git Commands
      • What is GitHub?
    • Docker Training
    • Confluence
    • Microsoft Azure
  • Cisco
    • ISE
    • SD WAN Training
    • Password Recovery
    • Software-Upgrade-Guides
    • BGP
    • Data Center
    • WIRELESS
  • CCIE
  • Blog
  • About
    • My Red Special Guitar
  • Contact

Ansible vs Python for Network Automation

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?

The main difference between Ansible and Python is Ansible is an open source Automation Platform that is written in Python and Python is Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. So Python is the programming language used to write Ansible. Saying that both of them can perform network automation tasks.

ansible network automation course

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?

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

For a more in depth discussion check out What language is best for network automation?

If you are really serious about using Python check out my Nornir Training

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.

Is Ansible good for Network Automation?

Yes, originally developed to administer Linux servers Ansible is now heavily used for network automation.

Ansible is one of the most popular open source network automation tools in use today.

It’s easy to get started, agentless (only requires an SSH connection) to the target device and there is a great community of engineers using Ansible for Network Automation and also most vendors are now developing their own Ansible modules.

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?

Ansible is an automation framework that is written in Python and uses Playbooks to perform it’s tasks. The playbooks are written in YAML.
Ansible itself is not a programming language in the traditional sense. It’s more accurately described as an automation tool or framework. Ansible uses YAML (YAML Ain’t Markup Language) for its configuration files, which allow users to define tasks, roles, and playbooks to automate various IT operations such as provisioning, configuration management, and application deployment.
While Ansible playbooks resemble a declarative programming style, where you define the desired state of the system rather than the exact steps to achieve it, it doesn’t encompass the full range of features and constructs typically associated with programming languages. However, you can incorporate programming logic within Ansible playbooks using Jinja2 templating language and executing command-line or script tasks.

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.

Is Ansible written in Python?

Ansible is written in Python. Python is a popular choice for developing system administration tools due to its readability, versatility, and extensive standard library. Ansible utilises Python for its core functionalities, making it easy to extend and customise through Python modules and plugins. Ansible playbooks are written in YAML, and you don’t need to know any Python to use Ansible

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
ansible course for network engineers
Get Access to my Ansible Course NOW
Previous Post:python for networkingStart using Python for Networking today
Next Post:Nornir Tutorial – 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 Network Automation Architect, CCIE #50038
About Roger | Twitter | Linkedin

python course for network engineers

More Ansible

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

Topics

Network Automation
Ansible
Python for Network Automation
CCIE
Cisco ISE
F5 Certification
BGP
OSPF
Network Automation Conferences
auvik promo banner
Pluralsight Trial

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 network automation 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

Python VENV Tutorial
Python for Network Engineers

Network Automation
Network Automation Courses
Network Discovery Tools
Network Automation Conferences
Ansible Training
What is Ansible?
Devops Tutorial
Network Source of Truth
DevOps Glossary
Network Monitoring Software

Contact

Contact

Get in touch with me here

[email protected]

  • Twitter
  • LinkedIn
  • YouTube
Buy me a coffeeBuy me a coffee

Copyright © 2025 · Roger Perkin · All Rights Reserved · Privacy Policy – Terms