How Do I Create a Manifest with Puppet Enterprise to be run on a server other than the Puppet Master server itself?

Question: How Do I Create a Manifest with Puppet Enterprise to be run on a server other than the Puppet Master server itself?

Assumption:  Puppet Master is installed on a Linux server.

Answer:  Manifests are .pp files.  The Puppet syntax (with its domain specific language) is beyond the scope of this posting.  This post is to get you started. Go to the directory where the modules are on the Puppet Master server.  Use this command if you are unsure: find / -name modules

Throughout these directions substitute "continualintegration" with the module name of your choice.

Run this command: puppet module generate jdoe-continualintegration

# The username "jdoe" and hyphen are optional.  Naturally you would use your own username or your first name. Puppet recommends this convention

Accept the defaults to the subsequent prompts.

Then issue these two Linux commands:

cd continualintegration
cd manifests

Modify init.pp to be the new manifest. Save the changes.

Go to the Puppet Enterprise Console (sometimes referred to as the Puppet Management GUI or Puppet Dashboard) by opening a web browser and going to https://x.x.x.x where x.x.x.x is the IP address of the Puppet Master server.

Log in.

Go to Classification -> Facter -> Add New Class

In this field, type "continualintegration".  As you type you should see a suggestion appear below.  Click on it.  Click "Add Class."  In the lower right hand corner, find the "Commit 1 change" button.  Click this button.

Now when Puppet Agent runs on the client, the configuration should be pushed down.  For Windows Servers, Puppet Agent may need to be ran as administrator.  To clarify you may need to open PowerShell as administrator and run with this command: puppet -t puppet.continualintegration.com -d # where puppet.continualintegration.com is the FQDN of the Puppet Master server in your network.

How do I get a forward slash (“/”) to be passed from a Puppet manifest on a Linux server with Puppet Master to a Windows server with Puppet Agent?

Question:  How do I get a forward slash ("/") to be passed from a Puppet manifest on a Linux server with Puppet Master to a Windows Server with Puppet Agent?

Answer # 1 (for creating Scheduled Tasks with Puppet manifests): For a Scheduled Task, the forward slash may be crucial.  A forward slash (that Puppet between Linux and Windows will automatically substitute for a back slash) with a shutdown.exe server is the only way for a reboot to work properly with a Scheduled Task.  In a Puppet manifest (.pp file), declare a Scheduled_Task resource (where the link used to be here https://docs.puppet.com/puppet/latest/reference/types/scheduled_task.html).  This is a built-in resource type for Puppet.

While this solution does not give you a forward slash in the end result, it will give you a solution by having an "argument."  The "arguments =>" property will allow you to place an "\r" in the "Add arguments" field in the "Edit Action" window found by clicking "Edit" in the "Actions" tab of the Scheduled Task.  When you manually create a Scheduled Task, the "...shutdown.exe /r ..." can all appear the "Program/script" field together.  A backslash before the "r" in the "Program/script" field will not allow you to reboot the server. But a backslash before the "r" in the "Add arguments" field will allow you to reboot the server.

Answer #2 (for passing a "/" to in a PowerShell command):  Use the [char]47 command in PowerShell to get a variable with a forward slash "/".   PowerShell commands can be compound with semi colons ";" separating distinct lines.  Therefore something like this will work (with assigning [char]47 to a variable and concatenating strings to ultimately call everything with the invoke-expression command:

command => '$fslash = [char]47; $construct = "schtasks " + $fslash + "create " + $fslash + "sc monthly " + $fslash + "tn continualIntegration " + $fslash + "tr c:\windows\system32\fun.exe "  + $fslash + "sd 09/08/2016"; invoke-expression $construct'

Answer #3 (transfer a file via a manifest):  A manifest can have a resource definition like this:
file { "c:\temp\special.ps1":
          source => puppet:/// /special.ps1
   }

# special.ps1 can have forward slashes in it. 
# This file would have to be in /etc/puppetlabs/code/environments/development/modules/foobar/files/
# Note that "files" (the subdirectory holding the file) is omitted from the source declaration in the manifest. 

This method could involve an exec resource definition with a command call.   This way you could run a PowerShell command with a forward slash.  Other files (with forward slashes) besides those with .ps1 extensions could similarly be transferred to a Windows server.

Answer #4  (use the provider key word):  A manifest with a resource definition of command can have a provider declaration too.  A manifest written like this will actually work:

command => '$construct = "schtasks /create /sc monthly /tn continualIntegration /tr c:\windows\system32\fun.exe /sd 09/08/2016"; invoke-expression $construct',
provider => 'powershell',

How Do You Find if MongoDB is Installed on Linux?

Problem scenario:  You are not sure if MongoDB is installed on Linux.  How do you find out for sure?

Solution:  Use this command to see if it is actively running:  ps -ef | grep mongo
However, MongoDB could be installed but not running.  So this command will not definitively answer the question.  On Debian (e.g., Ubuntu) or RedHat (e.g., CentOS or Fedora) distributions of Linux, use this command: mongod --version
The results will indicate if MongoDB is installed or not.  You'll see the version if it is installed.  The command will not work if MongoDB is not installed (e.g., with command not found).

