Navigation
0
SUBTOTAL :
Hands-On Enterprise Automation with Python

Hands-On Enterprise Automation with Python

Now pay Easier and Secure using Paypal
Price:

Read more

Automate common administrative and security tasks with Python

Bassem Aly

What this book covers

Chapter 1, Setting Up Python Environment
Chapter 2, Common Libraries Used in Automation,
Chapter 3, Setting up Your Network Lab Environment
Chapter 4, Using Python to Manage Network Devices
Chapter 5, Extracting Useful Data from Network Devices
Chapter 6, Configuration Generator with Python and Jinja2
Chapter 7, Parallel Execution of the Python Script
Chapter 8, Preparing a Lab Environment
Chapter 9, Using the Subprocess Module
Chapter 10, Running System Administration Tasks with Fabric
Chapter 11, Generating System Reports, Managing Users, and System Monitoring
Chapter 12, Interacting with the Database
Chapter 13, Ansible for System Administration
Chapter 14, Creating and Managing VMWare Virtual Machines
Chapter 15, Interacting with Openstack API
Chapter 16, Automating AWS with Python and Boto3
Chapter 17, Using the SCAPY Framework, introduces SCAPY
Chapter 18, Building Network Scanner Using Python

e-books shop
e-books shop
Purchase Now !
Just with Paypal



Book Details
 Price
 4.00 USD
 Pages
 492 p
 File Size
 28,577 KB
 File Type
 PDF format
 ISBN
 978-1-78899-851-2
 Copyright   
 2018 Packt Publishing 

About the Author
Bassem Aly is an experienced SDN/NFV solution consultant at Juniper
Networks and has been working in the telco industry for the last 9 years. He has
focused on designing and implementing next-generation solutions by leveraging
different automation and DevOps frameworks. Also, he has extensive experience
of architecting and deploying telco applications over OpenStack. He also
conducts corporate training on network automation and network
programmability using Python and Ansible.

I would like to thank my amazing wife, Sarah, and my fantastic daughter, Mariam. They've sacrificed many nights and meals for this dream. I hope Mariam will read this book one day and understand why I spent so much time on the computer instead of “chasing”. Thanks to my parents for their encouragement, which made me who I am today. Finally, thanks to my mentor, Ashraf Albasti, who has helped me in countless ways in my career.

About the reviewer
Jere Julian is a senior network automation engineer with nearly two decades of
automation experience currently focused on workflow simplification through
automation. The past few years have found him on the speaker circuit at DevOps
Days and Interop ITX, as well as regularly contributing to network computing.
He lives in NC with his wife and two boys and fights fire as a community
volunteer as opposed to the data center. He can be contacted on Twitter at @julianje.

Preface
The book 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 the cloud
infrastructure with Python. In the concluding chapters, you will cover Pythonbased
offensive security tools and learn 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.

