vigeeking / dharma

My goal is to create a pipeline that is built exclusively with tools I either already know, or am only learning because they provide added value to the project
GNU General Public License v3.0
0 stars 0 forks source link

Create shell script for doing google labs #25

Open vigeeking opened 4 years ago

vigeeking commented 4 years ago

Since I'm taking the google IT support professional Certificate (https://www.coursera.org/specializations/google-it-support) for shits and giggles, I'm getting tired of having to download the pem file, change the permissions, etc every time I have to do a disposable lab. So I'm going to write a shell script to do all that for me. I was preparing to just write it extemperaneously, but I realized I needed to check my notes. If I need to check my notes, then I should probably make a story.

This story is done when I have a simple shell script that asks for the vm ip address and username, chmod's the pem file, and then connects using that pem file.

vigeeking commented 4 years ago

chmod 600 /home/tei/Downloads/.pem echo "what is the ip address" read ip echo "what is the username?" read name ssh -i /home/tei/Downloads/.pem $name@$ip

vigeeking commented 4 years ago

TODO: I need a way to either run recursive batch files, or otherwise figure out how I can eliminate the manual step between downloading the package, deleting everything in the folder (since it downloads as a random name), and running the above script. Also, Justin mentioned possibly using command operators instead of asking for input. This is a good idea, and I want to start implementing that. This story will be complete when I have made a second pass on this story and either created follow on stories or have otherwise dismissed the above ideas.

vigeeking commented 4 years ago

Additional todo: If I could add the ability to cut and paste from an arbitrary webpage, then I could completely automate the certification classes. While that in itself only has arguably nefarious uses, there could be a use in creating that as a test script to run against MY environment as a proof positive of the bare state working.
Further definition of pipeline: Part of the pipeline creation process should involve spinning up an environment from code that has nothing, deploying the pipeline onto it, and having an "interactive" session be established and checked. In other words, my script above is now my already written test case for an arbitrary definition of an ephemeral environment in my pipeline.

msaperst commented 4 years ago

A few thoughts, why are you prompting? Put in those values are command line parameters. If they're not provided, spit out an error message. An actual example from some of my code:


if [ "$#" -ne 3 ]; then
    echo "Error: Appropriate information not provided";
    exit;
fi
if [ $1 * 1 -ne $1 ]; then
    echo "Error: Number of vars not set as first input";
    exit;
fi
id=$1;
markup=$2;
album=$3;```
This should then allow a lot more flexibility - allow scheduling, doing it in batch, etc
msaperst commented 4 years ago

If I could add the ability to cut and paste from an arbitrary webpage

What information would you be looking to grab? A curl or wget might be able to extract a vast majority of what you want. There might also be API endpoints that provide that page with exactly what you need, which would be easier to parse

vigeeking commented 4 years ago

These are all of my assumptions:

So the way the "labs" in the classes go is they are using some form of vm creation to create an ephemeral vm (either windows or linux). They are then having you go in and manually do some file manipulation ( image ) and then "check" that against the desired end state. If the states match, the user then "passes" the test. All of that happens with clean handoffs where the user is being tracked across the vm creation, and the webpage receiving the instruction to "check" to see if the end state is correct.

I like this as an "interactive" check in it's cleanest sense. If I can automate the "taking" of the lab (look at this webpage, copy and paste that data here), then it means that I now have a neatly packaged "user test" that my script can now check for. So my understanding of TDD means I've written a very simple test that it would be good for them to have run in some form. Is that correct?

If so, then I think I have created a great test for anytime I am using an "ephemeral environement." If I can do the equivalent of logging in and running the commands copied and pasted from a different web page, then I'm pretty comfortable that my idea of "ephemeral" will be pretty durable.