How Do You Programmatically Search Hyperlinks on a Given Webpage?

Problem scenario
You have a web page that you access from the front-end (e.g., a web browser). You want to see if there is a hyperlink on the page that goes to a certain URL. You know the web page and the URL, but you are not sure if a hyperlink on the website has such a link. What should you do?

Solution
Use the curl command.

How Do You Troubleshoot the Puppet Error “file mode specification must be a string, not ‘Integer'”?

Problem scenario
You are running a manifest and you get this error:

Error: Failed to apply catalog: Parameter mode failed on File[/opt/hadoop/hadoop-2.2.0.tar.gz]: The file mode specification must be a string, not ‘Integer’ at /etc/puppetlabs/code/environments/production/modules/hadoop/manifests/init.pp:55

What is wrong?

Solution
Go to the Puppet Master server and open the file in the error. (The error provides the full directory path.) Go to the line number that the error message specifies.

How Do You Create a Puppet Manifest to Install Java?

Problem scenario
You have Puppet agent and Puppet Master set up and configured to work together. You are are running open source Puppet 5.x on Ubuntu servers in AWS. You want to install Java on the Puppet agent nodes. You tried to use the Java module.

On the Puppet Master server, you ran this: puppet module install puppetlabs-java –version 2.2.0

This is your site.pp file:

class { ‘java’ :
package =’java-1.8.0-openjdk-devel’, …

How Do You Troubleshoot Puppet Agent with a “Failed to open TCP connection…connection refused port 8140” error?

Problem scenario
You run puppet agent but you get this error:

Error: Could not request certificate: Failed to open TCP connection to puppetmaster.domain.com:8140 (Connection refused – connect(2) for “puppetmaster.domain.com” port 8140)

What do you do?

Solution
Ensure port 8140 is open. Install nmap on a server, and run this command:

nmap -p 8140 puppetmaster.domain.com

If you see this

PORT STATE SERVICE
8140/tcp closed unknown

Then the Puppet Master service is not running.

How Do You Troubleshoot the Puppet Problem “Error 500 on SERVER: … Could not find node statement with name ‘default’ or “?

Problem scenario
You run the Puppet agent on a server but you receive this error:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Could not find node statement with name ‘default’ or ‘ip-172-31-20-105.us-east-2.compute.internal, ip-172-31-20-105.us-east-2.compute, ip-172-31-20-105.us-east-2, ip-172-31-20-105’ on node ip-172-31-20-105.us-east-2.compute.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

What should you do?

How Do You Send an Email via a Postfix Server on Linux with the Command Prompt That Has Multiple Recipients and a Subject?

Problem scenario
You want to send one email to multiple people. You tried separating the email addresses with a comma or semicolon but you received this message: “555 5.5.4 Unsupported option:”

You do not know how to send an email with a subject via the Postfix command prompt. How do you send an email to multiple people with “Re:” content of your choice?

Solution
Prerequisite
You need to have Postfix installed and configured.

How Do You Print out Lines of a File One-by-One with No Commas and No Semicolons from a Linux Shell?

Problem scenario
You have a flat file that may have lines that terminate (or end) with semicolons or commas. You want to print one line of this file at a time without commas or semicolons. How do you do this with Linux?

Prerequisite
You have a file named “list” (with no extension) in the same directory as this script below.

Solution
Run this Bash script:

while read list; …

How Do You Automate a telnet Session to Send a Postfix Email on a Linux Server?

Problem scenario
You want to create a script that will send an email from a Linux server. You want it to use telnet. How do you automatically send an email using telnet?

Solution
Prerequisite
Set up Postfix. If you are running SUSE, see this posting. If you are running a RedHat derivative, see this posting.