Skip to content

Instantly share code, notes, and snippets.

@arnobroekhof
Last active December 16, 2015 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnobroekhof/5400051 to your computer and use it in GitHub Desktop.
Save arnobroekhof/5400051 to your computer and use it in GitHub Desktop.
Converts the fstab of a linux to a puppet config file
#!/bin/sh
FILE=$1
if [ -z $1 ]
then
echo "No file given"
exit 1
fi
if [ ! -f $1 ]
then
echo "File $1 doesn't exist, exiting...."
exit 1
fi
echo "# mount points from fstab" > "fstab.pp"
cat $1 |grep ^[^#$] | while read LINE; do
REMOTE=`echo $LINE | awk '{ print $1 }'`
LOCAL=`echo $LINE | awk '{ print $2 }'`
FSTYPE=`echo $LINE | awk '{ print $3 }'`
OPTS=`echo $LINE | awk '{ print $4 }'`
EXTRA=`echo $LINE | awk '{ print $5 " " $6 }'`
cat >> "fstab.pp" << EOF
# mount point ${REMOTE}
exec { "create-${LOCAL}-dir":
cwd => "/tmp",
creates => "${LOCAL}",
path => ["/usr/bin", "/usr/sbin","/bin"],
command => "/bin/mkdir -p ${LOCAL}",
}
mount { "${LOCAL}":
device => "${REMOTE}",
fstype => "${FSTYPE}",
ensure => "mounted",
options => "${OPTS}",
atboot => true,
require => Exec["create-${LOCAL}-dir"],
}
EOF
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment