How Do You Find If Chef Server or If Chef Client Is Installed on a Linux server?

Question:  How Do You Find If Chef Server Is Installed on a Linux server?

Answer
Run this command:  which chef-server-ctl

If Chef server is installed, the result of the above command will display the location of the Chef binary file.  If Chef server is not installed, the word "no" will be in the results.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Question:  How Do You Find Out If Chef Client Is Installed on a Linux server? 

Answer
Run this command:  chef-client -v

If the response is "command not found" chef-client is not installed.  If chef-client is installed, the above command will result in a display of the version of chef-client.

Continuous Integration vs. Continual Integration

Historically the term "continuous integration" has been the norm in the world of technology.  In this article, Amazon defines it.  As of two days ago, Amazon posted an article using the term "continual integration."  This website helps promote the grammatically correct "continual integration."

What Are OPT Resumes?

Problem scenario:  A recruiter warns that he/she will not accept OPT resumes for a specific solution.  What are OPT resumes?

Solution:  OPT stands for Optional Practical Training.  OPT employment authorization last for 12 months and is related to academic training in the U.S.  To learn more, see this link.  If you are a U.S. citizen like the author of this blog, it is probably of no concern to you (unless you are getting into recruiting or hiring).  A U.S. citizen's resume is not an "OPT."

How Do You Get the Puppet Master Service to Run for The First Time?

Problem scenario
Your newly installed Puppet Master is not working.  The main service will not start.  You try this command:  service puppetserver restart

You see this as the results of the above command:
"Job for puppetserver.service failed because the control process exited with error code. See "systemctl status puppetserver.service" and "journalctl -xe" for details."

You then try this command to see what is wrong (per the error message above):
systemctl status puppetserver.service

It results in this:

