Happy Halloween!!

Did you know these two interesting facts about Halloween?

If you are looking for a type of cinnamon that you do not eat and yearn for that creepy green glow color, try Linux Mint (not the type you eat) on a bootable USB stick.  Linux Mint has a "Spooky" login theme that is very festive for today.  On the topic of Linux and Halloween, you may want to read this article that CNet published ten years ago about Microsoft's relationship to open source software. 

Halloween is celebrated around the world; if you want to read about the different locations, you can consult with Wikipedia here.  To prepare your manse for a special effects extravaganza, there is now software that is ideal for Halloween lights in your yard.  If your budget cannot afford you this luxury and you want just that one Misfits song "Halloween," you can buy it alone for a low price.  If you need a pair of those festive Misfits gloves, you can buy them here.  Halloween skeleton costumes remind some people of The Karate Kid movie especially this scene.  The movie involves an underdog who learns self-defense techniques without realizing it.  By waxing cars for an immigrant mentor the underdog, Italian American youngster develops a muscle memory and physical reflex to block attacks from his opponents.  On the topic of southern European underdogs, the Battle of Thermopylae was won by the Greeks.  By winning this battle the Greeks, who do not celebrate Halloween, have given struggling people hope to those who read about this famous battle.  The victory shows the benefits of both patriotism (knowing your country and its land and being prepared to sacrifice) and preparation can combine to prevail against incredible odds.

The writer of The Karate Kid movie (Robert Kamen) went to the University of Pennsylvania and received a PhD in American Studies.  Kamen's focus on America undoubtedly played a role in his ability to create touching stories for films that have a broad appeal to movie watchers in the U.S. Relevant to Philadelphia (where the University of Pennsylvania is), we had this post for Constitution Day.  Philadelphia, despite being home to many technology companies (some of them growing rapidly),  has many historic buildings with gothic architectures which would be great to see in the fall (with trees' leaves changing colors).  Trick-or-treaters would love the costumed Patriotic interpreters as well.  Benjamin Franklin founded the University of Pennsylvania -- despite having only two years of schooling himself.  The first American to propose daylight saving time was Ben Franklin himself, and for many years clocks were set back in October (lasting until 2006).  This made it seem like sunset came earlier on October 31st which was great for trick-or-treating enthusiasts who could not stay up late due to their parents' caring restrictions. 

What Are Some Tips on a Bash Programmer Becoming a PHP Programmer?

Problem scenario
You are a Bash programmer, but you want to learn how to code in PHP.  How do you learn to develop PHP scripts when you have a Linux bash background?

Solution
If you are new to PHP programming and familiar with Bash programming, remember these tips:

1.  Variable assignments involve the variable with the syntax of a cash sign "$" before the variable name.  Here is an example:

$var4        = 4;

2.  An error such as this "PHP Parse error:  syntax error, unexpected '...' (T_VARIABLE) " can be caused by forgetting to have a semi-colon at the end of a line.  Here is an example:

$var1        = "A sentence";

3.  To concatenate strings, use a period between two variables like this:

$var3        = $var1.$var2;

4.  Here is a basic program to learn about arithmetic and conditionals:

<?php
   $var1        = "The beginning of a sentence";
   $var2        = " and other stuff.";
   $var3        = $var1.$var2;
   $var4        = 4;
   $var5        = 5;
   $var6        = $var4 - $var5;
   if ($var6 > 3) { echo "It is bigger than three!!!";}
   else { echo "It is not bigger than three!!!";}
?>

Save the above file as test.php, and run it with this command: php test.php

How Do You Troubleshoot the Jira Cluster Message “Node is not using the correct shared home…”?

Problem scenario
In the Jira "Instance health checks" section you see a problem has been detected under the "Cluster" section.  It says "Node jiranode1 is not using the correct shared home..."  How do you get this error to go away?

Possible solution #1
Log into the node on the back-end.  Stop the Jira service and then start the Jira service.

Possible solution #2
Log into a working node on the back-end.  Look at the differences between the directories with the one that is not working.  Are the permissions set similarly?  Do they have the same subdirectories?

Possible solution #3
Go here for more information.

How Do You Troubleshoot the SonarQube Scanner Error “java.lang.IllegalStateException: Unable to load component class or.sonar.scanner.scan.ProjectLock”?

Problem scenario
You are trying to run SonarScanner, but you get an error about "java.lang.IllegalStateException: Unable to load component class or.sonar.scanner.scan.ProjectLock".  What should you do?

Possible solution
Is there a sonar-project.properties file in the directory where you are running the above command?  Does your user have access to read the file?  Check these things first.

