Book Image

Hands-On Enterprise Automation with Python

By : Bassem Aly
Book Image

Hands-On Enterprise Automation with Python

By: Bassem Aly

Overview of this book

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.
Table of Contents (20 chapters)

How a computer executes your Python script

This is how your computer's operating system executes Python script:

  1. When you type python <your_awesome_automation_script>.py in the shell, Python (which runs as a process) instructs your computer processor to schedule a thread (which is the smallest unit of processing):
  1. The allocated thread will start to execute your script, line by line. A thread can do anything, including interacting with I/O devices, connecting to routers, printing output, performing mathematical equations, and more.
  2. Once the script hits the End of File (EOF), the thread will be terminated and returned to the free pool, to be used by other processes. Then, the script is terminated.

In Linux, you can use #strace –p <pid> to trace a specific thread execution.

The more threads that you assign to your script (and that are permitted by your...