How Do You Set Up a Shared Drive or Folder Using Oracle VirtualBox?

Problem scenario:  You want to transfer files between a host machine running Oracle VirtualBox and a guest server.  By sharing media, your Oracle VirtualBox is much more useful.  How do you configure a folder to be shared between the host machine that runs Oracle VirtualBox and a virtual guest OS?   

Solution
These directions are for Oracle VirtualBox running on a Windows 7 Professional host with a guest virtual server running Linux, specifically CentOS 7.x.  If you want to have a USB stick be the shared drive, physically insert it into your Windows desktop now.  Create a folder on this USB stick.

1.  a)   Identify a folder on your Windows host machine that you want to be a share with your Linux guest VM.

b)  This step only needs to be performed one time.  You may be able to skip this step if it has been performed previously.  In Oracle VirtualBox open the CentOS VM.  Go to Devices -> Shared Folders -> Shared Folder Settings.  Click the folder icon with a green plus sign (to add a folder).

Then go to the "Folder Path" drop down then find the folder on the Windows server you want to add.  For folder name, enter whichever name you want.  For these directions we will call it "contint".  If you are actually following these directions and not just reading them, replace "contint" with the name you chose here.  Check the options for "Auto-mount" and "Make Permanent."  Click "Ok."

2.a.  On the Linux guest, run this command:  yum update kernel*
b.  Reboot the guest server.
c.  In Oracle VirtualBox Go to Devices -> Insert Guest Additions CD Image.  Unless you received an error, proceed to step #3.  If you get an error and failure do the following: verify VBoxGuestAdditions.iso is on your Windows host.  Then in Oracle VirtualBox go to Devices -> Optical Drives -> Choose disk image.  Then navigate to the VBoxGuestAdditions.iso file.

3.  This step only needs to be performed one time.  You may be able to skip this step if it has been performed previously.  On the Linux guest VM, run these five commands:

mkdir /media/VirtualBoxGuestAdditions
mount -r /dev/cdrom /media/VirtualBoxGuestAdditions
yum -y install bzip2 gcc make perl kernel-devel
KERN_DIR=/usr/src/kernels/`uname -r`
export KERN_DIR

If applicable, we find this message to be ignorable:
"Could not find the X.org or XFree86 Window System, skipping."

4.  Run these commands on the Linux guest VM:
mkdir /mnt/windows-share
mount -t vboxsf contint /mnt/windows-share  # where "contint" was the name chosen in step 1. b.

How Do You Install VirtualBox Guest Additions on a Linux Guest Server when the Files Are All Missing From the .iso?

Problem scenario:  You are trying to install Guest Additions on a Linux server.  You mount the CD/DVD/.iso through Oracle VirtualBox to /media/VirtualBoxGuestAdditions.  On the host virtual server the /media/VirtualBoxGuestAdditions (the directory where the CD/DVD/.iso was mounted) has no files.  You try to unmount the device and remount the device.  But you see no files. You are unable to run "./VBoxLinuxAdditions.run" because the file is not where it should be.  What do you do to solve this problem?

Solution
Reboot the Linux server.  Mount the device again (e.g., with a command like this "mount /dev/cdrom /media/VirtualBoxGuestAdditions").

How Do You Troubleshoot yum Command Failures with the Error “File /var/cache/yum/i386/7/epel/metalink.xml does not exist”?

Problem scenario:  yum commands are failing.  You get this error after running a yum command:  "File /var/cache/yum/i386/7/epel/metalink.xml does not exist"

Solution
Remove EPEL. Use this command: "yum remove epel-release"

How Do You Fix an Error “no repomd file” When Trying To Run a Yum Command?

Problem scenario:  You try to use yum commands.  You get an error about "no repomd file" and the desired yum command does not work.  What should you do?

Solution

If you are using Fedora Linux, run this command:

