Ansible vs Python: Best of Both
Key Points
- The speaker argues that using Ansible and Python together, rather than choosing one over the other, provides a stronger solution for automating VM and application deployment on public cloud platforms.
- Ansible playbooks, written in easy‑to‑read YAML and powered by reusable modules, excel at declarative infrastructure tasks like creating VMs, assigning IPs, attaching storage, and provisioning software.
- Python scripts require deeper programming expertise and manual handling of cloud‑provider libraries, making them less approachable for simple automation but useful for more complex or custom logic.
- Simplicity and shareability of Ansible make it ideal for enterprise automation initiatives, allowing subject‑matter experts in networking, storage, or cloud configuration to contribute without extensive coding knowledge.
- Since Ansible modules themselves are implemented in Python, the two technologies complement each other, enabling teams to start with straightforward YAML and extend functionality with Python when needed.
Full Transcript
# Ansible vs Python: Best of Both **Source:** [https://www.youtube.com/watch?v=Nzq6fEr9SJ4](https://www.youtube.com/watch?v=Nzq6fEr9SJ4) **Duration:** 00:06:01 ## Summary - The speaker argues that using Ansible and Python together, rather than choosing one over the other, provides a stronger solution for automating VM and application deployment on public cloud platforms. - Ansible playbooks, written in easy‑to‑read YAML and powered by reusable modules, excel at declarative infrastructure tasks like creating VMs, assigning IPs, attaching storage, and provisioning software. - Python scripts require deeper programming expertise and manual handling of cloud‑provider libraries, making them less approachable for simple automation but useful for more complex or custom logic. - Simplicity and shareability of Ansible make it ideal for enterprise automation initiatives, allowing subject‑matter experts in networking, storage, or cloud configuration to contribute without extensive coding knowledge. - Since Ansible modules themselves are implemented in Python, the two technologies complement each other, enabling teams to start with straightforward YAML and extend functionality with Python when needed. ## Sections - [00:00:00](https://www.youtube.com/watch?v=Nzq6fEr9SJ4&t=0s) **Ansible and Python for VM Provisioning** - The speaker explains why combining Ansible playbooks (declarative YAML modules) with Python scripts (procedural flexibility) is the optimal approach for automating virtual machine creation and application deployment on a public cloud. ## Full Transcript
okay so I've been tasked with creating a
brand new instance of a virtual machine
and our application on top of it on a
public cloud provider now in my mind
there is one of two things that I could
do here I could use an anible
Playbook or I could use a python
script now you might be asking why I
would do one versus the other so
hopefully by the end of my talk here
today it shouldn't be an answer versus
python conversation no no it should be
anible and python they're better
together now let's get
started okay so first let's dive into
our use cases here when we're trying to
decide between anible and python it's
helpful to First understand what it is
that we're talking about so let's look
let's dive into anible first in anible
we have playbooks and these are defined
in yaml these are very simple to read
even simpler to write simple diversion
control Etc now in yaml we are
leveraging what we call modules and
modules uh represent sort of this unit
of work that we are performing so we're
able to Define what we're actually doing
with that module within yam and this
will allow me to say create the virtual
machine attach a public IP address
attach storage provision the application
on top of all this infrastructure and
we're good to go anible is really good
at that declarative picture show me a
picture of what you want and I will make
it so now on the uh on the python side
we're still working in you know a
document approach we have our python
script here but this requires somebody
with innate knowledge of this fully
featured programming language so to
start out with an automated tasks we
might we might have to first import a
couple of libraries so you know this
could be libraries to leverage
automation within your public cloud
provider but the point is you kind of
already need need to know how to
leverage these libraries and methods and
things to go in and accomplish the same
task that we've defined so simply with
anible so that is the what what is
anible versus what is python in this
particular use case now that brings us
to why why would we choose ansible
versus python now why would you choose
between one of the other well it comes
down to that complexity and that
simplicity so here we have something
that's you know again very U very simple
to Define inversion control and read
it's also very simple now to um to share
this within my team within my
organization as a whole and so that we
can we can much easier adopt an
Enterprise automation Journey using
something that's simple to Define and
track as anible now that doesn't mean
we're not going to have complicated
tasks after all these modules that
answer is is using within a Playbook are
WR written in Python which brings us um
we've we've cover covered the what the
why and now let's talk about the who so
who is engaging with with ansible this
would be um maybe subject matter experts
sometimes that really understand storage
or networking or Cloud configuration and
and provisioning but it could also be um
something like a citizen developer right
this is really easy to read and
understand now on the python side we
might be talking again about a subject
matter expert but also a python
programmer and these are people that
have gone to school and are highly
effective within this space so when we
talk about ansible versus python it's
really more uh relevant to say anible
and python we still need these experts
to write our complex automation for us
that we can now leverage back in anible
use anible as that thing that's easy to
use Easy to call your python uh
automation modules and and kind of
separate it out that
way so now that we've sort of uh covered
our use cases and and compare the two
solutions when would we decide to use
anible versus python now it all comes
down to that complexity again because
just because we have such a simple way
of defining automation doesn't negate
the fact that we still need this anible
is written on the backbone it its
backbone is python right um if we didn't
have python we don't have ansible and so
it's incredibly important to maintain
the subject matter expertise in a
fully-fledged pro programming language
but once it comes time to scale this
automation out to the rest of our team
to the rest of our organizations we need
something that's a little bit more
simpler to maintain and operate at scale
and that is anle and the anel automation
platform
form so there it is you know at the end
of the day I chose to write my task to
automate this VM creation attach my
external um IP address and storage and
add the application on top because it's
simple for me to write but also simple
for me to pass off to my colleague to
spin up another Dev instance when I am
out of the office had I done this in
Python yes would have been able to do
the same thing but I might have been
called on the weekend that I have off to
go up and stand a brand up stand up a
brand new developer instance for my
application now that we understand why I
would choose ansible over python or vice
versa I think you should go out and try
our interactive Labs page and this is
where you will gain handson experience
with anible
automation okay thank you very much for
watching please do not forget to like
And subscribe to see more from this
channel