How Do You Fix a .service File for systemctl Commands to Work?

Problem scenario
You have a bash command that works reliably. But when it is in a .service file (e.g., the ExecStart stanza) the corresponding systemctl command with systemctl start fails. You have tried putting quotes around the arguments in the ExecStart stanza. Using your .service file with systemctl almost works; but there is an unlogged failure that you do not expect. The service (e.g., Logstash or some other service) fails quickly.

How Do You Secure a Docker Container, a Docker Host, and Their Network?

Problem Scenario
You have been tasked with finding ways of securing Docker containers, a Docker host, and your network that has Docker containers.  How do you harden a Docker container and its related infrastructure (i.e., the Docker network and Docker host)?

Solution
Overview

From a pragmatic perspective we understand that there are exceptions to the recommended practices.  (Not the least of which is the rapid rate that technology changes.)  The assertions below are recommended practices. 

How Do You Troubleshoot a Python Error “UnboundLocalError: local variable ‘x’ referenced before assignment”?

Problem scenario
You run a Python program but you get this error: “UnboundLocalError: local variable ‘x’ referenced before assignment”

Solution
Root Cause

You have a function in Python and it refers to a previously assigned variable.  This variable was not passed as a parameter.

Procedures
You need to redeclare (but not necessarily reassign) the variable as a “global”. 

How Do You Delete VM Instances from GCP That Pertain to GKE?

Problem Scenario
You have some GKE standard clusters that you want deleted.  What should you do?

Possible Solution #1 (from the Cloud Shell or with a gcloud command)
1.  Delete the instance group of the instance for the cluster you want to delete.  To do this in the web UI, go to Compute Engine -Instance Groups.  Check the box on the left-hand side and click on “Delete”.

How Do You Write a Tic-Tac-Toe Program in Groovy?

Problem scenario
You want to code a Groovy 2.x program.  You want a program that reads user input, prints out processed output, uses closures (similar to functions in other languages) with and without return statements, handles some exceptions (non-standard input or input that is no longer valid based on what was previously entered), and uses classes.  How do you write a Tic-Tac-Toe (aka naughts and crosses) program in Groovy that has the above things?

How Do You Invoke a class in a Groovy Program?

Problem scenario
You have a Groovy with these lines of code:

class Contint {
   static void main(String[] args) {
      def apple = {println “This is a basic test.”};
      apple.call();
   }
}
println “This is the second print statement in the code.”

The “Contint” class is never invoked.  What should you do?

Solution
Overview

You need to use the “new” reserved word.  This will instantiate the class. 

How Do You Create a Logic App without Using the Azure Portal Web UI?

Problem scenario
You want to create a Logic App without using the Azure Portal web UI.  What should you do?

Possible Solution #1
To get an overview of using an ARM template for a Logic App, you should read this article.

Possible Solution #2
If you have Visual Studio, you can use the Azure Logic Apps Tool for Visual Studio. 

How Do You Troubleshoot This Message “ImportError: No module named ‘google.cloud’?

Problem scenario
You run a Python program or from the Python command prompt you receive this message:

Traceback (most recent call last):
  File “main.py”, line 21, in <module
    from google.cloud import pubsub_v1
 ImportError: No module named ‘google.cloud’

ModuleNotFoundError: No module named ‘google’

What should you do to eliminate this problem?

Possible Solution #1
Try to run the program as sudo:

sudo python nameOfProg.py

Possible Solution #2
Try this with or without sudo (depending on whether or not you are using “sudo” to run the Python program):

sudo pip install google-cloud-bigquery

# You may or may not want to omit the “sudo” in the above command.