cat /etc/*-release

Look at the output of the above command to find the version of Fedora.  Verify you are using a recent version of Fedora (released within the past two years). View the "Release Schedule" of this link to find the year your version of Fedora was released.  If you are using a version that is a few years old, upgrade your Fedora version.

If you are using CentOS Linux, run this command:

yum update --disablerepo=epel\*

Then run your yum command(s).

How do you handle a “ENOMEM” error when trying to run a Chef command?

Problem scenario:  You recently installed Chef server on a Linux t2.micro instance (an AWS virtual server with 1 vCPU and 1 GB of RAM).  You ran this command "chef-server-ctl reconfigure" and received this error:

"Errno::ENOMEM occurred in delayed notification: runit_service[opscode-solr4] ( private-chef::opscode-solr4 line 37) had an error: Errno::ENOMEM: Cannot allocate memory - fork(2)"

What should you do?

Solution
Root cause:  A t2.micro instance has insufficient RAM.  You will need a server with more memory.
Try this command:  free -mh

The results of the above command will look something like this if there is enough memory:
  total        used        free      shared  buff/cache   available
Mem:           3.5G        1.1G        217M         68M        2.1G        2.0G
Swap:            0B          0B          0B

You need a server with at least 4 GB of RAM.   Chef's hardware requirements are 4 GB.  See this Chef document for more information.  To install a standalone Chef instance, follow these directions.  To add RAM to a VM click here for AWS resizing directions or here for GCP resizing directions.  For directions on adding or configuring virtual memory, see this posting.

Troubleshooting An Initial Run Chef Client

Problem scenario
When you are configuring a server to be a Chef client, you run this command:

/usr/bin/chef-client

But you get this error:

"Chef encountered an error attempting to create the client <hostnameOfChefClientServer>"

Solution

Verify you have a client.pem file in this directory on the server you are running the command on: /etc/chef/

The Chef documentation says this:
"Every request made by the chef-client to the Chef server must be an authenticated request using the Chef server API and a private key. When the chef-client makes a request to the Chef server, the chef-client authenticates each request using a private key located in /etc/chef/client.pem.

"However, during the first chef-client run, this private key does not exist. Instead, the chef-client will attempt to use the private key assigned to the chef-validator, located in /etc/chef/validation.pem. (If, for any reason, the chef-validator is unable to make an authenticated request to the Chef server, the initial chef-client run will fail.)

"During the initial chef-client run, the chef-client will register with the Chef server using the private key assigned to the chef-validator, after which the chef-client will obtain a client.pem private key for all future authentication requests to the Chef server."

Infrastructure as Code and Architecting Server Environments for Automatic Replication

Infrastructure as Code is often associated with "Continuous Configuration Automation."  We think the term should be "Continual Configuration Automation."

There are four popular tools to rapidly provision cloud infrastructure using templates: Azure Resource Manager, CloudFormation, Terraform, and Heat.  Three of these tools each support two different types of template files for provisioning servers.

  • Azure Resource Manager uses JSON exclusively (as our research indicates as of November of 2017).
  • CloudFormation can use JSON (CFN, aka CloudFormation, templates) or YAML to create virtual servers architected to work together.  For an article about moving away from JSON to YAML for AWS CloudFormation, see this link.
  • Hashicorp's Terraform can use JSON or HashiCorp Configuration Language.  See this link for more information.
  • Heat uses either JSON (CFN templates) or YAML (Heat Orchestration Templates).  For more information, see this link.

How Do You Redirect The Output of Lynx to a Regular File?

Problem scenario:  You are using Lynx and you want to redirect the downloaded web page to a file.  You do not want it to be sent to standard out (also referred to as printed to the screen).  What do you do?

Solution

You should use the "-dump" flag between the "lynx" utility word and the URL.  Then use the regular POSIX redirect symbol ">" at the end of the Linux command.  Here is an example:

lynx -dump https://www.continualintegration.com > /tmp/index.html

Please remember to use good discretion when using this capability.  Respect the intellectual property rights of others.

How Do You Get Lynx (in Linux) to Automatically Accept Cookies?

Problem scenario
You are using Lynx, and the prompt to accept cookies is tedious or disruptive to a non-interactive process you want to develop.  How do you get Lynx (running on Linux) to automatically accept cookies?

Answer
To configure Lynx to always accept cookies, do these steps:

1.  Find lynx.cfg with this command:  find / -name lynx.cfg

2.  Update lynx.cfg in three places:

a) Replace this stanza

#FORCE_SSL_COOKIES_SECURE:FALSE

with this stanza

FORCE_SSL_COOKIES_SECURE:TRUE

b) Replace this stanza

#SET_COOKIES:TRUE

With this stanza (just no leading comment):

SET_COOKIES:TRUE

c) Replace this stanza

# ACCEPT_ALL_COOKIES:FALSE

with this stanza:

ACCEPT_ALL_COOKIES:TRUE

d) Save the changes.  You are done.

A List of Books Related to Puppet (configuration management software)

Here is an alphabetized list of Puppet books. 

Beginning Puppet by Spencer Krum, William Van Hevelingen, Daniele Sluijters
DevOps: Puppet, Docker, and Kubernetes by Packt Publishing
Extending Puppet by Alessandro Franceschi
Instant Puppet 3 Starter by Jo Rhett
Learning MCollective: Parallel Server Management in Puppet and Chef by Jo Rhett
Learning Puppet by Bill Ward
Learning Puppet 2nd Edition by Jussi Heinonen
Learning Puppet 4: A Guide to Configuration Management and Automation by Jo Rhett
Learning Puppet for Windows Server by Fuat Ulugay
Learning Puppet Security by Jason Slagle
Mastering Puppet by Thomas Uphill
Mastering Puppet 5: Optimize enterprise-grade environment performance with Puppet by Packt Publishing
Pro Puppet 2nd Edition by Spencer Krum, William Van Hevelingen, Ben Kero, James Turnbull, and Jeffrey McCune
Puppet 2.7 Cookbook by John Arundel (This is more of a legacy book.  But it has good reviews and some enterprises do not upgrade very quickly.)
Puppet 3 Beginner's Guide by John Arundel
Puppet 3 Cookbook by John Arundel
Puppet 4 Essentials 2nd Edition by Felix Frank, Martin Alfke
Puppet 4.10 Beginner's Guide - Second Edition: From newbie to pro with Puppet 4.10 by Packt Publishing
Puppet 5 Beginner's Guide - Third Edition: Go from newbie to pro with Puppet 5 by Packt Publishing
Puppet 5 Cookbook: Jump start your Puppet 5.x deployment using engaging and practical recipes, 4th Edition by Packt Publishing
Puppet 5 Essentials - Third Edition: A fast-paced guide to automating your infrastructure by Packt Publishing
Puppet Beginner’s Guide 2nd Edition by John Arundel (This has not been released yet; the publication date is going to be in June of 2017.  It can be pre-ordered on Amazon.)
Puppet Best Practices: Design Patterns for Maintainable Code by Chris Barbour
Puppet Continuous Delivery by Bill Ward
Puppet Cookbook 3rd Edition by Thomas Uphill, John Arundel
Puppet Essentials by Felix Frank
Puppet for Containerization by Scott Coulton
Puppet Reporting and Monitoring by Michael Duffy
Pulling Strings with Puppet: Configuration Management Made Easy by James Turnbull
Puppet Types and Providers: Extending Puppet with Ruby by Dan Bode and Nan Liu
Troubleshooting Puppet by Thomas Uphill


For a great online guide to troubleshooting a Puppet manifest, click here.