How Do You Use tar to Create a Single File That Is a Copy of a Subdirectory and All of Its Files and Subdirectories?

Problem scenario
You want to recursively copy subdirectories from on Linux machine to another.  How do you copy them into one file with the directory structure for the purpose of transferring it later?

Solution
On the source server go to the parent directory that you want to compress into one file.  Run this tar command:

tar cvfz target.tgz subdirsource/

Now target.tgz will have all the directories of 

How Do You Get ansible-vault to Prompt You for a Password to Encrypt a File That You Create?

Problem scenario
You are using the ansible-vault command.  You are not being prompted for a password as the documentation suggests you would be.  You want to use ansible-vault create or ansible-vault edit and be prompted for a password. How can you specify a password manually?  How can someone on a different Ansible server decrypt your encrypted files?  

Possible solution #1
Modify the ansible.cfg file.

What Should You Do It You See Duplicate Plugins in Jenkins List of “Available” Plugins?

Problem scenario
You log into Jenkins.  You go to Manage Jenkins -Manage Plugins -Available.   You see the same plugin listed twice (e.g, under different categories such as “Build Reports” or “External Site/Tool Integrations”).  What should you do?

Solution
This is a workaround: look at the version of the plugins.  Are there duplicates the same version?  If the versions are the same, ignore one duplicate as we do not think it will cause a problem. 

What Is the Python Requests Syntax Equivalent of a curl “-X DELETE”?

Problem scenario
You are invoking requests.get() in a Python program (after an “import requests” statement near the top of your code).  You want to pass the equivalent of “-X DELETE” in curl in your Python program.  How do you use the DELETE option with a REST API call in Python?

Solution
Prerequisites

This assumes you have “requests” installed (e.g., sudo pip install requests). 

How Do You Troubleshoot the SonarQube Problem “Service unavailable” in the Web UI?

Problem scenarios
Your situation is described in one of two ways.

#1  You go to the SonarQube web UI to log in.  You see nowhere to log in.  You see this error: “Service Unavailable    The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.”  What should you do?

Or your situation is like this:

#2 

How Do You Troubleshoot PHP Not Displaying the Output of a Bash Command?

Problem scenario
You have a PHP program that works from the back-end (from a command terminal executing like php foobar.php). When you view the program in a web browser, it is not running the Bash commands properly. What should you do?

Solution
The root cause is probably the user execution context and a variety of permissions or configuration settings on the Linux system.

How Do You Write to a File with Python?

Problem scenario
You want to store variable values in a log file.  How do you get Python to write to a log file?

Solution
Use these lines in your Python program:

var1 = ‘contint’

with open(‘contint.log’, ‘a’) as contint_log:
    contint_log.write(“\n”)  # creates a new line
    contint_log.write(var1)
    contint_log.write(“Done writing variable.\n”) # template text

How Do You Install SonarQube Scanner on a RHEL Server?

Update on 2/10/22: The Python example is a little dated. Back when Python 2.x was common, the print statements didn’t necessarily have parentheses.

Problem scenario
SonarQube does not work without a launcher installed.  The web UI seems complete, but it is not.  You need a CLI launcher of some sort on the back-end.  You want to use sonar-scanner from the command prompt to analyze some code. 

How Do You Capture Error Messages in a File of Your Choice Using Python Rather Than Have Them Printed to the Screen?

Problem scenario
You have a Python program that displays urllib3 (or some other type) of message to the screen.  You do not want them echoed there cluttering the screen.  You want to redirect the output to a log file (to permanently store the data).  How do you get a Python program to write to a log file?

Solution
Use these three lines, but replace “contint” with the name of your choice:

import logging

logging.basicConfig(filename=’contint.log’,

How Do You Get a Jenkins Plugin to Work That Normally Uses the Internet When You Have No Internet Access?

Problem scenario
Your Jenkins server has no access to the internet.  You are trying to run a  Jenkins job that involves a plugin.  You receive a 407 error when a job runs.  You look at the console output and see java.io error that deals with being unable to connect to a website.  How do you customize a Jenkins plugin to retrieve installation media from an internal server instead of a default website URL?