Cloud Computing Is Changing the Global Economy

The Economist, specifically the August 27th - September 2nd 2016 issue, on page 47 and 48, in the article "Linux and AWS," reports four fascinating facts:

1) The world's I.T. budget is approximately $3,400,000,000,000 (almost 3.5 trillion) dollars.   
2) As of mid-2016, Google's market share for cloud services increased 162% from the previous year!  
3) Roughly 65% of the over one million AWS customers are startups.
4) AWS has computing capacity that is ten times greater than its closest 14 competitors combined! (As of early September 2016.)

Update as of February 2021: If you combine IaaS and PaaS, AWS accounts for 32% of the market according to this website.

Update in early 2022: Worldwide spending on I.T. is predicted to be $4.5 trillion dollars for 2022 (according to Gartner). To put that in perspective, the GDP of the U.S. was estimated to be roughly $23 trillion dollars in 2021 (according to the Bureau of Economic Analysis).

How Do You Unzip Files Using Ubuntu (Using the Command Line Interface)?

Goal:  You want to use unzip with Ubuntu Linux without using the GUI desktop.
Background:  The unzip character-based utility is useful for many reasons.  At the command line you can access compressed files that normally occupy little space on the disk.  Transferring .zip files is great for keeping network bandwidth utilization low.

Try this command to see if unzip is installed: man unzip

Part 1:  Installing Unzip
If the command cannot be found, use this command:  sudo apt-get install unzip

If the above command does not work, (for example, you do not have access to the Internet, and your network has no Debian package repositories configured), get the file from here:  https://packages.debian.org/wheezy/unzip

To find the correct installation media (and choose the correct link from the website above), you need to determine the architecture.  To do this, use this command: dpkg --print-architecture

Once you get the correct file on to Ubuntu, install it with this command: dpkg -i unzip.*.deb

Part 2:  Using Unzip
Now that unzip is installed, you can use it with a command like this (assuming you have a file named foobar.zip):

unzip foobar.zip

The above command will decompress the contents while retaining a copy.  The extracted contents will be decompressed in the same directory you run the command in.  The extracted files will not go to the directory where foobar.zip is if you use the path of foobar.zip in the invocation of the unzip command (e.g., if you are in /root/ and run unzip /tmp/foobar.zip the extracted files will go into the /root/ directory).

How Do You Zip Files Using Ubuntu Linux From The Command Line Interface?

Goal:  You want to use zip with Ubuntu Linux without using the GUI.  You want to use the character prompt exclusively.

Background:  The zip character-based utility is useful for many reasons.  At the command line you can free up space while retaining files for future usage.  Try this command to see if zip is installed: man zip

Try this command to see if zip is installed: man zip

Part 1: Installing Zip
If the command cannot be found, use this command:

sudo apt-get install zip

If you do not have access to the Internet, and your network has no Debian package repositories configured, get the file from here:  https://packages.debian.org/wheezy/zip

To find the correct installation media (and choose the correct link from the website above), you need to determine the architecture.  To do this, use this command: dpkg --print-architecture

Once you get the file over, install it with this command: dpkg -i zip.*.deb

Part 2  How to Use Zip
Now that zip is installed, you can use it with a command like this (assuming you have three regular files named pub.txt, pub1.txt, pub2.txt):

zip target.zip pub.txt pub1.txt pub2.txt

