Python for DevOps
by Noah Gift , Kennedy Behrman , Alfredo Deza , and Grig Gheorghiu
Copyright 2020 Noah Gift, Kennedy Behrman, Alfredo Deza, Grig Gheorghiu. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Acquisitions Editor: Rachel Roumeliotis
- Development Editor: Corbin Collins
- Production Editor: Christopher Faucher
- Copyeditor: nSight, Inc.
- Proofreader: Sonia Saruba
- Indexer: WordCo Indexing Services, Inc.
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Rebecca Demarest
- December 2019: First Edition
Revision History for the First Release
- 2019-12-11: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781492057697 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Python for DevOps, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
The views expressed in this work are those of the authors, and do not represent the publishers views. While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-492-05769-7
[LSI]
Preface
One time Noah was in the ocean, and a wave crashed on top of him and took his breath away as it pulled him deeper into the sea. Just as he started to recover his breath, another wave dropped on top. It extracted much of his remaining energy. It pulled him even deeper into the ocean. Just as he started to recover, yet another wave crashed down on top. The more he would fight the waves and the sea, the more energy was drained. He seriously wondered if he would die at that moment. He couldnt breathe, his body ached, and he was terrified he was going to drown. Being close to death helped him focus on the only thing that could save him, which was conserving his energy and using the wavesnot fighting them.
Being in a startup that doesnt practice DevOps is a lot like that day at the beach. There are production fires that burn for months; everything is manual, alerts wake you up for days on end damaging your health. The only escape from this death spiral is the DevOps way.
Do one right thing, then another, until you find clarity. First, set up a build server, start testing your code, and automate manual tasks. Do something; it can be anything, but have a bias for action. Do that first thing right and make sure it is automated.
A common trap in startups or any company is the search for superheroes. We need a performance engineer because they will fix our performance problems. We need a Chief Revenue Officer because they will fix all sales problems. We need DevOps engineers because they will fix our deployment process.
At one company, Noah had a project that was over a year late, and the web application had been rewritten three times in multiple languages. This next release only needed a performance engineer to get it finished. I remember being the only one brave or stupid enough to say, What is a performance engineer? This engineer made everything work at scale. He realized at that point that they were looking for a superhero to save them. Superhero hiring syndrome is the best way to pick up on something being very wrong on a new product or a new startup. No employee will save a company unless they first save themselves.
At other companies, Noah heard similar things: If we could only hire a senior Erlang engineer, or If we could only hire someone to make us revenue, or If we could only hire someone to teach us to be financially disciplined, or If we could only hire a Swift developer, etc. This hire is the last thing your startup or new product needsit needs to understand what it is doing wrong that only a superhero can save the day.
In the case of the company that wanted to hire a performance engineer, it turned out that the real issue was inadequate technical supervision. The wrong people were in charge (and verbally shouting down the people who could fix it). By removing a poor performer, listening to an existing team member who knew how to fix the problem all along, deleting that job listing, doing one right thing at a time, and inserting qualified engineering management, the issue resolved itself without a superhero hire.
No one will save you at your startup; you and your team have to protect yourselves by creating great teamwork, a great process, and believing in your organization. The solution to the problem isnt a new hire; it is being honest and mindful about the situation you are in, how you got there, and doing one right thing at a time until you work your way out. There is no superhero unless it is you.
Just like being in the ocean in a storm and slowly drowning, no one is going to save you or the company unless it is you. You are the superhero your company needs, and you might discover your coworkers are too.
There is a way out of the chaos, and this book can be your guide. Lets get started.
What Does DevOps Mean to the Authors?
Many abstract concepts in the software industry are hard to define precisely. Cloud Computing, Agile, and Big Data are good examples of topics that can have many definitions depending on whom you talk to. Instead of strictly defining what DevOps is, lets use some phrases that show evidence DevOps is occurring:
Two-way collaboration between Development and Operation teams.
Turnaround of Ops tasks in minutes to hours, not days to weeks.
Strong involvement from developers; otherwise, its back to Devs versus Ops.
Operations people need development skillsat least Bash and Python.
Developer people need operational skillstheir responsibilities dont end with writing the code, but with deploying the system to production and monitoring alerts.
Automation, automation, automation: you cant accurately automate without Dev skills, and you cant correctly automate without Ops skills
Ideally: self-service for developers, at least in terms of deploying code.
Can be achieved via CI/CD pipelines.
GitOps.
Bidirectional everything between Development and Operations (tooling, knowledge, etc.).
Constant collaboration in design, implementation, deploymentand yes, automationcant be successful without cooperation.
If it isnt automated, its broken.
Cultural: Hierarchy < Process.
Microservices > Monolithic.
The continuous deployment system is the heart and soul of the software team.
There are no superheroes.
Continuous delivery isnt an option; it is a mandate.
How to Use This Book