Why Cannot You List Every Repository in Your GitHub Organization’s Account?

Problem scenario
You are trying to list the repositories in your GitHub organization with the REST API. You run something like this:

curl -u $username:$password https://api.github.com/orgs/$ORGNAME/repos

But as you add repositories, all are not showing. What is wrong?

Possible solution
Do you have more than 30 repositories? The output of the curl (GET REST) invocation can be the same as you add repositories if you exceed 30. You can change the limit to 100. See this posting for details.

How Do You Remove the ECDSA Fingerprints of Old Servers That You Will Not Connect to Again?

Problem scenario
You have a server that has run SSH to connect to other servers. You want to remove the fingerprints so the ECDSA key fingerprint will challenge a user to continue connecting. What do you do?

Solution
Run this command where x.x.x.x is the IP address or hostname of the server whose finger print should be removed: ssh-keygen -R x.x.x.x

If you used a hostname with the SSH comands, use a hostname in the command above. If you used an IP address with the SSH commands, use the IP address in the command above.

How Do You Create an Issue for a Repository in a GitHub Organization the API?

Problem scenario
You are running this command:

curl -u jdoe:$password -X PUT -d '{"title": "Look at this bug", "body": "This is a serious problem here.", "assignees": [ "jdoe" ], "milestone": 1, "labels": [ "bug" ]}' https://api.github.com/repos/$orgname/$reponame/issues

