How to Use Conditional Logic With A Puppet Manifest For Executing a Command

Scenario:  You want an exec command in a manifest to be invoked only if a certain file is on the Windows Server.  You do not want the execution of a command to happen if a file does not exist in a certain location.
Solution:  Incorporate the following lines into your manifest (.pp file).
exec { ‘cont_int”:
    command => “echo continual > contint.txt”,
  

How Do You Find Out if The Server Has Puppet Master or Puppet Agent?

Problem scenario
Assuming that you know Puppet is installed, you want to find out if you are on a Linux server that has Puppet Master or Puppet Agent.  This posting applies strictly to Linux or Unix.

Solution
Run this command:
cat /etc/puppet/puppet.conf
Then use “ip addr show” (or ifconfig) to verify the IP address of the server that you are on. 

How To Troubleshoot the mkfs.ext4 Utility

Scenario / Goal: You are trying to add a hard drive (or new storage) to a Linux server.  You want the drive usable.  You attach the drive and use fdisk.  Now you want to use mkfs to create a file system on it.

Problem: You are trying to use mkfs.ext4 but you get this error:  “mkfs.ext4 no such file or directory while trying to determine filesystem size.” 

How To Install Pip On Red Hat version 6 with Python 2.7.x Installed

Goal:  You want to install pip on RedHat 6 with Python version 2.7.x installed.
Problem scenario:  
You try “yum install python-pip” but get an error about python(abi) = 2.6 being an unmet dependency.  Trying to install an older version may require you to downgrade other components.  The latest version of Python packages is often safer and recommended. 
Solution:  Obtain a copy of 

Using Python and Ruby To Read Files

Problem:  You have a Python program that reads in a file named coolFile (in /tmp), and outputs the content to the screen.  The program prints an extra blank line after each line of content of the file named coolFile.  You want the output to not have an extra blank line.  Here is the code:

#/usr/bin/python

x = open(“/tmp/coolFile”, “r”)
for line in x:
        print (line)

How do you have the output now print an extra blank line after each line?

In PowerShell Diskpart Script Does Not Work (Despite No Error) Via “diskpart /s nameofscript.txt”

Goal:  To use a diskpart.exe script (a file of commands that could be ran interactively in sequence).
Problem:  When you run this command via PowerShell it does not work:  diskpart /s C:\Full\Path\script.txt
The result says something like “Microsoft DiskPart …” and there is a list of alphabetic diskpart subcommands (ACTIVE to RECOVER).  There is no explicit error.  The diskpart command and script does no work.

How To Solve the PowerShell Error “The term ‘script’ is not recognized…”

Goal:  You want to run a .ps1 file.
Problem:  You get the error “Powershell : script : The term ‘script’ is not recognized as the name of a cmdlet, At line:1 char:1 + …”
Solution:  Use the “script” resource section inside of a DSC configuration exclusively.  It will not work or run as a standalone PowerShell script.  Scripts with GetScript, SetScript, and TestScript must be run as part of a DSC configuration. 

One Way To Get Around The Error “Get-targetresource PS module does not implement the key property solution” in DSC

Goal:  Apply DSC configuration
Problem/scenario:   When you run the “start-dscconfiguration NameOfConfig -wait -verbose” (where NameOfConfig is the name of the configuration) from the folder that houses the subfolder with NameOfConfig, you get an error like this:  “Get-targetresource PS module does not implement the key property solution”
Solution:  Stop a specific process by running this command.
gps wmi* |? {$_.Modules.ModuleName -like ‘*DSC*’} | Stop-Process -Force
Re-run the “start-dscconfiguration NameOfConfig -wait -verbose” command.

[Sassy_Social_Share]

Problem and Solution: “New Simple Volume” is Greyed Out After Disk Was Added To Windows Server

Goal:  You want to create a new Disk Partition on Windows Server.
Problem:  You go to Server Manager -> Computer Management -> Storage -> Disk Management.  You right click a newly-added partition (in the graphical bar section that says “Unallocated”).  “New Simple Volume,” “New Spanned Volume,” and “New Striped Volume” are all grayed out.  
Solution:  Right click the “Disk X” (where X is the integer associated with the newly-added disk).