How Do You Test the Database Credentials (username and password) of a PostgreSQL Database Using Bash?

Problem scenario
You are not sure if the username and password to a PostgreSQL database work.  What do you do?

Solution
Run this one-line command:

psql -d “postgresql://jdoe:coolpassword@localhost/foobardb” -c “select now()”

# Replace “jdoe” with the SQL database username
# Replace “coolpassword” with the user’s password
# Replace “foobardb” with the name of the database you are authenticating too
# If you have the PostgreSQL client installed (so psql works) and the database is remote,

How Do You Configure Jenkins Builds to Avoid Slave Servers That Are Either Windows or Linux?

Problem scenario
You are configuring Jenkins jobs.  You want certain jobs to only run on Windows slaves (e.g., PowerShell jobs) and certain jobs to only run on Linux slaves (e.g., Bash scripts).  You want to force a job force a selection of a slave server to avoid Windows or Linux servers.  How do you have Jenkins avoid slave servers based on the OS architecture?

Solution
1. 

How Do You Find the Version of SonarQube That You Have Installed?

Problem scenario
You have installed SonarQube.  You want to know what version you are using.  How do you find out?

Solution
Go to the web UI for SonarQube.  It may be as simple as opening a web browser and entering the external IP address of the server.  Without logging in scroll to the bottom.  You should see something like this near the bottom:  Version 6.7 (build 33306)

How Do You Change the Base URL for SonarQube?

Problem scenario
Currently you have to enter a URL like this to access SonarQube’s web UI:

http://servername.com:9000/sonar

You want to be able to type no path (e.g., no “sonar”) in the web browser.  You want to just enter the hostname in the web browser and the port number of the SonarQube server.  What should you do?

Solution
Go to the conf directory [that is a sibling] with the sonar.properties file. 

How Do You Prepend or Append to a Variable in Ansible?

Problem scenario
You are using a variable in Ansible.  You want to attach a string to it to augment this variable.  You can rename it so later in the playbook you can call this modified, augmented version of the variable.

You assign the variable like this:

foo: ” {{ bar }}”

You want foo to have an extra string (e.g., “/subdirectory/path/to”).  What do you do?

How Do You Troubleshoot the SonarQube Problem with Nothing Displaying in the Web Browser?

Problem scenario
You go to the SonarQube web UI to log in.  You see nowhere to log in but no error either.  What could be wrong?

Solution
Have your web browser accept cookies.  If you block cookies and using Apache web server with SonarQube 7.x, you may experience this problem.

What is the Sonar Scanner?

Question
You have read about the Sonar Scanner.  What is it exactly?

Answer
It is now called the SonarQube Scanner — not the Sonar Scanner.  Source: https://docs.sonarqube.org/latest/

“The SonarQube Scanner is recommended as the default launcher to analyze a project with SonarQube.”  This quote was taken from
https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner.

What Is the Difference between a Node and a Pod in Kubernetes?

Question
You are using Kubernetes.  You read about Nodes and Pods.  What is the difference?

Answer
A Pod is a collection of one or more containers (e.g., Docker or rkt containers).  A node is a server that is the home of one or more Pods.

“A Node is a worker machine in Kubernetes and may be either a virtual or a physical machine…” (taken from 

How Do You Find the Number of Active Connections That an Nginx HTTP Load Balancer Has?

Problem scenario
You have an Nginx instance configured to be an HTTP load balancer (aka invisible landing page, pass-through distributor or reverse proxy).  You want to analyze the inbound web traffic that your Nginx server is currently receiving.  How do you find out how many active connections there are through the load balancer?

Solution
1.  Modify the /etc/nginx/conf.d/default.conf file in the Nginx HTTP load balancer. 

How Do You Set up a Basic CI/CD Pipeline with GitLab and Jenkins?

Problem scenario
You want to create a rudimentary CI/CD pipeline (one that is simple and has no QA or automated testing of code).  You want to trigger a deployment of code upon code being checked into a Git repository.  You want to set up GitLab and Jenkins to be the main servers of this pipeline.  You have two other servers; one is for developing code on and checking code into a Git repository and the other server is for receiving code once it is checked into GitLab.