The message in the response you receive is "Not Found". You found documentation that refers to an "owner" being in the URL. You see "POST /repos/:owner/:repo/issues" (with no reference to the organization). (This was taken from https://developer.github.com/v3/issues/#create-an-issue .)

What should you do to create a GitHub issue with the REST API?

Solution
1. Modify the command.
1.a. Use "POST" instead of "PUT".
1.b. Eliminate the '"milestone": 1,'
1.c. It should look like this:

curl -u jdoe:$password -X POST -d '{"title": "Look at this bug", "body": "This is a serious problem here.", "assignees": [ "jdoe" ], "labels": [ "bug" ]}' https://api.github.com/repos/$orgname/$reponame/issues

2. Run the command after you change the word "jdoe" to the username and the "password" to your GitHub.com password.

How Do You Read in User Input with Golang?

Problem scenario
You want to read in user input with Golang. What should you do?

Solution
This program will illustrate how you accept user input with a Golang program:

package main

import (
  "bufio"
  "fmt"
  "os"
)

func main() {
fmt.Println("Please enter some text:")
reader := bufio.NewReader(os.Stdin)
text, _ := reader.ReadString('\n')
fmt.Println("The text you entered was this: ", text)
}

How Do You Write an Ansible Playbook to Install a Yum Package?

Problem scenario
How do you use the yum module in an Ansible playbook to install a yum package?

Solution
Prerequisites
This assumes you have installed Ansible and configured a managed node to work with it. If you need assistance with this, see this posting.

Procedures
1. On the Ansible control server, create this .yaml file (e.g., called good.yaml):

- hosts: all
  tasks:
  - name: Install Apache web server and nmap
    yum:
      name: "{{ packages }}"
    vars:
      packages:
        - httpd
        - nmap
    become: yes

2. Run this: ansible-playbook good.yaml

How Do You Create a GCP VM to Be a Web Server?

Problem scenario
You have a GCP server. You can run curl commands to its URL via localhost. But with a URL constructed with the server's external IP address the curl command times out. You cannot reach the URL from your workstation. How do you get the GCP server to present the web service to other machines?

Solution
Modify the firewall rule by following these steps below.
1. Go to the VM's details (go to the hamburger icon in the upper righthand corner, then go to VM Instances and click on the VM).
2. Look for the "Network tags". You will find something like "http-server" or "https-server". Make a mental note of one of them.
3. Go to the hamburger icon in the upper righthand corner, go to VPC Network -> Firewall Rules.
4. Click "CREATE FIREWALL RULE".
5. Enter a relevant port in "Protocols and ports" (e.g., 8080 or just 80) and a relevant IP Range in "Source filters" (e.g., 0.0.0.0/0 if it is not sensitive).
6. Click "Save".

How Do You Install Firefox on a Windows Server with PowerShell?

Problem scenario
You want to install Firefox on a Windows server without using the traditional GUI method. What should you do?

Solution
Updated on 5/16/21
1. Open PowerShell ISE as Administrator (right click it, go to More -> Run as Administrator).
2. Run this script (e.g., firefox.ps1):

# This script was mostly taken from https://forum.pulseway.com/topic/1940-install-firefox-with-powershell/

# www.continualintegration.com changed the version number of Firefox and added some comments
# Silent Install Firefox 

# Download URL: https://www.mozilla.org/en-US/firefox/all/

# Path for the workdir
$workdir = "c:\installer\"

# Check if work directory exists if not create it

If (Test-Path -Path $workdir -PathType Container)
{ Write-Host "$workdir already exists" -ForegroundColor Red}
ELSE
{ New-Item -Path $workdir  -ItemType directory }

# Download the installer

$source = "https://download.mozilla.org/?product=firefox-88.0.1-SSL&os=win64&lang=en-US"
$destination = "$workdir\firefox.exe"

# Check if Invoke-Webrequest exists otherwise execute WebClient

if (Get-Command 'Invoke-Webrequest')
{
     Invoke-WebRequest $source -OutFile $destination
}
else
{
    $WebClient = New-Object System.Net.WebClient
    $webclient.DownloadFile($source, $destination)
}

# Start the installation

Start-Process -FilePath "$workdir\firefox.exe" -ArgumentList "/S"

# Wait XX Seconds for the installation to finish

Start-Sleep -s 35

# Remove the installer

rm -Force $workdir\firefox*

# write-host should be changed to write-verbose  # we have not tried it yet with these directions
# https://devblogs.microsoft.com/scripting/understanding-streams-redirection-and-write-host-in-powershell/

How Do You Set the S3 Policy to Archive after 60 Days?

Problem scenario
You want items in an S3 bucket to be archived automatically after they are 60 days old. What do you do?

Solution
1. Log into the AWS console.
2. Click on your S3 bucket.
3. Click on the "Management" tab on the right.
4. Click on "Add lifecycle rule"
5. Give the rule a name. Click "Next."
6. Check the box for "Current version" or "Previous versions." Then below the "For current version of objects" click "+ Add transition"
7. Choose the transition policy you want (e.g., "Transition to Amazon Glacier after").
8. For the "Days after object creation" type 60. Click Next.
9. For configure expiration, just click "Next."
10. On the Review page, click "Save."

How Do You Delete an Aurora Database when You Get an Error about It Not Being Started?

Problem scenario
You are trying to delete an Aurora database but you get this error: "This database is not started." What do you do?

Possible Solution #1 (with the web console)
1. Log into the web console.
2. Go to "Amazon RDS".
3. Go to "Databases"
4. Click on the Aurora cluster of the database you want to delete or its parent.
5. Go to Actions -> Start
6. If it is grayed out, it may be stopping. It can take several minutes to fully stop.
7. Then go to Actions -> Delete. Respond to the next prompt.

Possible Solution #2 (with the AWS CLI)
From the AWS CLI, run these two commands (but replace "foobar" with the database name that you want to delete):

aws rds start-db-instance --db-instance-identifier foobar
# You may have to wait 10 minutes or more for the database to start
aws rds delete-db-instance --db-instance-identifier foobar

How Do You Find the Default Directory for Tomcat when It Acts as a Web Server?

Problem scenario
Your Tomcat server is has been configured to serve as a web server. You have access to the back-end Linux server. But you do not know what directory corresponds with the URL of the host. How do you find what the default directory is for files that are presented on the web?

Solution
From the back-end, run this: sudo find / -name index.html | grep tomcat

Look for a WEB-INF or webapps directory. See if there are subdirectories after one of these directories until the index.html file (e.g., /var/lib/tomcat9/webapps/foo/index.html ).