How Do You Delete a Network Interface in AWS When You Get an Error about Not Having Permission?

Problem Scenario
In AWS you try to delete a Security Group.  You cannot do it because you get an error that "These security groups are associated with one or more network interfaces.  Delete the network interfaces, or associate them with different security groups."  You click the link "View your network interfaces."  But you are unable to delete the network interfaces.  You try to "Detach" them (with the "Force detachment" option), but you get "Error deleting network interface. You do not have permission to access the specified resource."

What do you do to delete a Network Interface in AWS when you get this error?

Solution
Look at the "Description" column of "Network Interfaces" (which is under "Network and Security").  Find the relevant item, device or object (e.g., if you see ELB go to Load Balancing -> Load Balancers).  Delete this object if you are procedurally able to do so.  Then go back and delete the Network Interface.  Now you can delete the Security Group.

Advertisement
You may want a book on AWS networking such as one of the following:

1119439833AWS Certified Advanced Networking Official Study Guide: Specialty Exam
B07JCS19YJBuilding a Modular and Scalable Virtual Network Architecture with Amazon VPC: VPC Quick Start
B07S8ZTHPXAWS Certified Advanced Networking - Specialty Exam Guide: Build your knowledge and technical expertise as an AWS-certified networking specialist
B0742HR1Y4AWS Networking Cookbook: Powerful recipes to overcome the pain points of optimizing your Virtual Private Cloud (VPC)

How Do You Troubleshoot the Docker Command Error “not a valid repository/tag”?

Problem scenario
You are trying to run a Docker command, but you get this error:

Error parsing reference: " continual/integration" is not a valid repository/tag.

What do you do?

Solution
Look to see if you have an extra "\" or space in your Docker run command.  That can cause this problem.

How Do You Install the Elastic Stack on Any Type of Linux?

Updated on 9/24/19

Problem scenario
You want to install Elastic Stack on different distributions of Linux with the same exact script.  What should you do?

Solution
Prerequisites
i. You should have at least 3 GB of total memory (a combination of virtual memory and RAM) allocated to the server. If you need to add memory, see this posting.

ii. Install the Java Development Kit version 8.  If you need assistance, try running a script with the following content:

#!/bin/bash
# Written by www.continualintegration.com

