How Do You Use Amazon Route 53 with a Domain Name?

Problem scenario
You have a web server with an external IP address (e.g., a VPS, an EC-2 instance, a DigitalOcean droplet, a VM in Azure or GCP).  You have a domain name, e.g., funexample.com, that you have registered.  You want to go to craft a URL foobar.funexample.com to resolve to this web server with an external IP address.  Right now when you open a web browser and go to foobar.funexample.com, nothing downloads.  You get a message about "Server not found" or "Page cannot be displayed."  In a web browser when you enter the external IP address of the web server, it resolves.  How do you up DNS to resolve your URL to your IP address with Amazon Route 53?

Solution
Prerequisites

1.  You have registered a domain name with AWS or transferred a domain name to Amazon (e.g., funexample.com).  (This costs money.)
2.  You have the external IP address of a web server (e.g., x.x.x.x) that you want to assign a domain name to (e.g., you want a URL with funexample.com to resolve to x.x.x.x).

Procedures
1.  Log into the AWS Console.
2.  Go here: https://console.aws.amazon.com/route53/home#hosted-zones:
3.  Check the option near the domain you want to configure (as there should be a circular button on the left)
4.  On the right there should be a button that says "Configure Query Logging"
5.  For the "New log group name" choose something like this (but replace "contint" with a phrase that will be meaningful to you): /aws/route53/contint
6.  Click "Create Log Group"
7.  For the option "CloudWatch Logs resource policy" choose the "Create a new resource policy in..."
8.  For the field "Resource policy name", enter one that will be meaningful to use (e.g., "route-53-query-logging").
9.  For the "Log groups that the resource policy applies to" enter something like this: /aws/route53/*
10.  Click "Create policy and test permissions" button
11.  Click the button in the lower righthand corner that says "Create query logging config"
12.  Click "Go to Record Sets" button
13.  Click "Create Record Set"
14.  Enter a value for Name.  The result will be something worth noting.  For example, if you enter "foobar" your website address will be foobar.funexample.com (assuming your domainname was funexample.com).
15.  Enter the IP address of your web server in the "Value" field.  (We recommend a private or "internal" IP address.)
16.  Click the "Create" button.
17.  You are now done.  AWS servers will be able to resolve the foobar.funexample.com URL almost immediately.  From an AWS Linux server, you can run a command like this: curl foobar.funexample.com > /tmp/good.html
Then examine /tmp/good.html to verify it is the page you want.

Web browsers on a Windows workstation will need time (e.g., 30 minutes or more) for your new URL, e.g., "foobar.funexample.com", to resolve.

What Does the “git rebase” Command Do?

Problem scenario
You are familiar with codebases in the context of configuration management or version control.   How can you invoke "git rebase" to learn more about git?

Solution
If you use the man page for "git rebase" you see this phrase to define "git rebase":  "Forward-port local commits to the updated upstream head"

What does "Forward-port local commits to the updated upstream head" mean?

According to Steve Bennett, it means "Sequentially regenerate a series of commits so they can be applied directly to the head node." 

The phrase "forward-port" means applying a change from one code base to another. (Do not confuse forward-port with TCP/IP ports.  The term port here is not a reference to TCP/IP.  In our experience however, this git usage of "forward-port" is very rare.)

The term "head" "is a reference to the last commit in the currently checked-out branch" according to this StackOverflow posting.  The "git rebase" command reapplies commits to another base of code according to this external website which has more detailed information about "git rebase".

How Do You Troubleshoot the Error “We are experiencing problems connecting to the Graylog server running on http://127.0.0.1:9000/api”?

Updated on 1/22/19

Problem scenario

You installed Graylog in a Docker container.  You open the URL for the server in a web browser.  You see this message:

" Server currently unavailable

We are experiencing problems connecting to the Graylog server running on http://127.0.0.1:9000/api. Please verify that the server is healthy and working correctly.

You will be automatically redirected to the previous page once we can connect to the server.

Do you need a hand? We can help you."

What should you do?

Solution
1.  Stop the Docker container with Graylog. 
2.  Remove this container. 
3.  Create a new Docker container but replace the 127.0.0.1 with the external IP address of the Linux Docker server (the Docker host).  The command should look like this (but replace x.x.x.x with the IP address of the Linux server):

docker run --link contint-mongo:mongo --link contint-elasticsearch:elasticsearch -p 9000:9000 -e GRAYLOG_WEB_ENDPOINT_URI="http://x.x.x.x:9000/api" -d graylog2/server

4.  If the command you drafted fails, you may need to run it with "sudo " at the beginning.  If you normally need to use sudo before Docker commands, you may want to try to configure your Docker host to not need that; if you need assistance with this, see this posting.

How Can a Bash Variable Be a String with a Multi-word Linux Command with a Space in It That Can Be Executed Independently and Correctly?

Problem scenario
You have a variable in a Bash script that helps you compose a new Bash command.  You want to create a complex and dynamic Bash command.  This variable includes one or more spaces in it.

You can echo the commands and verify that these are valid Linux commands.  You run them and they test out.  But to run automatically in a script, you are finding that it can be difficult.  What can be done to get the script to run successfully with having spaces in the commands?

Solution
Have the script create a new [disposable] script with the correct commands appended into it.  Have that disposable script be run.  That disposable script can then be deleted.

Here is an example of doing complex sed commands with /etc/ssh/sshd_config:

var1=65  # You could introduce logic to have a more dynamic line number assignment (e.g., grep -n)
var2=91  # You could introduce logic to have a more dynamic line number assignment (e.g., grep -n)

comm1="sed -i \""$var1"s/KererosAuthentication no/KerberosAuthentication yes/\" /etc/ssh/sshd_config"

echo $comm1 >> /tmp/intermediate.sh  # this will create a temporary script

comm2="sed -i \""$var2"s/X11UseLocalhost no/X11UseLocalhost yes/\" /etc/ssh/sshd_config"

echo $comm2 >> /tmp/intermediate.sh

bash /tmp/intermediate.sh
rm /tmp/intermediate.sh   # delete this temporary script

How Do You Troubleshoot the Message “error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory”?

Problem scenario
You are using a Red Hat derivative of Linux (e.g., CentOS/RHEL/Fedora).  When trying to run a MongoDB command you receive this message: "error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory"

What should you do?

Solution
Get different installation media.  If you try to install a .tgz file for Ubuntu on CentOS/RHEL/Fedora, you will get this message.  The solution is to get new installation media.

How Do You Troubleshoot the Python Error “NameError: name is not defined” When Using Boto3?

Problem scenario
You are running a Python program with Boto and you get an error like this:

  " aws_access_key_id=AKIAJfoobar9999, NameError: name 'AKIAfoobar9999' is not defined"

What should you do?

Solution
Put single quotes around the aws_access_key_id value.

What Does the “git branch” Command Do?

Problem scenario
You have seen "git branch" and heard of branching strategies.  What does "git branch" actually do?  How can you use "git branch"?

Solution
In the context of version control or configuration management, branching is a fork of a codebase. 
(Forking is the creation of an independent copy of a repository; a branch is the same except it is a copy of a repository within the same repository for the purpose of merging with the main or "trunk" branch. Forking usually involves publishing the repository. A branch will be available whereever its trunk is available. The repository may not be published.) A branch is a duplicate version of the Git repository that is created for testing, prototyping or developing. The "git branch" command allows you to list, create or delete branches of a Git repository.  To understand what a branch of a code base is, try this from inside a git repository:

git branch --list  # *

To create a branch, from inside a git repository, run a command such as this:

git branch fun4whatever  # *

To delete a branch, from inside a git repository, run a command such as this:

git branch -D fun4whatever # replace "fun4whatever" with the name of your git repository's branch.

*  To install git, run sudo apt-get -y install git for a Debian distribution or sudo yum -y install git for a RedHat distribution.

You may want to do this first if you do not have a git repository:

git clone https://github.com/ContinualIntegration/portfolio.git
cd portfolio

How Do You Install and Configure Grunt?

Problem scenario
You want to use Grunt the automation tool (https://gruntjs.com).  How do you install it and get it to work on Linux?

Solution
#1  If you are using CentOS, Red Hat Enterprise Linux, or Fedora, run these two commands:

sudo yum -y install nodejs npm  # *
sudo npm install -g grunt

If you are using Debian or Ubuntu Linux, run this command:  sudo apt-get -y install nodejs npm grunt  # *

* If you need assistance installing Node.js and npm on a different distribution of Linux, see this posting.

2.a. Run this commmand:  sudo npm init

2.b.  # Respond with whatever you think is best.  You can press enter to these nine prompts:

name: (jdoe)
version: (1.0.0)
description:
entry point:
test command:
git repository:
keywords:
author:
license:

2.c.  For the "Is this ok?" prompt, choose "yes".

3.  Run these three commands:
sudo npm install -g grunt-cli
sudo npm install grunt --save-dev
sudo npm install grunt-contrib-concat --save-dev

4.  Create a file called Gruntfile.js with this as the content (the top line starts with "module.exports..."):

module.exports = function(grunt) {
    //based on https://stackoverflow.com/questions/15703598/
    // Project configuration.
    grunt.initConfig({
        concat: {
            "options": { "separator": ";" },
            "build": {
                "src": ["js/contint1.js", "js/contint2.js"],
                "dest": "js/completeapp.js"
            }
        }
    });

    // Load required modules
    grunt.loadNpmTasks('grunt-contrib-concat');

    // Task definitions
    grunt.registerTask('default', ['concat']);
};

5.  Run the command: grunt

You should see this:

'Running "concat:build" (concat) task

Done.'

6.  You can use this command to see what version of Grunt is installed:  grunt -V

How Do You Install and Configure Gulp?

Problem scenario
You want to use Gulp the automation tool (https://gulpjs.com/).  How do you install it and get it to work on Linux (either a Debian distribution or a Red Hat distribution)?

Solution
1.  If you are using CentOS, Red Hat Enterprise Linux, or Fedora, run these two commands:

sudo yum -y install nodejs npm  # *
sudo npm install -g gulp

If you are using Debian or Ubuntu Linux, run this command:  sudo apt-get -y install nodejs npm gulp  # *

* If you need assistance installing Node.js and npm on a different distribution of Linux, see this posting.

2.a. Run this commmand:  sudo npm init

2.b.  # Respond with whatever you think is best.  You can press enter to these six prompts:

name: (jdoe)
version: (1.0.0)
git repository:
keywords:
author:
license:

2.c.  For the "Is this ok?" prompt, choose "yes".

3  Run this command:  sudo npm install --save-dev gulp

4.  Create a file called Gulpfile.js with this as the content (the top line starts with "var gulp..."):

var gulp = require('gulp');
gulp.task('default', function() {
  // place code for your default task here
});

5.  Run the command: gulp

You should see this:

[12:46:49] Using gulpfile ~/Gulpfile.js
[12:46:49] Starting 'default'...
[12:46:49] Finished 'default' after 125 µs

6.  You can use this command to see what version of Gulp is installed:  gulp -v