Mike Ciavrella's Scripting for Automation
Core Skills: Scripting for Automation was taught by Mike Ciavrella, a 12-year LISA veteran.
He created this class as a response to so many people he encountered who were automating because they knew it was a "best practice", and that they should "automate everything". Mike found that people didn't think about why they were automating, and he knew that was as important as actually doing the automation.
If I could provide only one take-home, it would be that automation is not scripting; scripting necessarily arises from automation, not the other way around. Don't build automation because you write scripts; write scripts because you're automating.
This class was divided primarily into two sections - first, establishing some guidelines and general best practices, and the second being practical, with a dive into shell scripts, which are commonly used in UNIX-like environments to automate processes. Mike postulates that there are four principles to automation:
- Visibility Logging must be built-in
- Idempotence Idempotence is the idea that repeating an action doesn't repeat the action - it guarantees that the action brings the system into alignment with policy
- Robustness Exceptions to the rule shouldn't leave the system in an unstable state. Make sure that the script cleans up after itself - both upon successful and unsuccessful termination, if at all possible.
- Automation is Abstraction Abstraction aids higher-level understanding but hides details
It's definitely beyond the scope of this blog entry to cover the scripting that Mike went over. I would recommend taking this class (or his Advanced Bash Scripting class) the first chance you get. In the meantime, you can pick up some good habits in your shell script in the Advanced Bash Scripting Guide.