How Do You Create a File on a Server with Terraform?

Problem scenario
You are trying to get user data to create a file on a server in Terraform. It is in a directory that requires sudo privileges. You use the “sudo” command in the Bash script. The Bash script executes except a file is never transferred. How do you get Terraform to copy a file to a new server?

Solution
Use the Terraform-supported cloud_config option instead of having a Bash script transfer the file.

How Do You Do a regex Operation in Python without Importing a Module?

Problem scenario
You need a pattern matching function in a Python program, but you cannot use “import re”. What should you do?

Possible Solution #1
Use the index() function.

Here is an example:

foobar = “abcdefghijklmnopqrstuvwxyz”
print(foobar.index(‘jk’))

Possible Solution #2
Use the .starswith() function.

foobar = “abcdefghijklmnopqrstuvwxyz”
print(foobar.startswith(‘abc’))

Possible Solution #3
Use the find() function.

Where Are The SSH Logs in Fedora?

Problem scenario
You are trying to find the SSH logs in Fedora. Where should you look?

Possible solution #1
/var/log/secure/

Possible solution #2
Check these locations:
/var/log/ssh/
/var/log/auth.log

Possible solution #3
/var/log/messages
(Many other applications write to this file besides SSH.)

Possible solution #4
They could be stored in binary format in /var/log/journal/ …

Run this command: journalctl -u sshd
Look at the output.

What is the Difference between a Data Structure Container and a Virtual Environment Container?

Question
You have heard about different types of containers and seek a disambiguation. Can containers be disambiguated?

Answer
One type of container is a virtual environment like Docker. Another type of container is a data structure of a programming language such as an array, set, list, tuple, or dictionary. These different types of collections of data are called containers.

What Are cgroups?

Question
You know cgroups provide isolation (along with namespaces in the context of containers). But what exactly are cgroups?

Answer
cgroups enforce hard limits of subsystems to allow efficient allocation of resources of the super-system.

Cgroups allow you to allocate resources — such as CPU time, system memory, network bandwidth, or combinations of these resources — among user-defined groups of tasks (processes) running on a system.

How Do You Troubleshoot Connectivity over Port 80 when You Know It Is Listening?

Problem scenario
A server is hosting a website. On the server, nmap -Pn x.x.x.x is showing port 80 is listening on the server itself. From another server this nmap -Pn x.x.x.x command is showing no ports (or a subset of the ports) are listening. What is the cause of this?

Possible Solution #1
There is a firewall on the webserver that is causing this.

Why is a Kubernetes Pod’s Status “Pending”, and What Can Be Done about It?

Problem scenario
You have a Pod that you want to run on a worker node. Its status is “Pending.” What can you do to get the Pod to proceed (and what are some common root causes for this problem)?

Background
A common root cause is that the nodes have insufficient resources for the Pod (e.g., insufficient CPU or memory).

Possible Solution #1
Wait.

Is It a Best/Recommended Practice to Use Branching with Version Control Systems?

Problem scenario
You are debating on using branching with your repositories or using trunk-based development (with virtually no other branches). Is it a best practice to develop on the mainline (with branching infrequently if ever)?

Solution
Maybe. It is not clear.

In Support of the “Yes” / You Should Use Branches
In practice many companies use Git Flow or other branches in their Git repositories.