https://blog.danslimmon.com/2019/07/15/do-nothing-scripting-the-key-to-gradual-automation/ Skip to content Dan Slimmon Scientific incident response Menu Search * Blog * Incident Response Training * LinkedIn * Twitter * Email Search for: [ ] Search [crap0] Do-nothing scripting: the key to gradual automation On 2019/07/15 By Dan SlimmonIn Uncategorized Every ops team has some manual procedures that they haven't gotten around to automating yet. Toil can never be totally eliminated. Very often, the biggest toil center for a team at a growing company will be its procedure for modifying infrastructure or its procedure for provisioning user accounts. Partial instructions for the latter might look like this: 1. Create an SSH key pair for the user. 2. Commit the public key to Git and push to master. 3. Wait for the build job to finish. 4. Find the user's email address in the employee directory. 5. Send the user their private key via 1Password. This is a relatively short example. Sometimes there are 20 steps in the process. Sometimes there are branches and special cases to keep track of as you go. Over time, these procedures can become unmanageably large and complex. Procedures like this are frustrating because they're focus-intensive yet require very little thought. They demand our full attention, but our attention isn't rewarded with interesting problems or satisfying solutions - just another checkbox checked. I have a word for a procedure like this: a slog. We know that this procedure is ripe for automation. We can easily see how to automate any given step. And we know that a computer could carry out the instructions with far greater speed and accuracy than we can, and with less tendency toward practical drift. However, automating slogs sometimes feels like an all-or-nothing proposition. Sure, we could write a script to handle step 2, or step 5. But that wouldn't really make the procedure any less cumbersome. It would lead to a proliferation of single-purpose scripts with different conventions and expectations, and you'd still have to follow a documented multi-step procedure for using those scripts. This perception of futility is the problem we really need to solve in order to escape from these manual slogs. I've found an approach that works pretty reliably: do-nothing scripting. Do-nothing scripting Almost any slog can be turned into a do-nothing script. A do-nothing script is a script that encodes the instructions of a slog, encapsulating each step in a function. For the example procedure above, we could write the following do-nothing script: import sys def wait_for_enter(): raw_input("Press Enter to continue: ") class CreateSSHKeypairStep(object): def run(self, context): print("Run:") print(" ssh-keygen -t rsa -f ~/{0}".format(context["username"])) wait_for_enter() class GitCommitStep(object): def run(self, context): print("Copy ~/new_key.pub into the `user_keys` Git repository, then run:") print(" git commit {0}".format(context["username"])) print(" git push") wait_for_enter() class WaitForBuildStep(object): build_url = "http://example.com/builds/user_keys" def run(self, context): print("Wait for the build job at {0} to finish".format(self.build_url)) wait_for_enter() class RetrieveUserEmailStep(object): dir_url = "http://example.com/directory" def run(self, context): print("Go to {0}".format(self.dir_url)) print("Find the email address for user `{0}`".format(context["username"])) context["email"] = raw_input("Paste the email address and press enter: ") class SendPrivateKeyStep(object): def run(self, context): print("Go to 1Password") print("Paste the contents of ~/new_key into a new document") print("Share the document with {0}".format(context["email"])) wait_for_enter() if __name__ == "__main__": context = {"username": sys.argv[1]} procedure = [ CreateSSHKeypairStep(), GitCommitStep(), WaitForBuildStep(), RetrieveUserEmailStep(), SendPrivateKeyStep(), ] for step in procedure: step.run(context) print("Done.") This script doesn't actually do any of the steps of the procedure. That's why it's called a do-nothing script. It feeds the user a step at a time and waits for them to complete each step manually. At first glance, it might not be obvious that this script provides value. Maybe it looks like all we've done is make the instructions harder to read. But the value of a do-nothing script is immense: * It's now much less likely that you'll lose your place and skip a step. This makes it easier to maintain focus and power through the slog. * Each step of the procedure is now encapsulated in a function, which makes it possible to replace the text in any given step with code that performs the action automatically. * Over time, you'll develop a library of useful steps, which will make future automation tasks more efficient. A do-nothing script doesn't save your team any manual effort. It lowers the activation energy for automating tasks, which allows the team to eliminate toil over time. Share this: * Twitter * Facebook * Like Loading... Post navigation Previous An Incident Command Training Handbook Next Stop apologizing for bugs 71 thoughts on "Do-nothing scripting: the key to gradual automation" Comment navigation - Older Comments 1. Pingback: Do-nothing scripting: the key to gradual automation - Latest-News-Events 2. Pingback: New best story on Hacker News: Do-nothing scripting: the key to gradual automation - Cassinni 3. Pingback: Do-nothing scripting: the key to gradual automation - Cyber Geeks Global 4. Pingback: Do-nothing scripting: the key to gradual automation - MadGhosts 5. Pingback: Do-nothing scripting: the key to gradual automation (2019) by jabo - HackTech News 6. Pingback: Web Weekly #44 (#blogPost) - 51posts 7. Pingback: Web Weekly #44 (#blogPost) - The web development company 8. [VdV5zL_] Mayur (@mdave16) I built https://github.com/mdave16/executable_documentation from this blog post if you would prefer to do things from a different language or just want a starting off point. As I go through the various bits of documentation I have and create scripts for them, I will probably improve the templates in the repo, also open to input. 2021/11/07 at 21:42 Reply 1. [89f6a28] ahh Reminds me of the Controller in MVC (Model-View-Controller). The Controller should be very brief and not contain any business logic of the application. Instead, it ties together the Model component (business logic) and View component (how the user interacts with the application). If you read the Controller code it should give you a high level outline of the flow of the application, which matches what your do-nothing scripting describes 2024/01/19 at 19:14 Reply 9. Pingback: Weekly web development resources #95 | WebTutorialOnline | Programming News | Software Development | Web Development 10. Pingback: Compilation of great reads 11/2021 - The web development company 11. Pingback: tl;dr in tech by Joe Karlsson - Issue #4 - Joe Karlsson 12. Pingback: Hacker News Jin Ri TOP 20| 2025-02-08 - Chu Hai Jue Jin ,Wu Xian Ke Neng . Wei Du Li Kai Fa Zhe , Kua Jing Dian Shang Cong Ye Zhe , Hai Wai Zi Mei Ti Ti Gong Zui Xin Chu Hai Zi Xun He Zi Yuan - Chu Hai Jue Jin ,Wu Xian Ke Neng . Wei Du Li Kai Fa Zhe , Kua Jing Dian Shang Cong Ye Zhe , Hai Wai Zi Mei Ti Comment navigation - Older Comments Leave a comment Cancel reply [ ] [ ] [ ] [ ] [ ] [ ] [ ] D[ ] Search for: [ ] Search Top Posts * Do-nothing scripting: the key to gradual automation * The most important thing to understand about queues * Incident SEV scales are a waste of time * An Incident Command Training Handbook * When efficiency hurts more than it helps Archives * January 2025 * August 2024 * July 2024 * June 2024 * May 2024 * April 2024 * March 2024 * February 2024 * January 2024 * December 2023 * August 2023 * May 2023 * April 2023 * March 2023 * February 2023 * December 2022 * November 2022 * October 2022 * July 2022 * June 2022 * May 2022 * February 2022 * December 2021 * March 2021 * August 2019 * July 2019 * June 2019 * May 2019 * March 2019 * February 2019 * October 2017 * July 2017 * June 2017 * April 2017 * September 2016 * August 2016 * June 2016 * March 2016 * December 2015 * October 2015 * July 2015 * June 2015 * September 2014 * August 2014 * July 2014 * May 2014 * October 2013 * September 2013 * June 2013 * May 2013 * April 2013 * March 2013 * December 2012 * November 2012 * August 2012 * July 2012 Categories * Descriptive engineering * incident-response * Mind hacks * Monitoring * Post-mortems * Postgres * Problem-Solving * Statistics and probability * Uncategorized * Workflow Meta * Register * Log in * Entries feed * Comments feed * WordPress.com Blog at WordPress.com. Discover more from Dan Slimmon Subscribe now to keep reading and get access to the full archive. Type your email... [ ] Subscribe Continue reading * Comment * Reblog * Subscribe Subscribed + [croppe] Dan Slimmon Join 117 other subscribers [ ] Sign me up + Already have a WordPress.com account? Log in now. * Privacy * + [croppe] Dan Slimmon + Subscribe Subscribed + Sign up + Log in + Copy shortlink + Report this content + View post in Reader + Manage subscriptions + Collapse this bar %d [b]