Table of Contents
Title Page
Copyright and Credits
Hands-On Enterprise Automation with Python
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the author
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
1. Setting Up Our Python Environment
An introduction to Python
Python versions
Why are there two active versions?
Should you only learn Python 3?
Does this mean I can't write code that runs on both Python 2 and Pyt
hon 3?
Python installation
Installing the PyCharm IDE
Setting up a Python project inside PyCharm
Exploring some nifty PyCharm features
Code debugging
Code refactoring
Installing packages from the GUI
Summary
2. Common Libraries Used in Automation
Understanding Python packages
Package search paths
Common Python libraries
Network Python Libraries
System and cloud Python libraries
Accessing module source code
Visualizing Python code
Summary
3. Setting Up the Network Lab Environment
Technical requirements
When and why to automate the network
Why do we need automation?
Screen scraping versus API automation
Why use Python for network automation?
The future of network automation
Network lab setup
Getting ready – installing EVE-NG
Installation on VMware Workstation
Installation over VMware ESXi
Installation over Red Hat KVM
Accessing EVE-NG
Installing EVE-NG client pack
Loading network images into EVE-NG
Building an enterprise network topology
Adding new nodes
Connecting nodes together
Summary
4. Using Python to Manage Network Devices
Technical requirements
Python and SSH
Paramiko module
Module installation
SSH to the network device
Netmiko module
Vendor support
Installation and verification
Using netmiko for SSH
Configuring devices using netmiko
Exception handling in netmiko
Device auto detect
Using the telnet protocol in Python
Push configuration using telnetlib
Handling IP addresses and networks with netaddr
Netaddr installation
Exploring netaddr methods
Sample use cases
Backup device configuration
Building the python script
Creating your own access terminal
Reading data from an Excel sheet
More use cases
Summary
5. Extracting Useful Data from Network Devices
Technical requirements
Understanding parsers
Introduction to regular expressions
Creating a regular expression in Python
Configuration auditing using CiscoConfParse
CiscoConfParse library
Supported vendors
CiscoConfParse installation
Working with CiscoConfParse
Visualizing returned data with matplotLib
Matplotlib installation
Hands-on with matplotlib
Visualizing SNMP using matplotlib
Summary
6. Configuration Generator with Python and Jinja2
What is YAML?
YAML file formatting
Text editor tips
Building a golden configuration with Jinja2
Reading templates from the filesystem
Using Jinja2 loops and conditions
Summary
7. Parallel Execution of Python Script
How a computer executes your Python script
Python multiprocessing library
Getting started with multiprocessing
Intercommunication between processes
Summary
8. Preparing a Lab Environment
Getting the Linux operating system
Downloading CentOS
Downloading Ubuntu
Creating an automation machine on a hypervisor
Creating a Linux machine over VMware ESXi
Creating a Linux machine over KVM
Getting started with Cobbler
Understanding how Cobbler works
Installing Cobbler on an automation server
Provisioning servers through Cobbler
Summary
9. Using the Subprocess Module
The popen() subprocess
Reading stdin, stdout, and stderr
The subprocess call suite
Summary
10. Running System Administration Tasks with Fabric
Technical requirements
What is Fabric?
Installation
Fabric operations
Using run operation
Using get operation
Using put operation
Using sudo operation
Using prompt operation
Using reboot operation
Executing your first Fabric file
More about the fab tool
Discover system health using Fabric
Other useful features in Fabric
Fabric roles
Fabric context managers
Summary
11. Generating System Reports and System Monitoring
Collecting data from Linux
Sending generated data through email
Using the time and date modules
Running the script on a regular basis
Managing users in Ansible
Linux systems
Microsoft Windows
Summary
12. Interacting with the Database
Installing MySQL on an automation server
Securing the installation
Verifying the database installation
Accessing the MySQL database from Python
Querying the database
Inserting records into the database
Summary
13. Ansible for System Administration
Ansible terminology
Installing Ansible on Linux
On RHEL and CentOS
Ubuntu
Using Ansible in ad hoc mode
How Ansible actually works
Creating your first playbook
Understanding Ansible conditions, handlers, and loops
Designing conditions
Creating loops in ansible
Trigger tasks with handlers
Working with Ansible facts
Working with the Ansible template
Summary
14. Creating and Managing VMware Virtual Machines
Setting up the environment
Generating a VMX file using Jinja2
Building the VMX template
Handling Microsoft Excel data
Generating VMX files
VMware Python clients
Installing PyVmomi
First steps with pyvmomi
Changing the virtual machine state
There's more
Using Ansible playbook to manage instances
Summary
15. Interacting with the OpenStack API
Understanding RESTful web services
Setting up the environment
Installing rdo-OpenStack package
On RHEL 7.4
On CentOS 7.4
Generating answer file
Editing answer file
Run the packstack
Access the OpenStack GUI
Sending requests to the OpenStack keystone
Creating instances from Python
Creating the image
Assigning a flavor
Creating the network and subnet
Launching the instance
Managing OpenStack instances from Ansible
Shade and Ansible installation
Building the Ansible playbook
Running the playbook
Summary
16. Automating AWS with Boto3
AWS Python modules
Boto3 installation
Managing AWS instances
Instance termination
Automating AWS S3 services
Creating buckets
Uploading a file to a bucket
Deleting a bucket
Summary
17. Using the Scapy Framework
Understanding Scapy
Installing Scapy
Unix-based systems
Installing in Debian and Ubuntu
Installing in Red Hat/CentOS
Windows and macOS X Support
Generating packets and network streams using Scapy
Capturing and replaying packets
Injecting data inside packets
Packet sniffing
Writing the packets to pcap
Summary
18. Building a Network Scanner Using Python
Understanding the network scanner
Building a network scanner with Python
Enhancing the code
Scanning the services
Sharing your code on GitHub
Creating an account on GitHub
Creating and pushing your code
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think

Bookscreen
e-books shop

Who this book is 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.

To get the most out of this book
The reader should be acquainted with the basic programming paradigm of
Python programming language and should have basic knowledge of Linux and
Linux shell scripting.

0