? puppetserver.service - LSB: puppetserver
   Loaded: loaded (/etc/init.d/puppetserver; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2017-01-12 19:17:18 EST; 22s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 6434 ExecStart=/etc/init.d/puppetserver start (code=exited, status=1/

How do you fix this problem?

Solution
It is recommended that you have 6 GB of memory for Puppet Enterprise.  For testing purposes the Puppet Master service will run with less than 1 GB. Modify this file /etc/default/puppetserver.

Find this line in /etc/default/puppetserver:

JAVA_ARGS="-Xms2g -Xmx2g -XX:MaxPermSize=256m"

Change it to this (where 256 is the number of MB your server has*):

JAVA_ARGS="-Xms900m -Xmx900m -XX:MaxPermSize=256m"

* Use this command: free -m
In the results of free -m, the value under "total" for "Mem:" is the value of "x" you should use for this computation: 
y = x * .9
The resulting value of y (based on this formula) should be in the JAVA_ARGS statement in the file /etc/default/puppetserver in a certain way:  Replace the "2" in both instances of "Xms2g" (as shown above) with the value of y.  Replace the "g" in these two strings with the letter m.  (The "g" is for gigabytes and the "m" is for megabytes.)  This example involving changing "g" to "m" assumes you have only 1 GB of RAM on the server.  In some instances your JAVA_ARGS stanza in the /etc/default/puppetserver file would have a "g" and not an "m".

If you need assistance adding virtual memory (aka swap space), see this posting.  If you want to upgrade your AWS EC-2 instance, see this posting.  If you want to resize your GCP virtual machine (aka server in Google Cloud), see this posting.

How Do You Solve The Problem When Puppet Agent Returns an Error About “require_relative for main:Object”?

Problem scenario:  On a Linux server you run "puppet agent -t" to apply a manifest on a Puppet Agent.  You receive this error:

"Error: Could not retrieve local facts: undefined method 'require_relative' for main:Object"

What do you do to fix this?

Solution:  Install a compatible version of Puppet agent on the server.  One way to do this is to run this command:

curl -k https://continualintegration:8140/packages/current/install.bash | sudo bash`

#where "continualintegration" is the hostname (or FQDN) of the Puppet Master server.

This way is preferred because the Puppet Agent server gets the installation media from the Puppet Master itself.

How Do You Troubleshoot the Yum Error “[Errno 14] Peer cert cannot be verified or peer cert invalid. Trying other mirror…”?

Problem scenario:  You are running a yum command and get this error:
"[Errno 14]  Peer cert cannot be verified or peer cert invalid.  Trying other mirror..."

Possible Solutions
The SSL certificate is not being verified.  One solution would be to ensure the Linux server you are running the yum command on has the correct SSL cert. 

Another solution would be to modify the /etc/yum.conf file.  Add this entry as the lowest stanza in the [main] section:  sslverify=false

This second solution (immediately above) is not a best practice.  But behind a firewall that blocks Internet access, it is a configuration that some Linux administrators use without too much risk.  Use it with caution if your environment does not have an intrusion detection system and firewall because you do not want to apply Linux patches from an unverified source.  It is inadvisable to use this "sslverify=false" stanza on an important server that has access to the Internet.  This setting on /etc/yum.conf applies to all repos on the server.  The default setting, when this stanza is omitted, on modern RedHat versions has the equivalent effect of having a "sslverify=true" stanza.  The .repo files in /etc/yum.repos.d/ can be granularly managed.  To set a .repo file to false, use this similar stanza with no quotes: "sslverify=0".

How Do You Ensure That a PowerShell Pop-Up Window (mini-GUI) Always Appears in the Front?

Problem scenario:
You have a PowerShell script that launches a pop-up window.  This pop-up appears behind the PowerShell ISE GUI.  Without being in the foreground, the users of this script fail to realize there is a prompt waiting for the user to take action.  You want the pop-up window to be in the front.  You tried things like these options to no avail:

  • New-Object System.Windows.Forms.Form -Property @{TopMost = $true}
  • -ArgumentList([System.Diagnostics.Process]::GetCurrentProcess().MainWindowHandle)
  • form.TopMost = "True"
  • form.TopMost = $true
  • form.TopMost = $True
  • $form.TopLevel = $true
  • set-foregroundWindow(Get-Process PowerShell).Main.WindowHandle
  • $form.BringToFront()
  • set-WindowsFocus
  • [void]$showWindowAsync::ShowWindowAsync((Get-Process -id $pid).MainWindowHandle, 2)  #hide GUI
    [void]$showWindowAsync::ShowWindowAsync((Get-Process -id $pid).MainWindowHandle, 10)  # GUI returns

You could use a form (not a PowerShell Window) with PowerShell code and no special Vexasoft solution, and the above may be unsuccessful in reliably (or ever) making the pop-up window appear in front of the PowerShell ISE application.  Users waste time not knowing that the program is waiting on them. 

The last bullet's two lines of PowerShell code were taken from this external link.  In some instances, the above options will not work reliably.  When the PowerShell window is not minimized there may also be an error about calling a method on a null-valued expression.  When a pop-up is hidden behind the PowerShell window, the interactive experience is delayed unnecessarily.

What should you do so the pop-up GUI is clearly visible (as interactive scripts can stall until options are selected or input is provided)?

Solution 
Minimize the PowerShell ISE application via the follow PowerShell code (where "start-sleep 5" is the line that launches the pop-up):

$shell = New-Object -ComObject "Shell.Application"
$shell.minimizeall()
start-sleep 5  # This is where the pop-up would be called.  It is just a placeholder.
$shell = New-Object -ComObject "Shell.Application"
$shell.undominimizeall()

Every line but the middle line in the above five lines of code were taken from this external website.

How Do You Get a Script with Yum Commands That Rely on a Public Website to Work when you have No Access to the Internet?

Problem scenario
You have a Bash script that cannot be modified that runs yum commands.  The script runs on a RedHat distribution of Linux and uses URLs with SSL (e.g., https://continualintegration.com).  The script expects a yum repository to be set up at this URL.  This script must run without access to the Internet due to enterprise security policies.  What do you do if you are behind enough security to not need SSL to be set up properly (given that you have no Internet access) and need to get the script to work immediately?

Solution
Mirror the URL resources on a server internally, and intentionally "spoof" the IP address to point DNS records for the URL to that internal yum server. 

1.  Go to the server that will run the script and change the /etc/hosts file so the FQDN of the URL will map to the IP address of the internal server.  For example, the /etc/hosts file of the server that will run the script should have an entry like this (assuming the script refers to https://continualintegration.com and the internal server that will serve as https://continualintegration.com is at 123.123.123.123):

123.123.123.123                             continualintegration.com

The steps will keep referring to 123.123.123.123 as the IP address of your internal yum repository server.

2.  Go to the yum repository server at 123.123.123.123.  Install Apache httpd server on this server.  Modify the httpd.conf file (find it with this command "find / -name httpd.conf").  Search for the word "DocumentRoot" in httpd.conf to change instances of the default "/var/www/html" path to the path of the .rpms. 

3.  Transfer the .rpms from the server on the Internet to the yum repository server at 123.123.123.123.  The destination directory should be the one you configured in the step above.   Start the Apache server (e.g., "apachectl start").

4.  Install createrepo on the 123.123.123.123 server if it has not been installed.  Use this command to configure the directory with .rpms to be a yum repository:  createrepo /path/to/rpms/
The above command will create a "repodata" directory in the directory you specified.  The command will also create a repomd.xml file in that "repodata" subdirectory.  These things allow the yum repository to work.

5.  Set up SSL on this yum repository server at 123.123.123.123.  Use this command:  yum install mod_ssl
For further configuration details of SSL, see this link.  

6.  On the server that will run the script, modify the /etc/yum.conf file.  Add this entry as the lowest stanza in the [main] section:  sslverify=false
(This is not a best practice.  But behind a firewall that blocks Internet access, it is a configuration that some Linux administrators use without too much risk.)

7.  Now you should be able to run the script.  The resolution of the FQDN of the URL should be to this new yum repository on your server.  The script will never know it did not use the real server on the Internet.

For more information about configuring yum clients see this external link.  It has details about retrieving RPMs for specific sources with SSL.

Software Firewall and Anti-Virus Program

Looking for a downloadable anti-virus or anti-spyware solution on Amazon?  You will not find this on Amazon: The latest Lavasoft Ad-Aware Total Security is an all-in-one solution for Windows computers.  Ad-Aware Total Security has a great OS firewall and strong anti-spyware capabilities. Its virus database and scanning technology provides great all-around protection.  To learn more about this under-rated security solution for Windows computers or to buy it, click on this link.

How Do You Solve The “No route to host” Error When You Try To Use The wget Command?

Problem scenario
You can ping a web server, but you cannot use the "wget https://www.continualintegration.com" command (with no quotes and where www.continualintegration.com is the URL or IP address of the web server).  You get the error result "No route to host."  How do you use wget to retrieve the files on the web server?

Solution
Try one of these four diagnostic methods to isolate the problem:

  1. Verify the firewall is not blocking web requests on the Apache server.  Use "ps -ef | grep firewalld" with no quotes to see if it is running.  If it is running, and you are in a situation where you can afford to turn it off, turn it off with "service firewalld stop" or "systemctl stop firewalld". 
  2. See if there is an intermediate proxy server or firewall between the two servers.  Use traceroute or some other network tool. 
  3. Use nmap -p 80 x.x.x.x (where x.x.x.x is the IP address of the Apache server). 
  4. Use "route -n" on the requesting server (the one you were issuing the wget command from).  The results will let you see if there is a default gateway, a subnet mask, and an IP address on your server.  If you are not receiving these, the problem should probably be solved by reconfiguring the network interface card correctly.