Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Hands-On Enterprise Automation with Python
Hands-On Enterprise Automation with Python

Hands-On Enterprise Automation with Python: Automate common administrative and security tasks with Python

eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Hands-On Enterprise Automation with Python

Common Libraries Used in Automation

This chapter will walk you through how Python packages are structured and the common libraries used today to automate the system and network infrastructure. There's a long growing list of Python packages that cover network automation, system administration, and managing public and private clouds.

Also, it's important to understand how to access the module source code and how the small pieces inside the Python package are related to each other so we can modify the code, add or remove features, and share the code again with the community.

The following topics will be covered in this chapter:

  • Understanding Python packages
  • Common Python libraries
  • Accessing module source code

Understanding Python packages

Python core code is actually small by design to maintain simplicity. Most functionalities will be through adding third-party packages and modules.

Module is a Python file that contains functions, statements, and classes that will be used inside your code. The first thing to do is import the module then start to use its functions.

On other hand, a package collects related modules connected to each other and puts them in a single hierarchy. Some large packages such as matplotlib or django have hundreds of modules inside them, and developers usually categorize the related modules into a sub-directories. For example, the netmiko package contains multiple sub-directories and each one contains modules to connect to network devices from different vendors:

Doing that gives the package maintainer the flexibility to add or remove features from each module...

Common Python libraries

In the next sections, we will explore the common Python libraries used for network, system, and cloud automation.

Network Python Libraries

Network environments nowadays contain multiple devices from many vendors, and each device plays a different role. Design and automation frameworks for network devices are essential to network engineers in order to automate repeated tasks and enhance the way they usually do their job, while reducing human errors. Large enterprises and service providers usually tend to design a workflow that can automate different network tasks and improve network resiliency and agility. The workflow contains a series of related tasks that together form a process or a workflow that...

Accessing module source code

You can access the source code of any module that you use in two ways. First, go to the module page at github.com and view all the files, releases, commits, and issues in one place, as in the following screenshot. I have read access to all shared code via the netmiko module maintainer and can see a full list of commits and file contents:

The second method is to install the package itself in the Python site-package directory using pip or PyCharm GUI. What pip actually does is it goes to GitHub and downloads the module content and runs setup.py to install and register the module. You can see the module files, but this time you have full read/write access on all files and you can change the original code. For example, the following code leverages the netmiko library to connect to a Cisco device and execute the show arp command on it:

from netmiko import...

Summary

In this chapter, we explored some of most popular network, system, and cloud packages provided in Python. Also, we learned how to access the module source code and to visualize it for better understanding of the internal code. We looked at the call flow for code while running. In the next chapter, we will start building a lab environment and apply our code to it.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • •Make the most of Python libraries and modules to automate your infrastructure
  • •Leverage Python programming to automate server configurations and administration tasks
  • •Efficiently develop your Python skill set

Description

Hands-On Enterprise Automation with Python starts by covering the set up of a Python environment to perform automation tasks, as well as the modules, libraries, and tools you will be using. We’ll explore examples of network automation tasks using simple Python programs and Ansible. Next, we will walk you through automating administration tasks with Python Fabric, where you will learn to perform server configuration and administration, along with system administration tasks such as user management, database management, and process management. As you progress through this book, you’ll automate several testing services with Python scripts and perform automation tasks on virtual machines and cloud infrastructure with Python. In the concluding chapters, you will cover Python-based offensive security tools and learn how to automate your security tasks. By the end of this book, you will have mastered the skills of automating several system administration tasks with Python.

Who is this book for?

Hands-On Enterprise Automation with Python is for system administrators and DevOps engineers who are looking for an alternative to major automation frameworks such as Puppet and Chef. Basic programming knowledge with Python and Linux shell scripting is necessary.

What you will learn

  • •Understand common automation modules used in Python
  • •Develop Python scripts to manage network devices
  • •Automate common Linux administration tasks with Ansible and Fabric
  • •Managing Linux processes
  • •Administrate VMware, OpenStack, and AWS instances with Python
  • •Security automation and sharing code on GitHub

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 28, 2018
Length: 398 pages
Edition : 1st
Language : English
ISBN-13 : 9781788992640
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Jun 28, 2018
Length: 398 pages
Edition : 1st
Language : English
ISBN-13 : 9781788992640
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 104.97
Hands-On Enterprise Automation with Python
€32.99
Learn Ansible
€41.99
Python Automation Cookbook
€29.99
Total 104.97 Stars icon

Table of Contents

19 Chapters
Setting Up Our Python Environment Chevron down icon Chevron up icon
Common Libraries Used in Automation Chevron down icon Chevron up icon
Setting Up the Network Lab Environment Chevron down icon Chevron up icon
Using Python to Manage Network Devices Chevron down icon Chevron up icon
Extracting Useful Data from Network Devices Chevron down icon Chevron up icon
Configuration Generator with Python and Jinja2 Chevron down icon Chevron up icon
Parallel Execution of Python Script Chevron down icon Chevron up icon
Preparing a Lab Environment Chevron down icon Chevron up icon
Using the Subprocess Module Chevron down icon Chevron up icon
Running System Administration Tasks with Fabric Chevron down icon Chevron up icon
Generating System Reports and System Monitoring Chevron down icon Chevron up icon
Interacting with the Database Chevron down icon Chevron up icon
Ansible for System Administration Chevron down icon Chevron up icon
Creating and Managing VMware Virtual Machines Chevron down icon Chevron up icon
Interacting with the OpenStack API Chevron down icon Chevron up icon
Automating AWS with Boto3 Chevron down icon Chevron up icon
Using the Scapy Framework Chevron down icon Chevron up icon
Building a Network Scanner Using Python Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(1 Ratings)
5 star 0%
4 star 100%
3 star 0%
2 star 0%
1 star 0%
LTE_Interest Jul 16, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Wide range of topics covered but not in depth. I would have preferred more depth in every topic.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.