Basic Puppet

Earlier today I was helping a friend get started learning puppet.  My favorite configuration management system.  I figured some of the basics I shared might help others.  His focus was on how to handle some very basic things in multiple operating systems.  In these examples we will assume that I am working with two flavors of Linux RHEL and Suse.

 

Set ownership and file permissions:

file { "/etc/passwd":
        owner => $operatingsystem ? {
                redhat => "root",
                suse => "root",
                default => "root",
        },
        group => $operatingsystem ? {
                redhat => "root",
                suse => "wheel",
                default => "root",
        },
        mode => $operatingsystem ? {
                redhat => "644",
                suse => "664",
                default => "644",
        },
} # end of file passwd

 

Simple process with an operating system switch.  The variables you can trigger off in puppet can be found with the facter command.   Once you understand your variables using case operators can be really powerful.

 

Push out a file with different sources:

file { "ntpdconfig":
                name => "/etc/ntp.conf",
                ensure => present,
                replace => true,
                owner => 'root',
                group => 'root',
                mode => '0644',
                source => $operatingsystem ? {
                        redhat => "puppet:///files/redhat/ntp.conf",
                        suse => "puppet:///files/suse/ntp.conf",
                        default => "puppet:///files/redhat/ntp.conf",
                };
        }

Push out the file with different local sources by OS and replace the file if already present.

 

One of the things I love about puppet is the ability to to service checks.  For example ensure that httpd is running and set to start at boot time.  Sometimes the ability to check for the running service requires a custom setting which you can do with the following:

service { tivoli:
                name => "startscript",
                enable => true,
                status => "/bin/ps -ef | /bin/grep startscript_process_name",
                ensure => running,
}

In this case we can use the ps command to check for the process as running.

 

From time to time you need to push out a file and execute if something changes:

 

file { “/scripts/bob.sh”:

ensure => present,

replace => true,

owner => ‘root’,

group => ‘root’,

mode => ‘0750’,

source => “puppet:///files/common/bob.sh”,

}

exec {“bob”:

cwd => “/scripts”,

command => “/scripts/bob.sh”,

require => file[“/scripts/bob.sh”],

timeout => 0,

subscribe => [ File[“/scripts/bob.sh”] ],

}

 

Simple… push out the file bob.sh and if it changes execute it.

 

Here is a template for running code for different operating systems:

case $lsbdistid {
        #-----------RHEL---------------------
        RedHatEnterpriseServer: {

                case $lsbmajdistrelease {
                        5: {
                                                   } #End of RHEL 5
                        6: {
                                                   } #End of RHEL 6
                                                7: {
                                                   } #End of RHEL 7

                } # End of RHEL
                #-----------SUSE Enterprise not for VMware
                Suse: {
                                                11: {
                                                    } #End of Suse 11
                } #End of Suse Enterprise
} #End of lsbdistid

 

Hope it helps.

Change in VMware 5.5 U2 ATS can cause storage outages!

Update:  VMware has posted the following KB and there is a really good article by Comac Hogan on the matter.   I have also posted a PowerCLI script to resolve the issue.

 

Yesterday I was alerted to the fact that there was a change in the VMware 5.5 U2 heartbeat method.  In U2 and vSphere 6 it now uses ATS on VAAI enabled arrays to do heartbeats.   Some arrays are experiencing outages due to this change.   It’s not clear to me what array are exactly effected other than IBM has posted an article here.   It seems to cause one of the following symptoms : Host disconnects from vCenter or storage disconnects from host.  As you can see one of these (storage) is a critical problem creating an all paths down situation potentially.

The fix suggested by IBM disabled the ATS lock method and returns it to pre U2 methods.   It’s my understanding that this is an advanced setting that can be applied without a reboot.  I have also been told that if you create this advanced setting it will be applied via host profile or powercli.

It is very early in the process in all accounts you should open a VMware ticket to get their advice on how to deal with this issue.   They are working on the problem and should produce a KB when possible with more information.   I personally would not apply this setting unless you are experiencing the issue as identified by VMware.   I wish I had more information but it has not happened in my environment.

 

Post comments if you are experiencing this issue with more information.  I will update the article once the KB is posted.