interview questions for devops

This is the last day of May 2020, hard to imagine that we are here. For someone my age, its a blessing to have lived this long. I watched Blade Runner the movie as a teen, and the future was 2019, a long way away from 1982. The writer figured in thirty years, we would have floating cars, clones, and common slaves (made from cloned humans). It didn’t all happen in 2019 for sure. To be sure of what the writer imagined, watch the movie! We have amazing technology for sure. So in 2020, you are going to get a new hot job for yourself, and get ready for the interview test. This month a friend needed some help with a interview question.

So my friend, mostly doing networking, gets into a cloud / devops job. Mostly a glorified Sysadmin position with average to below pay, but the benefits lure him in. He is in a panic about the XML interview question. Its a large text file with repeating xml/json like strings, each section for a user/computer pair that is in use by the organization. So the interview question is this:

I have a large JSON file, using any programming tool or language, I want you to change every password string in this file to a random string, instead.

Simple right? Well I do these things on a regular basis, but this one was a bit different. I didn’t give him the entire interview answer, but I gave him some hints. I was going to do the data processing with unix SED/AWK, but changed my mind and used powershell instead.

Here is the json file, what it looked like.

PS C:\Users\superDaveRDeluhery> type json.txt
db password : it43ss3489888~
username : superdave
text comment : a wonderful life
data home path : \data\user\superdave
comment : 10

Here is powershell line with REGEX, looks for semicolon : then two digits (d{2}). And replaces with ‘ken’. Notice the “comment : 10” line is now changed with new value.

PS C:\Users\superDaveRDeluhery> (Get-Content -path json.txt -Raw) -replace “\: \d{2}”, “: ken”
db password : it43ss3489888~
username : superdave
text comment : a wonderful life
data home path : \data\user\superdave
comment : ken

—— here same command, but create a new file called newjson.txt (instead of just writing to the screen)

PS C:\Users\superDaveRDeluhery> (Get-Content -path json.txt -Raw) -replace “\: \d{2}”, “: ken” >> newjson.txt

display the changed file

PS C:\Users\superDaveRDeluhery> type .\newjson.txt
db password : it43ss3489888~
username : superdave
text comment : a wonderful life
data home path : \data\user\superdave
comment : ken
PS C:\Users\superDaveRDeluhery>

Have not found the powershell command to create a random string, assign it to a variable, then use that to replace the text. Appears pretty easy to get random numbers, those might need to be converted to char so that you can get random strings (which the interview might want you to create random strings of letters and numbers, not just numbers).

https://ss64.com/ps/get-random.html

##———————- another test question

June 22/ update – In life we have tests, you do them your way and go from there. Most of us take the easiest route, the path of least resistance. We all do it. But cut and paste is not really possible when you have 50,000 lines to replace. So here is a another test question. You have a list of objects in a text file, like three hundred objects in a text file. You have a single line, an ACL, and you need to create a new acl so that we replace a token in a line entry, and create three hundred line entries having a different object. Here is the example of the data:

myfile.txt contents:

object extended super_acl_55

object extended super_acl_56

object extended super_acl_533

object extended super_acl_5523

How do you take that data and create a new ACL using that data? My answer is use windows shell, use the “for” command to grab the third token (tokens=3). Each token gets echo into a line. I see how to do this in powershell. . .but have not done it, yet. When I grow up and become awesome at powershell, I will perhaps be too old to type. Haha! Back to the for loop. The for example is below:

C:\Users\users_uhery>for /F “eol=; tokens=3,4* delims=, ” %i in (myfile.txt) do @echo access-list CR.ITS line 50 extended permit tcp object %i object PP.qfTTtp.ieft.com-100.10.20.21 eq ssh

This uses the “for” shell command. The command, the for command, will process each line and will take each lines third token, example “super_acl_533) and put that data into the echo statement. So in the echo you see

echo access-list CR.ITS line 50 extended permit tcp object %i object PP.qfTTtp.ieft.com-100.10.20.21 eq ssh

See the %i, between the object and object? See that? Its the variable that for uses to hold the token. That gets replaced with the “super_acl_533”. So the final output would be

access-list CR.ITS line 50 extended permit tcp object super_acl_55 object PP.qfTTtp.ieft.com-100.10.20.21 eq ssh

access-list CR.ITS line 50 extended permit tcp object super_acl_56 object PP.qfTTtp.ieft.com-100.10.20.21 eq ssh

access-list CR.ITS line 50 extended permit tcp object super_acl_533 object PP.qfTTtp.ieft.com-100.10.20.21 eq ssh

##———————- end of test question

Since this is a cisco blog, a few cisco things. Studying CCIE wireless? Understand SSDP and mDNS, you must. Check out SSDP using UDP and multicast. Seen packets with M-SEARCH? Check out details.

https://williamboles.me/discovering-whats-out-there-with-ssdp/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s