distro=$(cat /etc/*-release | grep NAME)

debflag=$(echo $distro | grep -i "ubuntu")
if [ -z "$debflag" ]
then   # If it is not Ubuntu, test if it is Debian.
  debflag=$(echo $distro | grep -i "debian")
  echo "determining Linux distribution..."
else
   echo "You have Ubuntu Linux!"
fi

rhflag=$(echo $distro | grep -i "red*hat")
if [ -z "$rhflag" ]
then   #If it is not RedHat, see if it is CentOS or Fedora.
  rhflag=$(echo $distro | grep -i "centos")
  if [ -z "$rhflag" ]
    then    #If it is neither RedHat nor CentOS, see if it is Fedora.
    echo "It does not appear to be CentOS or RHEL..."
    rhflag=$(echo $distro | grep -i "fedora")
    fi
fi

if [ -z "$rhflag" ]
  then
  echo "...still determining Linux distribution..."
else
  echo "You have a RedHat distribution (e.g., CentOS, RHEL, or Fedora)"
  yum -y install java-1.8.0-openjdk*
  JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk
  echo 'export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk' >> ~/.bashrc
  source ~/.bashrc
  source /etc/environment
fi

if [ -z "$debflag" ]
then
  echo "...still determining Linux distribution..."
else
   echo "You are using either Ubuntu Linux or Debian Linux."
   apt-get -y update # This is necessary on new AWS Ubuntu servers.
   apt -y install openjdk-8-jre-headless
fi

suseflag=$(echo $distro | grep -i "suse")
if [ -z "$suseflag" ]
then
  if [ -z "$debflag" ]
  then
    if [ -z "$rhflag" ]
      then
      echo "*******************************************"
      echo "Could not determine the Linux distribution!"
      echo "Installation aborted. Nothing was done."
      echo "******************************************"
      exit
    fi
  fi
else
   zypper -n install java-1_8_0-openjdk java-1_8_0-openjdk-devel
fi

Procedures
Warning: This script requires access to the internet.  It bypasses the HTTPS feature provided by elastic.co.  This may not be recommended in some environments.

1.  Create a script called "elasticstack.sh" with the following stanzas:

#!/bin/bash
# Define variables for version, Elastic Stack user and group
version=6.4.0
esu=esu
esg=esg

echo $esu"    -    nofile    65536" >> /etc/security/limits.conf

useradd $esu  # For SUSE
adduser $esu # For Red Hat and Ubuntu/Debian distributions
groupadd $esg # For SUSE
addgroup $esg # For Red Hat and Ubuntu/Debian distributions

curl -k https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$version.tar.gz > /tmp/elasticsearch-$version.tar.gz
cd /opt
cp /tmp/elasticsearch-$version.tar.gz /opt
tar -zxvf elasticsearch-$version.tar.gz
mv elasticsearch-$version elasticsearch
sudo chown -R $esu:$esg /opt/elasticsearch

curl -k https://artifacts.elastic.co/downloads/logstash/logstash-$version.tar.gz > /tmp/logstash-$version.tar.gz
cd /opt
cp /tmp/logstash-$version.tar.gz /opt
tar -zxvf logstash-$version.tar.gz
mv logstash-$version logstash
sudo chown -R $esu:$esg /opt/logstash

curl -k https://artifacts.elastic.co/downloads/kibana/kibana-$version-linux-x86_64.tar.gz > /tmp/kibana-$version-linux-x86_64.tar.gz
cd /opt
cp /tmp/kibana-$version-linux-x86_64.tar.gz /opt
tar -zxvf kibana-$version-linux-x86_64.tar.gz
mv kibana-$version-linux-x86_64 kibana
sudo chown -R $esu:$esg /opt/kibana

cat >/etc/systemd/system/elasticsearch.service <<EOL
[Unit]
Description=elasticsearch

[Service]
Type=simple
User=$esu
Group=$esg

ExecStart=/opt/elasticsearch/bin/elasticsearch
Restart=always
WorkingDirectory=/
Nice=19
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
EOL

cat >/opt/logstash/config/logstash-simple.conf   <<EOL
input { stdin { } }
output {
  elasticsearch { hosts => ["localhost:9200"] }
  stdout { codec => rubydebug }
}
EOL

cat >/etc/systemd/system/logstash.service <<EOL
[Unit]
Description=logstash

[Service]
Type=simple
User=$esu
Group=$esg

EnvironmentFile=/opt/logstash/config/startup.options
ExecStart=/opt/logstash/bin/logstash "-f" "/opt/logstash/config/logstash-simple.conf"
Restart=always
WorkingDirectory=/
Nice=19
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
EOL

cat >/etc/systemd/system/kibana.service <<EOL
[Unit]
Description=kibana

[Service]
Type=simple
User=$esu
Group=$esg

ExecStart=/opt/kibana/bin/kibana
Restart=always
WorkingDirectory=/
Nice=19
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
EOL

echo "The script has finished."
echo " "
echo "Try starting the services like this:
sudo systemctl start elasticsearch
sudo systemctl start logstash
sudo systemctl start kibana"

2.  Run the script above like this: sudo bash elasticstack.sh

How Do You Troubleshoot the PHP Syntax Error “unexpected end of file in …”?

Problem scenario
You receive this message "PHP Parse error:  syntax error, unexpected end of file in /path/to/file.php on line x."  How do you solve this?

Solution
Verify you have a closing brace for every open brace.  You may want to go to this site to help you find an unmatched brace.

How Do You Troubleshoot a “500 Error” with SonarQube?

Problem scenario
You try to run SonarScanner or do something with SonarQube.  You get a "500 Error" or some related internal server error.  What should you do?

Solution
Reinstall Java.  It is a dependency for SonarQube.  You can keep SonarQube installed and just stop the services while you uninstall and reinstall Java.  After you remove Java (and do research if you don't know how), you can use this posting if you need assistance on reinstalling Java.

If restinalling Java does not work, it is possible that you need a fresh database or you will need to reinstall SonarQube.

If you were using Jenkins and received a "500 Error", see this link.

How Do You Get an Ansible Playbook to Issue a Reboot of a Server and Wait for the Server to Come back?

Problem scenario
You know that the orchestrated installation of interconnected systems can have a significant benefit. Sometimes ordering the installation of packages on a single server can be useful. You do not want a "failed to connect to server" or "ansible ssh shared connection failed" message when you run a playbook.  You want the playbook run to wait for the server to boot up again.  The playbook reboots multiple servers at once.  What should you do?

Solution
1.  Change the ansible.cfg file to have this stanza underneath the [ssh] section:

ssh_args = -o ControlMaster=no -o ControlPersist=120s

2.  Use the "serial: 1" attribute above the "shell: sleep 3 && shutdown -r" command.  This way the servers reboot serially.  Ansible seems to perform more reliably when the managed nodes reboot this way.

# This solution was adapted from this posting.