Hands-On Enterprise Automation with Python.
eBook - ePub

Hands-On Enterprise Automation with Python.

Automate common administrative and security tasks with Python

  1. 398 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Hands-On Enterprise Automation with Python.

Automate common administrative and security tasks with Python

About this book

Invent your own Python scripts to automate your infrastructureAbout This Book• 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 setWho This Book Is ForHands-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 GitHubIn DetailHands-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.Style and approachThis book will follow a practical approach to help you script and automate tasks using Python.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Creating and Managing VMware Virtual Machines

For a long long time, virtualization has been an important technology in the IT industry as it provides an efficient way for hardware resources and allows us to easily manage application life cycle inside the Virtual Machine (VM). In 2001, VMware released the first version of the ESXi that could run directly over the commodity off the shelf (COTS) server while converting it to a resource that could be consumed by multiple separate virtual machines. In this chapter, we will explore many options available to automate the building of virtual machine thanks to Python and Ansible.
The following topics will be covered in this chapter:
  • Setting up the lab environment
  • Generating a VMX file using Jinja2
  • VMware Python clients
  • Using Ansible playbooks to manage instances

Setting up the environment

For this chapter, we will have VMware ESXi version 5.5 installed over a Cisco UCS server and host a few virtual machines. We need to enable a few things in our ESXi server in order to expose some external ports to the outside world:
  1. The first thing is to enable both Shell and SSH access to the ESXi console. Basically, ESXi allows you to manage it using the vSphere client (based on C# for the versions before 5.5.x and based on HTML for version 6 and up). Once we enable the Shell and SSH access, this will give us the ability to use the CLI to manage virtual infrastructure and to perform tasks such as creating, deleting, and customizing the virtual machine.
  1. Access the ESXi vSphere client and go to Configuration, then choose Security Profiles from the left tab, and finally click on Properties:
A pop-up window will be opened that contains a list of services, statuses, and various options that can be applied:
  1. Select SSH service and then click on Option. Another pop-up window will be opened.
  2. Choose the first option that reads Start automatically if any ports are open, and stop when all ports are closed under the Startup Policy.
  3. Also, click on Start under Service Commands and hit OK:
Repeat the same steps again for the ESXi Shell service. This will ensure that both services will be started once the ESXi server has started and will be opened and ready to accept the connection. You can test both services, SSH to the ESXi IP address and provide the root credentials as with SSH connection:

Generating a VMX file using Jinja2

The basic unit for a virtual machine (sometimes called a guest machine) is the VMX file. This file contains all the settings needed to bui...

Table of contents

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

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Hands-On Enterprise Automation with Python. by Bassem Aly in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in Python. We have over one million books available in our catalogue for you to explore.