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

You're reading from   Hands-On Enterprise Automation with Python Automate common administrative and security tasks with Python

Arrow left icon
Product type Paperback
Published in Jun 2018
Publisher Packt
ISBN-13 9781788998512
Length 398 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Bassem Aly Bassem Aly
Author Profile Icon Bassem Aly
Bassem Aly
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Setting Up Our Python Environment 2. Common Libraries Used in Automation FREE CHAPTER 3. Setting Up the Network Lab Environment 4. Using Python to Manage Network Devices 5. Extracting Useful Data from Network Devices 6. Configuration Generator with Python and Jinja2 7. Parallel Execution of Python Script 8. Preparing a Lab Environment 9. Using the Subprocess Module 10. Running System Administration Tasks with Fabric 11. Generating System Reports and System Monitoring 12. Interacting with the Database 13. Ansible for System Administration 14. Creating and Managing VMware Virtual Machines 15. Interacting with the OpenStack API 16. Automating AWS with Boto3 17. Using the Scapy Framework 18. Building a Network Scanner Using Python 19. Other Books You May Enjoy

What this book covers

Chapter 1, Setting Up Python Environment, explores how to download and install the Python interpreter along with the Python Integrated Development Environment, called JetBrains PyCharm. The IDE provides you with smart autocompletion, intelligent code analysis, powerful refactoring and integrates with Git, virtualenv, Vagrant, and Docker. This will help you to write professional and robust Python code.

Chapter 2, Common Libraries Used in Automation, covers the Python libraries that are available today and that are used for automation. We will categorize them based on their usage (system, network, and cloud) and provide a simple introduction. As you progress through the book, you will find yourself deep diving into each of them and understanding their usage.

Chapter 3, Setting up Your Network Lab Environment, discusses the merits of network automation and how network operators use it today to automate the current devices. We will explore popular libraries that are used today to automate network nodes from Cisco, Juniper, and Arista. This chapter covers how to build a networking lab to apply the Python script on. We will use an open source network emulation tool called EVE-NG.

Chapter 4, Using Python to Manage Network Devices, dives into managing networking devices through telnet and SSH connections using netmiko, paramiko, and telnetlib. We will learn how to write the Python code to access switches and routers and execute commands on the terminal and then return the output. We will also learn how to utilize different Python techniques to back up and push configuration. The chapter ends with some use cases used today in modern network environment.

Chapter 5, Extracting Useful Data from Network Devices, explains how to use different tools and techniques inside Python to extract useful data from returned output and act upon it. Also, we will use a special library called CiscoConfParse to audit the configuration. Then we will learn how to visualize data to generate appealing graphs and reports with matplotlib.

Chapter 6, Configuration Generator with Python and Jinja2, explains how to generate a common configuration for a site with hundreds of network nodes. We will learn how to write a template and use it to generate a golden configuration with a templating language called Jinja2.

Chapter 7, Parallel Execution of the Python Script, covers how to instantiate and execute your Python code in parallel. This will allow us to finish the automation workflow faster as long as it is not interdependent.

Chapter 8, Preparing a Lab Environment, covers the installation process and preparation for our lab environment. We will install our automation server either in CentOS or Ubuntu over different hypervisors. Then we will learn how to automate the operating system installation with Cobbler.

Chapter 9, Using the Subprocess Module, explains how to send a command from a Python script directly to the operating system shell and investigate the returning output.

Chapter 10, Running System Administration Tasks with Fabric, introduces Fabric, which is a Python library for executing system administration tasks through SSH. Also, it's used in large deployment of applications. We will learn how to utilize and leverage this library to execute tasks on remote servers.

Chapter 11, Generating System Reports, Managing Users, and System Monitoring, explains that collecting data and generating recurring reports from the system is an essential task for any system administrator, and automating this task will help you to discover issues early and provide a solutions for them. In this chapter, we will see some proven ways to automate data collection from servers and generate formal reports. We will learn how to manage new and existing users using Python and Ansible. Also, we will dive into monitoring the system KPI and logs analysis. You can also schedule the monitoring scripts to run on a regular basis and send the result to your mail inbox.

Chapter 12, Interacting with the Database, states that if you're a database administrator or database developer, then Python provides a wide range of libraries and modules that cover managing and working on popular DBMSes such as MySQL, Postgress, and Oracle. In this chapter, we will learn how to interact with DBMSes using Python connectors.

Chapter 13, Ansible for System Administration, explores one of the most powerful tools in configuration management software. Ansible is very powerful when it comes to system administration and can be used to make sure the configuration is replicated exactly across hundreds or even thousands of servers at the same time.

Chapter 14, Creating and Managing VMWare Virtual Machines, explains how to automate VM creation on a VMWare hypervisor. We will discover different ways to create and manage virtual machines over ESXi using VMWare's official binding library.

Chapter 15, Interacting with Openstack API, explains that OpenStack was very popular in creating private IaaS when it came to private cloud. We will use Python modules such as requests to create REST calls and interact with OpenStack services such as nova, cinder, and neutron, and create the required resources over OpenStack. Later in the chapter, we will use Ansible playbooks for the same workflow.

Chapter 16, Automating AWS with Python and Boto3, covers how to automate common AWS services such as EC2 and S3 using official Amazon binindgs (BOTO3), which provides an easy-to-use API for services access.

Chapter 17, Using the SCAPY Framework, introduces SCAPY, which is a powerful Python tool used to build and craft packets and then send them on the wire. You can build any type of network stream and send it on the wire. It can also help you to capture network packets and replay them to the wire.

Chapter 18, Building Network Scanner Using Python, provides a complete example of building a network scanner using Python. You can scan a complete subnet for different protocols and ports and generate a report for each scanned host. Then, we will learn how to share the code with the open source community (GitHub) by leveraging Git.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime