What Do You Do If SonarQube Has No Logs and the Service Will Not Start?

Problem scenario
You try to start the SonarQube service.  It does not turn on or stay on.  You go to the logs directory in the "sonar" subdirectory on the Linux server.  Every time you run "sudo systemctl start sonar", there are no corresponding log entries.  You may find no logs at all.  What should you do to troubleshoot SonarQube to start when the logs are not helping you?

Solution
1.  Have the permissions changed on the files where it is installed?  Has the ownership or group of the files and the subdirectories of the Sonarqube installation changed?

If the user that runs the "sonar" service does not have the ability to write to the logs directory, you will not get proper information in the logs.  Check what Linux user and group owns the "sonar" subdirectory.  Run these two commands (where /path/of/parentdir/ is the path of the directory that houses the "sonar" subdirectory):

cd /path/of/parentdir/
ll

2.  If you do indeed find that the sonar subdirectory is owned by a user and group that is not special or dedicated for running the sonarqube service, run a command such as this:

chown -R sonar:sonargroup /path/of/parentdir/sonar

(If you need to find what the sonargroup is, try this: Log in as the sonar user or become root and run "su sonar".  Then run the groups command to see what user the sonar user has.)

3.  Try running these commands:
sudo systemctl enable sonar
sudo systemctl start sonar

How Do You Troubleshoot the Ansible Problem “IOError: [Errno 13] Permission denied…”?

Problem scenario
You are running an Ansible playbook, but you get an error like this:  "IOError: [Errno 13] Permission denied..."

How do you get the playbook to work?

Solution
If the playbook has a destination for a file and that file is already there on the managed node, this error may occur. 

1.  Go to the managed node. 
2.  Consider these four possible solutions:

  • Change the destination of the file in the playbook.
  • Move the file that is already in the destination file's place on the managed node to a different location.
  • Delete the file from the managed node.
  • Change the permissions of the destination directory on the managed node (either manually or via the Ansible playbook).

How Do You Write a Hello World Program in Lua?

Problem scenario
You want to run a basic Lua program as a test.  What do you do?

Solution
Prerequisite

You must have installed the Lua compiler.  If you are using a CentOS/RHEL/Fedora server, try this link.

Procedures
1.  Create a file called contint.lua with the following line:
print("This is a Hello World program")

2.  Run it with this command: lua contint.lua

How Do You Write a Hello World Program in Golang?

Problem scenario
You want to test out the Golang compiler.  You want to know how to write a basic Go program and run it.  What do you do?

Solution
Prerequisites

You must have the Golang compiler installed.  If you need help, see this posting.

Procedures
1.  Create a file called hw.go with the following five lines:

package main
import "fmt"
func main() {
    fmt.Println("This is a Hello World program!")
}

2.  Run the program by executing this command:  go run hw.go

How Do You Install the Lua Compiler on a CentOS/RHEL/Fedora Server?

Problem scenario
You want to run Lua programs on your Red Hat derivative distribution of Linux server (e.g., CentOS/RHEL/Fedora).  

Solution
1.  Make a script like this called lua.sh with the following lines:

yum -y install readline-devel gcc
curl https://www.lua.org/ftp/lua-5.3.5.tar.gz > /tmp/lua-5.3.5.tar.gz
mv /tmp/lua-5.3.5.tar.gz /opt/
cd /opt/
tar -xzvf lua-5.3.5.tar.gz
cd lua-5.3.5
sudo make linux test
echo "ENV=$ENV:/opt/lua-5.3.5/src/" >> /etc/environment
rm /usr/bin/lua
ln -s /opt/lua-5.3.5/src/lua /usr/bin/lua
a=$(lua -v)
echo $a

2.  Run the script with this command: sudo bash /tmp/lua.sh

What Are The Differences between CMD and ENTRYPOINT in Docker?

Question
Dockerfile has reserved words CMD and ENTRYPOINT.  They seem to do the same thing.  What are the differences between CMD and ENTRYPOINT in Docker besides their words' lengths?

Answer
There are many similarities between these two reserved words in Dockerfile "language."  But here are three differences:

#1  "...CMD can be overwritten by an argument to docker run, while ENTRYPOINT can be overwritten only by using the --entrypoint option of docker run." is a quote taken from page 43 of Docker Cookbook by Sebastien Goasguen.

If you want your Docker container to use different executables or parameters each time, CMD is preferable to ENTRYPOINT.

"If you would like your container to run the same executable every time, then you should consider using ENTRYPOINT in combination with CMD." taken from Docker's official website.

#2  CMD has three forms whereas ENTRYPOINT has only two forms.  The syntax associated with each of these forms will tell the Docker engine which to form to use.  The CMD forms are these: exec form (which is recommended), the default parameters method, and the shell form.  The ENTRYPOINT forms are these: exec form (recommended) and shell form.

You can read more about them here:
https://docs.docker.com/engine/reference/builder/#cmd
https://docs.docker.com/engine/reference/builder/#entrypoint

#3   In the history of Docker, CMD was a command before ENTRYPOINT become a supported reserved word.  This is relevant, external posting states this fact.  The Dockerfile used to be considered a manifesto (according to page 43 of Docker Cookbook by Sebastien Goasguen).  You can read more about the ways Docker has changed here.

How Do You Install docker-compose on Any Distribution of Linux?

Problem scenario
You want a Bash script to install Docker on any distribution of Linux.  You want to use the same script for each Linux server.  How do you write a script that will install docker-compose on any type of Linux including CentOS/RHEL/Fedora, Debian/Ubuntu and Linux SUSE?

Solution
Overview

This will work with AWS or Azure servers or on-premise servers.  It requires that the server have access to the internet.

Procedures

1.  Create a file call dc.sh with these lines:

#script to install Docker compose
version=1.20.1  #change the version as needed
curl -L https://github.com/docker/compose/releases/download/$version/docker-compose-`uname -s`-`uname -m` > ./docker-compose
mv ./docker-compose /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose

2.  Run this script dc.sh like this: sudo bash dc.sh

How Do You Troubleshoot the Ansible Message “AnsibleOptionsError…ansible.cfg…File contains no section headers”?

Problem scenario
You try to run an Ansible playbook but you get this error "AnsibleOptionsError...ansible.cfg...File contains no section headers"

Your ansible.cfg file has headers. What should you do?

Solution
Eliminate indentations.  The [header] should be on the far left of the screen with no leading spaces.

How Do You Troubleshoot the Bash Error “syntax error near unexpected token”?

Problem scenario
You run a Bash script with a function that you developed yourself.  When you run the script, you get the error "syntax error near unexpected token".  What should you do to solve this?

Solution
Call the function without the parentheses.  Do not use this: contintfunc()

Use this when you call, not define, your previously defined function:

contintfunc

How Do You Use an .sls File to Push down Configuration Changes Using SaltStack?

Problem scenario
You want to leverage the CM tool SaltStack.  You have Salt Master installed, and now you want to push down files to Salt Minion client servers.  How do you do this?

Solution
Prerequisites

This solution requires Salt Master to be configured.  If you need assistance, see this posting.

Procedures
1.  The Salt Minion client servers will need to run this:  sudo systemctl start salt-minion

2.a.  On the Salt Master server create a directory /srv/salt/ (e.g., sudo mkdir -p /srv/salt)

2.b.   Create this file: /srv/salt/top.sls with the following three lines of content:

base:
'*':
- funfun

2.c.  Create this file: /srv/salt/funfun.sls with the following three lines of content:
/tmp/great.txt:
file:
- managed
- user: cooluser
- mode: 644
- source: salt://good.txt

2.d.  Create this file: /srv/salt/good.txt with whatever content you want.

3.  Restart salt-master serivce with this command:  sudo systemctl restart salt-master

4.  Push the file down with this command: sudo salt '*' state.apply

5.  Go to the Salt Minion client servers. The /tmp/ directory should have a file called great.txt.