Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 6104

How validate the mount points and ensure that it is an expected state

$
0
0
I am trying to puppetize a post install script for database and the requirement is to puppetize a section for mount points What it does ? 1. Check if storage volumes are actually mounted 2. Check directory permissions { For each directory being checked specify directory:permissions:user:group to audit} 3. Check NFS mount options {RAC and non-RAC hosts may have different requirements} After sometime of research, i found the mount resource type, but it mandates device name, But I am not worried about the device and just need to ensure that the the mounts exists, Do we have any other option of doing it,. ? Below is the bash code -- ########################### # Check if storage volumes are actually mounted ########################### MOUNTPOINT_LIST="/n01/oraadmin1 /s01/oraadmin1 /n01/oraarch1 /n01/oraarch2 /n01/oracluster1 /n01/oradata1 /n01/oraggsbin /n01/oraggsdata /s01/oradata1" # Original list included oraflash1, but this is an optional mount on some systems. # MOUNTPOINT_LIST="/n01/oraadmin1 /s01/oraadmin1 /n01/oraarch1 /n01/oraarch2 /n01/oracluster1 /n01/oradata1 /n01/oraflash1 /n01/oraggsbin /n01/oraggsdata /s01/oradata1" for THIS_MOUNT in $MOUNTPOINT_LIST; do if [[ ! -L $THIS_MOUNT ]]; then if [ `cat /etc/fstab | grep -i $THIS_MOUNT | wc -l` -gt 0 ] then #Test if storage is mounted MOUNTED_FS_CHECK=`df -k $THIS_MOUNT | grep $THIS_MOUNT` if [[ -z $MOUNTED_FS_CHECK ]]; then put_error "$THIS_MOUNT storage is not mounted. " fi fi fi done ########################### # Check directory permissions # For each directory being checked specify directory:permissions:user:group to audit ########################### if [[ $PLATFORM == 'SLES' ]] then DIRPERMS_TUPLE_LIST="/dba:755:oracle:dba /home/oracle:755:oracle:oinstall /n01/oraadmin1:755:oracle:dba /s01/oraadmin1:755:oracle:dba /n01/oraarch1:755:oracle:dba /n01/oraarch2:755:oracle:dba /n01/oracluster1:755:oracle:dba /n01/oradata1:755:oracle:dba /n01/oraflash1:755:oracle:dba /n01/oraggsbin:755:ggs:ggs /n01/oraggsdata:755:ggs:ggs /s01/oradata1:755:oracle:dba /tmp:1777:root:root /u01:755:oracle:oinstall /u01/app:755:oracle:oinstall /u01/app/oracle:755:oracle:oinstall" else DIRPERMS_TUPLE_LIST="/dba:755:oracle:dba /home/oracle:700:oracle:oinstall /n01/oraadmin1:755:oracle:dba /s01/oraadmin1:755:oracle:dba /n01/oraarch1:755:oracle:dba /n01/oraarch2:755:oracle:dba /n01/oracluster1:755:oracle:dba /n01/oradata1:755:oracle:dba /n01/oraflash1:755:oracle:dba /n01/oraggsbin:755:ggs:ggs /n01/oraggsdata:755:ggs:ggs /s01/oradata1:755:oracle:dba /tmp:1777:root:root /u01:755:oracle:oinstall /u01/app:755:oracle:oinstall /u01/app/oracle:755:oracle:oinstall" fi for THIS_TUPLE in $DIRPERMS_TUPLE_LIST; do unset THIS_DIRECTORY THIS_PERMISSIONS THIS_USER THIS_GROUP PERMISSIONS_CHECK USER_CHECK GROUP_CHECK THIS_DIRECTORY=`echo $THIS_TUPLE | $AWK 'BEGIN {FS=":"} {print $1}'` THIS_PERMISSIONS=`echo $THIS_TUPLE | $AWK 'BEGIN {FS=":"} {print $2}'` THIS_USER=`echo $THIS_TUPLE | $AWK 'BEGIN {FS=":"} {print $3}'` THIS_GROUP=`echo $THIS_TUPLE | $AWK 'BEGIN {FS=":"} {print $4}'` if [[ ! -L $THIS_DIRECTORY ]]; then PERMISSIONS_CHECK=`find $THIS_DIRECTORY -maxdepth 0 -perm $THIS_PERMISSIONS -type d` if [[ -z $PERMISSIONS_CHECK ]]; then put_error "$THIS_DIRECTORY Permissions" "$THIS_PERMISSIONS" fi USER_CHECK=`find $THIS_DIRECTORY -maxdepth 0 -user $THIS_USER -type d` if [[ -z $USER_CHECK ]]; then put_error "$THIS_DIRECTORY User" "$THIS_USER" fi GROUP_CHECK=`find $THIS_DIRECTORY -maxdepth 0 -group $THIS_GROUP -type d` if [[ -z $GROUP_CHECK ]]; then put_error "$THIS_DIRECTORY Group" "$THIS_GROUP" fi else PERMISSIONS_CHECK=`find $THIS_DIRECTORY -maxdepth 0 -perm 777 -type l` if [[ -z $PERMISSIONS_CHECK ]]; then put_error "$THIS_DIRECTORY Permissions" "$THIS_PERMISSIONS" fi fi done ######################################### # Check NFS mount options # RAC and non-RAC hosts may have different requirements ######################################### if [[ "$CHECK_RAC" = "TRUE" ]]; then # /n../oraflash1, /n../oradata1, /s../oradata1, /s../oraadmin1 # actimeo=0 for RAC, omit actimeo=0 for standalone # Update on 12-JAN-2017: removed oraggsbin from BASE_NFS_MOUNT_OPTIONS_VAL check and created a separate check for it (GGSBIN_NFS_MOUNT_OPTIONS_VAL) BASE_NFS_MOUNT_OPTIONS_VAL="rw bg nfsvers=3 tcp hard nointr timeo=600 rsize=32768 wsize=32768 actimeo=0" # /n01/oraggsbin # include actimeo=0 for both RAC and standalone GGSBIN_NFS_MOUNT_OPTIONS_VAL="rw bg nfsvers=3 tcp hard nointr timeo=600 rsize=32768 wsize=32768 actimeo=0" # /n01/oraggsdata # actimeo=0 for RAC, omit actimeo=0 for standalone, noac for both RAC and standalone # Update on 12-JAN-2017: no longer omitting actimeo=0 for standalone, per MOS Doc ID 1232303.1 GGSDATA_NFS_MOUNT_OPTIONS_VAL="rw bg nfsvers=3 tcp hard nointr timeo=600 rsize=32768 wsize=32768 actimeo=0 noac" # /n../oraadmin1 # omit actimeo=0 for both RAC and standalone ADMIN_NFS_MOUNT_OPTIONS_VAL="rw bg nfsvers=3 tcp hard nointr timeo=600 rsize=32768 wsize=32768" # /n../oraarch. # omit actimeo=0 for both RAC and standalone ARCHLOG_NFS_MOUNT_OPTIONS_VAL="rw bg nfsvers=3 tcp hard nointr timeo=600 rsize=32768 wsize=32768" # /n01/oracluster1 # RAC only OCRVOTE_NFS_MOUNT_OPTIONS_VAL="rw bg nfsvers=3 tcp hard nointr timeo=600 rsize=32768 wsize=32768 actimeo=0 noac" else BASE_NFS_MOUNT_OPTIONS_VAL="rw bg nfsvers=3 tcp hard nointr timeo=600 rsize=32768 wsize=32768" GGSBIN_NFS_MOUNT_OPTIONS_VAL="rw bg nfsvers=3 tcp hard nointr timeo=600 rsize=32768 wsize=32768 actimeo=0" GGSDATA_NFS_MOUNT_OPTIONS_VAL="rw bg nfsvers=3 tcp hard nointr timeo=600 rsize=32768 wsize=32768 actimeo=0 noac" ADMIN_NFS_MOUNT_OPTIONS_VAL="rw bg nfsvers=3 tcp hard nointr timeo=600 rsize=32768 wsize=32768" ARCHLOG_NFS_MOUNT_OPTIONS_VAL="rw bg nfsvers=3 tcp hard nointr timeo=600 rsize=32768 wsize=32768" fi # Check NFS permissions # BASE (/n../oraflash1, /n../oradata1, /s../oradata1, /s../oraadmin1) for MOUNT_POINT in `cat /etc/fstab 2>/dev/null | grep snap | grep -v "/n../oraadmin1" | grep -v "/n../oraarch" | grep -v "/n01/oracluster1" | grep -v "/n01/oraggsbin" |grep -v "/n01/oraggsdata" | awk '{print $2 "|" $4}'` do FS=`echo $MOUNT_POINT | awk 'BEGIN {FS="|"} {print $1}'` BASE_NFS_MOUNT_OPTIONS_FOUND=`echo $MOUNT_POINT | awk 'BEGIN {FS="|" } {print $2}' | sed 's/,/ /g'` # check for missing mount options for O in $BASE_NFS_MOUNT_OPTIONS_VAL do if [[ `echo "$BASE_NFS_MOUNT_OPTIONS_FOUND" | grep "$O" 2> /dev/null | wc -l` -lt 1 ]]; then put_error "NAS mount options ${FS}" "\"${BASE_NFS_MOUNT_OPTIONS_VAL}\"" "${O} is not set" fi done # check for mount options set that shouldn't be for Q in $BASE_NFS_MOUNT_OPTIONS_FOUND do if [[ `echo "$BASE_NFS_MOUNT_OPTIONS_VAL" | grep "$Q" 2> /dev/null | wc -l` -lt 1 ]]; then put_error "NAS mount options ${FS}" "\"${BASE_NFS_MOUNT_OPTIONS_VAL}\"" "${Q} is set and should not be" fi done done # /n01/oraggsbin for MOUNT_POINT in `cat /etc/fstab 2>/dev/null | grep "/n0./oraggsbin" | grep -v "#" | awk '{print $2 "|" $4}'` do FS=`echo $MOUNT_POINT | awk 'BEGIN {FS="|"} {print $1}'` GGSBIN_NFS_MOUNT_OPTIONS_FOUND=`echo $MOUNT_POINT | awk 'BEGIN {FS="|" } {print $2}' | sed 's/,/ /g'` # check for missing mount options for O in $GGSBIN_NFS_MOUNT_OPTIONS_VAL do if [[ `echo "$GGSBIN_NFS_MOUNT_OPTIONS_FOUND" | grep "$O" 2> /dev/null | wc -l` -lt 1 ]]; then put_error "NAS mount options ${FS}" "\"${GGSBIN_NFS_MOUNT_OPTIONS_VAL}\"" "${O} is not set" fi done # check for mount options set that shouldn't be for Q in $GGSBIN_NFS_MOUNT_OPTIONS_FOUND do if [[ `echo "$GGSBIN_NFS_MOUNT_OPTIONS_VAL" | grep "$Q" 2> /dev/null | wc -l` -lt 1 ]]; then put_error "NAS mount options ${FS}" "\"${GGSBIN_NFS_MOUNT_OPTIONS_VAL}\"" "${Q} is set and should not be" fi done done # /n01/oraggsdata for MOUNT_POINT in `cat /etc/fstab 2>/dev/null | grep "/n0./oraggsdata" | grep -v "#" | awk '{print $2 "|" $4}'` do FS=`echo $MOUNT_POINT | awk 'BEGIN {FS="|"} {print $1}'` GGSDATA_NFS_MOUNT_OPTIONS_FOUND=`echo $MOUNT_POINT | awk 'BEGIN {FS="|" } {print $2}' | sed 's/,/ /g'` # check for missing mount options for O in $GGSDATA_NFS_MOUNT_OPTIONS_VAL do if [[ `echo "$GGSDATA_NFS_MOUNT_OPTIONS_FOUND" | grep "$O" 2> /dev/null | wc -l` -lt 1 ]]; then put_error "NAS mount options ${FS}" "\"${GGSDATA_NFS_MOUNT_OPTIONS_VAL}\"" "${O} is not set" fi done # check for mount options set that shouldn't be for Q in $GGSDATA_NFS_MOUNT_OPTIONS_FOUND do if [[ `echo "$GGSDATA_NFS_MOUNT_OPTIONS_VAL" | grep "$Q" 2> /dev/null | wc -l` -lt 1 ]]; then put_error "NAS mount options ${FS}" "\"${GGSDATA_NFS_MOUNT_OPTIONS_VAL}\"" "${Q} is set and should not be" fi done done # /n../oraadmin1 for MOUNT_POINT in `cat /etc/fstab 2>/dev/null | grep "/n../oraadmin1" | grep -v "#" | awk '{print $2 "|" $4}'` do FS=`echo $MOUNT_POINT | awk 'BEGIN {FS="|"} {print $1}'` ADMIN_NFS_MOUNT_OPTIONS_FOUND=`echo $MOUNT_POINT | awk 'BEGIN {FS="|" } {print $2}' | sed 's/,/ /g'` # check for missing mount options for O in $ADMIN_NFS_MOUNT_OPTIONS_VAL do if [[ `echo "$ADMIN_NFS_MOUNT_OPTIONS_FOUND" | grep "$O" 2> /dev/null | wc -l` -lt 1 ]]; then put_error "NAS mount options ${FS}" "\"${ADMIN_NFS_MOUNT_OPTIONS_VAL}\"" "${O} is not set" fi done # check for mount options set that shouldn't be for Q in $ADMIN_NFS_MOUNT_OPTIONS_FOUND do if [[ `echo "$ADMIN_NFS_MOUNT_OPTIONS_VAL" | grep "$Q" 2> /dev/null | wc -l` -lt 1 ]]; then put_error "NAS mount options ${FS}" "\"${ADMIN_NFS_MOUNT_OPTIONS_VAL}\"" "${Q} is set and should not be" fi done done # /n../oraarch. for MOUNT_POINT in `cat /etc/fstab 2>/dev/null | grep "/n../oraarch" | grep -v "#" | awk '{print $2 "|" $4}'` do FS=`echo $MOUNT_POINT | awk 'BEGIN {FS="|"} {print $1}'` ARCHLOG_NFS_MOUNT_OPTIONS_FOUND=`echo $MOUNT_POINT | awk 'BEGIN {FS="|" } {print $2}' | sed 's/,/ /g'` # check for missing mount options for O in $ARCHLOG_NFS_MOUNT_OPTIONS_VAL do if [[ `echo "$ARCHLOG_NFS_MOUNT_OPTIONS_FOUND" | grep "$O" 2> /dev/null | wc -l` -lt 1 ]]; then put_error "NAS mount options ${FS}" "\"${ARCHLOG_NFS_MOUNT_OPTIONS_VAL}\"" "${O} is not set" fi done # check for mount options set that shouldn't be for Q in $ARCHLOG_NFS_MOUNT_OPTIONS_FOUND do if [[ `echo "$ARCHLOG_NFS_MOUNT_OPTIONS_VAL" | grep "$Q" 2> /dev/null | wc -l` -lt 1 ]]; then put_error "NAS mount options ${FS}" "\"${ARCHLOG_NFS_MOUNT_OPTIONS_VAL}\"" "${Q} is set and should not be" fi done done # /n01/oracluster1 for MOUNT_POINT in `cat /etc/fstab 2>/dev/null | grep "/n0./oracluster" | grep -v "#" | awk '{print $2 "|" $4}'` do FS=`echo $MOUNT_POINT | awk 'BEGIN {FS="|"} {print $1}'` OCRVOTE_NFS_MOUNT_OPTIONS_FOUND=`echo $MOUNT_POINT | awk 'BEGIN {FS="|" } {print $2}' | sed 's/,/ /g'` # check for missing mount options for O in $OCRVOTE_NFS_MOUNT_OPTIONS_VAL do if [[ `echo "$OCRVOTE_NFS_MOUNT_OPTIONS_FOUND" | grep "$O" 2> /dev/null | wc -l` -lt 1 ]]; then put_error "NAS mount options ${FS}" "\"${OCRVOTE_NFS_MOUNT_OPTIONS_VAL}\"" "${O} is not set" fi done # check for mount options set that shouldn't be for Q in $OCRVOTE_NFS_MOUNT_OPTIONS_FOUND do if [[ `echo "$OCRVOTE_NFS_MOUNT_OPTIONS_VAL" | grep "$Q" 2> /dev/null | wc -l` -lt 1 ]]; then put_error "NAS mount options ${FS}" "\"${OCRVOTE_NFS_MOUNT_OPTIONS_VAL}\"" "${Q} is set and should not be" fi done done

Viewing all articles
Browse latest Browse all 6104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>