The above command will create a zip file called target.zip.  The files will be compressed (that is, the .zip file will be smaller than the sum of the three .txt files' sizes).  This can help reduce disk I/O when fetching the file, moving it around, and reduce network congestion with fewer packets over the network when it is in transit.

How do you unzip files using SUSE?

Goal  You want to use unzip when you are using SUSE (either openSUSE or SUSE Linux Enterprise).

Background
The unzip character-based utility is useful for many reasons.  At the command line you can access compressed files that normally occupy little space on the disk.  Transferring .zip files is great for keeping network bandwidth utilization low.

Try this command to see if unzip is installed: unzip --version
AWS SUSE servers have unzip installed by default, but they have no man pages.

Part 1:  Installing Unzip
If the command cannot be found, use these commands:

sudo su -
zypper install unzip

If the above command does not work, (for example, you do not have access to the Internet, and your network has no Debian package repositories configured), go here to get a file:

http://software.opensuse.org/download.html?project=Archiving&package=unzip

To find the correct installation media (and choose the correct link from the website above), you need to determine the architecture.  To do this, use this command: cat /etc/*-release

The above command will tell you if you are using SUSE Linux Enterprise or openSUSE.  The buttons can be right clicked to copy the location (e.g., to use wget http://software.opensuse.org/ymp/Archiving/SLE_12_SP1/zip.ymp).  Otherwise you click "Grab binary packages directly" and then download the appropriate file to your workstation and transfer it over to the Linux machine (e.g., with SFTP or SCP).

Once you get the file over, install it with this command: zypper install /path/to/unzip.rpm

Part 2:  How to Use Unzip
Now that unzip is installed, you can use it with a command like this (assuming you have a file named foobar.zip):

unzip foobar.zip

The above command will decompress the contents while retaining a copy.  The extracted contents will be decompressed in the same directory you run the command in.  The files will not necessarily go to the directory where foobar.zip is (e.g., if you are in /root/ and run unzip /tmp/foobar.zip the extracted files will go into the /root/ directory).

How do you zip files using SUSE Linux?

Goal:  You want to use zip when you are using SUSE (openSUSE or SUSE Linux Enterprise).  You want to use the character (or command) prompt.  You do not want to use the GUI.
Background:  The zip character-based utility is useful for many reasons.  At the command line you can free up space while retaining files for future usage.  Try this command to see if zip is installed: man zip

Part 1 Installation Process
If the command cannot be found, use these commands:

sudo su -
zypper install -y zip

If you do not have access to the Internet (so a .ymp file could not help you), and your network has no .rpm package repositories configured, get the file from here:

http://software.opensuse.org/download.html?project=Archiving&package=zip

If you are using a free SUSE Linux with AWS, then your version is SLE (not openSUSE).  To find the exact version of SUSE you are using, issue this command: cat /etc/*-release
AWS SUSE servers have zip installed by default.

The buttons can be right clicked to copy the location (e.g., to use wget http://software.opensuse.org/ymp/Archiving/SLE_12_SP1/zip.ymp).  But .ymp files are only useful if your server has Internet access.  You click "Grab binary packages directly" and then download the appropriate file to your workstation and transfer it over to the Linux machine (e.g., with SFTP or SCP).    

Once you get the file over, install it with this command: zypper install /path/to/zip*rpm

Part 2  How to Use Zip

Now that zip is installed, you can use it with a command like this (assuming you have three regular files named pub.txt, pub1.txt, pub2.txt):

zip target.zip pub.txt pub1.txt pub2.txt

The above command will create a zip file called target.zip.  The files will be compressed (that is, the .zip file will be smaller than the sum of the three .txt files).  This can help reduce disk I/O when fetching the file, moving it around, and reduce network congestion with fewer packets over the network when it is in transit.

How do you unzip files using RHEL (or CentOS or Fedora Linux)?

How do you unzip files using Red Hat Enterprise Linux (or CentOS or Fedora Linux)?

Goal:  You want to use unzip when you are using Red Hat Enterprise Linux (or CentOS or Fedora Linux).
Background:  The unzip character-based utility is useful for many reasons.  At the command line you can access compressed files that normally occupy little space on the disk.  Transferring .zip files is great for keeping network bandwidth utilization low.

Try this command to see if zip is installed: man zip

Try this command to see if unzip is installed: man unzip

Part 1:  How to Install Unzip
If the command cannot be found, use these commands:

sudo su -
yum install -y unzip

If you cannot install unzip that way (either because you have no Internet connection or rpm package repository server configured on your network), go to this URL:  http://rpmfind.net

Search for "unzip."  To determine the exact version of RedHat Linux you are using, issue this command: cat /etc/*-release

While rpmfind.net has no RHEL packages, CentOS rpms should work. They definitely work for RHEL 7.2 for unzip.  

Once the .rpm is downloaded, you can use this command: rpm -ivh unzip-6.0-15.el7.x86_64.rpm

(where unzip-6.0-15.el7.x86_64.rpm is the exact name of the rpm package you downloaded)

Part 2: How to Use Unzip

Now that unzip is installed, you can use it with a command like this (assuming you have a file named foobar.zip):

unzip foobar.zip

The above command will decompress the contents while retaining a copy.  The extracted contents will be decompressed in the same directory you run the command in.  The files will not necessarily go to the directory where foobar.zip is (e.g., if you are in /root/ and run unzip /tmp/foobar.zip the extracted files will go into the /root/ directory).

How do you zip files using Red Hat Enterprise Linux (or CentOS or Fedora Linux)?

Goal:  You want to use zip when you are using Red Hat Enterprise Linux (or CentOS or Fedora Linux).
Background:  The zip character-based utility is useful for many reasons.  At the command line you can free up space while retaining files for future usage.  Try this command to see if zip is installed: man zip

Part 1:  How to install zip?
If the command cannot be found, use these commands:

sudo yum install -y zip

If you do not have access to the Internet, and your network has no rpm  configured, get the file from here:  http://rpmfind.net

Search for "zip."  To find the exact version of RedHat you are using, issue this command: cat /etc/*-release

While rpmfind.net has no RHEL packages, CentOS rpms should work. They definitely work with RHEL 7.2 for zip.  

Once the .rpm is downloaded, you can use this command: sudo rpm -ivh zip-3.0-10.el7.x86_64.rpm

(where zip-3.0-10.el7.x86_64.rpm is the exact name of the rpm package you downloaded)

Part 2:  How to Use Zip
Now that zip is installed, you can use it with a command like this (assuming you have three regular files named pub.txt, pub1.txt, pub2.txt):

zip target.zip pub.txt pub1.txt pub2.txt

The above command will create a zip file called target.zip.  The files will be compressed (that is, the .zip file will be smaller than the sum of the three .txt files).  This can help reduce disk I/O when fetching the file, moving it around, and reduce network congestion with fewer packets over the network when it is in transit.