DevOps in Python: Infrastructure as Python

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Take advantage of Python to automate complex systems with readable code. This new edition will help you move from operations/system administration into easy-to-learn coding. You'll start by writing command-line scripts and automating simple DevOps-style tasks followed by creating reliable and fast unit tests designed to avoid incidents caused by buggy automation. You’ll then move on to more advanced cases, like using Jupyter as an auditable remote-control panel and writing Ansible and Salt extensions. The updated information in this book covers best practices for deploying and updating Python applications. This includes Docker, modern Python packaging, and internal Python package repositories. You'll also see how to use the AWS API, and the Kubernetes API, and how to automate Docker container image building and running. Finally, you'll work with Terraform from Python to allow more flexible templating and customization of environments. What You'll Learn • Understand operating system automation with Python • Package Python applications • Use Python as a DevOps console • Review Cloud automation with Python Who This Book Is For DevOps engineer. Site Reliability Engineer, or similar (including Platform, Production, and Systems), and whose organization uses Python.

Author(s): Moshe Zadka
Edition: 2
Publisher: Apress
Year: 2022

Language: English
Commentary: Vector PDF
Pages: 251
City: New York, NY
Tags: DevOps; Amazon Web Services; Web Programming; Python; Cryptography; Kubernetes; Unit Testing; Automation; Ansible; Anaconda; Testing; iPython; PyPy; Text Processing; Tox; Terraform; Infrastructure as Code; Virtual Environments; Paramiko; REST API; pyenv; Poetry; SaltStack; Containers; boto3

Table of Contents
About the Author
About the Technical Reviewer
Acknowledgments
Introduction
Chapter 1: Installing Python
1.1 OS Packages
1.2 Using pyenv
1.3 Building Python from Source
1.4 PyPy
1.5 Anaconda
1.6 Summary
Chapter 2: Packaging
2.1 Virtual Environments
2.2 pip
2.3 Setup and Wheels
2.4 Binary Wheels
2.5 manylinux Wheels
2.5.1 Self-Contained Wheels
2.5.2 Portable Wheels
2.5.3 manylinux Containers
2.5.4 Installing manylinux Wheels
2.6 tox
2.6.1 One Environment
2.6.2 Multiple Environments
2.6.3 Multiple Differently Configured Environments
2.7 Pip Tools
2.8 Poetry
2.8.1 Installing
2.8.2 Creating
2.8.3 Dependencies
2.8.4 Developing
2.8.5 Building
2.9 Pipenv
2.10 DevPI
2.11 pex and shiv
2.11.1 pex
2.11.2 shiv
2.12 Summary
Chapter 3: Interactive Usage
3.1 Native Console
3.2 The Code Module
3.3 ptpython
3.4 IPython
3.5 JupyterLab
3.6 Summary
Chapter 4: OS Automation
4.1 Files
4.2 Processes
4.3 Networking
4.4 Summary
Chapter 5: Testing
5.1 Unit Testing
5.2 Mocks, Stubs, and Fakes
5.3 Testing Files
5.3.1 Testing with Subdirectories
5.3.2 Accelerating Tests with eatmydata
5.3.3 Accelerating Tests with tmpfs
5.4 Testing Processes
5.5 Testing Networking
5.6 Testing HTTP Clients
Chapter 6: Text Manipulation
6.1 Bytes, Strings, and Unicode
6.2 Strings
6.3 Regular Expressions
6.4 JSON
6.5 CSV
6.6 Summary
Chapter 7: HTTPX
7.1 Clients
7.2 REST
7.3 Security
7.4 Authentication
7.5 Async client
7.6 Summary
Chapter 8: Cryptography
8.1 Fernet
8.2 PyNaCl
8.3 Passlib
8.4 TLS Certificates
8.5 Summary
Chapter 9: Paramiko
9.1 SSH Security
9.2 Client Keys
9.3 Host Identity
9.4 Connecting
9.5 Running Commands
9.6 Remote Files
9.6.1 Metadata Management
9.6.2 Upload
9.6.3 Download
9.7 Summary
Chapter 10: SaltStack
10.1 Salt Basics
10.2 Salt Concepts
10.3 Salt Formats
10.4 Salt Extensions
10.4.1 States
10.4.2 Execution
10.4.3 Utility
10.4.4 Extra Third-Party Dependencies
10.5 Summary
Chapter 11: Ansible
11.1 Ansible Basics
11.2 Ansible Concepts
11.3 Ansible Extensions
11.4 Summary
Chapter 12: Containers
12.1 Choosing a Base Image
12.1.1 GNU C Library Support
12.1.2 Long-Term Support
12.1.3 Avoiding Unexpected Changes
12.2 Installing the Python Interpreter
12.2.1 conda
12.2.2 Third-Party Repositories
12.2.3 Building Python in the Container
12.2.4 Python Base Image
12.3 Installing Python Applications
12.4 Optimizing Container Build Cache
12.5 Rebuilding Containers
12.6 Container Security
12.7 Summary
Chapter 13: Amazon Web Services
13.1 Security
13.1.1 Configuring Access Keys
13.1.2 Creating Short-Term Tokens
13.2 Elastic Computing Cloud (EC2)
13.2.1 Regions
13.2.2 Amazon Machine Images
13.2.3 SSH Keys
13.2.4 Bringing up Machines
13.2.5 Securely Logging In
13.2.6 Building Images
13.3 Simple Storage Service (S3)
13.3.1 Managing Buckets
13.4 Summary
Chapter 14: Kubernetes
14.1 Pods
14.1.1 Liveness and Readiness
14.1.2 Configuration
Environment Variables
Configuration Files
Secrets
14.1.3 Python Sidecars
14.2 REST API
14.3 Operators
14.3.1 Permissions
14.3.2 Custom Types
14.3.3 Retrieval
14.3.4 Goal State
14.3.5 Comparison
14.3.6 Reconciliation
14.3.7 Combining the Pieces
14.4 Summary
Chapter 15: Terraform
15.1 JSON Syntax
15.2 Generating Terraform Configurations
15.3 Summary
Index