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)

Running System Administration Tasks with Fabric

In the previous chapter, we used the subprocess module to run and spawn a system process inside the machine that hosted our Python script, and to return the output back to the Terminal. However, many automation tasks require access to remote servers to execute commands, which is not easy to do using a sub-process. This becomes a piece of cake with the use of another Python module: Fabric. The library makes connections to remote hosts and executes different tasks, such as uploading and downloading files, running commands with specific user IDs, and prompting users for input. The Fabric Python module is a robust tool for administrating dozens of Linux machines from a central point.

The following topics will be covered in this chapter:

  • What is Fabric?
  • Executing your first Fabric file
  • Other useful Fabric features