FREE UNLIMITED IMAGE HOSTING

FREE UNLIMITED IMAGE HOSTING FOR ALL.

DizinPix.com is one of the best image-hosting resources to HIDE YOUR IMAGES AND LOCK IMAGES WITH PASSWORD.

UNDERSTOOD. YUM!
Get Full Information
Categories: Symbolic

Do-nothing scripting: the key to gradual automation

Get Full Information
12 Views

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.

Get Full Information

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.

Get Full Information

Read More

Get Full Information
Ramshyam

Show comments

Recent Posts

SBI Recruitment 2019, Apply online for 600 Apprentice Vacancies @ www.sbi.co.in

SBI Recruitment 2019, Apply online for 600 Apprentice Vacancies @ www.sbi.co.inSSC CPO Recruitment 2019, Apply Online for CAPF Various SI…

6 days ago

Start your career in Clinical Research. Join India's leading Clinical Research Institute. Admissions Open for October, November & December 2019 batch

Start your career in Clinical Research. Join India's leading Clinical Research Institute. Admissions Open for October, November & December 2019…

1 week ago

Jntua – R&D-Discipline Wise available Ph.D. Seats for the academic year 2019-20

Jntua – R&D-Discipline Wise available Ph.D. Seats for the academic year 2019-20 Download Available Ph.D. Seats 2019-20

1 week ago

Challenge Valuation results for MBA IV sem (R17) Reg & Supple May 2019 Exams

Challenge Valuation results for MBA IV sem (R17) Reg & Supple May 2019 Exams Download MBA IV sem May 2019…

1 week ago

Challenge Valuation results for B.Tech IV Yr II sem (R15) Adv. Supple July 2019 Exams

Challenge Valuation results for B.Tech IV Yr II sem (R15) Adv. Supple July 2019 Exams Download B.Tech IV-II (R15) Adv.…

1 week ago