|Title||Hands-On Enterprise Automation with Python (available from Amazon and Packt)|
|Publication||2018 (Packt Publishing)|
|Summary||Using Python packages for network, system, and infrastructure automation.|
|Prerequisites||Intermediate Python programming. Intermediate administrative skills.|
Hands-On Enterprise Automation with Python is an excellent resource for learning how to automate common administrative tasks like running commands, scraping network config, and setting up systems. Python is a natural fit for such tasks with its impressive package library, its easy learning curve, and its concise syntax.
The number of Python tools and modules this book covers is stunning:
- Developing Python code with PyCharm
- Managing network devices with paramiko, netmiko, and telnetlib
- Using regular expressions with re
- Charting data with matplotlib
- Templating YAML files with Jinja2
- Multiprocessing with multiprocessing
- Running local system commands with subprocess
- Running remote system commands with fabric
- Getting system info with platform
- Sending emails with smtplib
- System administration with Ansible
- Interacting with a MySQL database using MySQLdb
- Storing files in Amazon S3 using boto3
- Packet sniffing and manipulating with scapy
Each new topic is introduced with background information, setup steps, and example code. Instructions are given for the reader to set up their own test environment and try things out. Later chapters also show how to use modules together to build more powerful automation. Most examples favor Python 2 but can be made compatible with Python 3.
The best thing about this book is how it covers an incredible breadth of topics in such a readable way. Rather than being dry manual pages pulled from a cryptic doc site, each chapter is a tutorial with explanations and real-world code examples. Readers can easily read through the book cover-to-cover or seek topics directly as a reference.
Another great thing is that the author always introduces new concepts before applying them. While intermediate skills with Python and administration are presumed as a prerequisite, the introductory chapters nevertheless show how to set up a full Python development environment with a network lab for testing. Before showing how to use any particular module, the author explains what the problem is and why the module should be used. This makes the material very accessible, especially for non-sysadmins.
- The tasks showcased are network-heavy.
- The setup primarily relies on Linux.
- Many pages are dedicated to workbench setup.
- Modules are covered at an introductory level and not in depth.
I thoroughly enjoyed reading Hands-On Enterprise Automation with Python. As a Software Engineer in Test, the word “automation” almost always means “test automation.” Reading this book was a healthy glimpse at other no-less-important types of automation oriented more toward admin tools and scripts. I could definitely leverage many of the modules covered in this book for my own work, too – several of them cross domains.
I really liked the three main reasons the author gave for using Python for automation: it is readable, it has so many libraries, and it has power in its conciseness. These reasons ring true for many applications, especially the point about modules. Since there’s a module for nearly everything, Python programming often simplifies to recipes for using those modules. Arguably, this book is a cookbook full of sysadmin recipes.
Reading this book also made me reminiscent of my days working at MaxPoint, where I first learned Python to build a test automation framework. I used many of the same modules shared in this book for the same tasks. I felt comfort in my familiarity and validation in my past efforts.